SlideShare uma empresa Scribd logo
1 de 20
Baixar para ler offline
Writing PHP Tests
                            PHPNW TestFest 2009




Wednesday, 27 May 2009
Goals

                         Increase test coverage in PHP

                         Win an elePHPant

                         Have Fun

                         Beat London

                         Cheat if we have to

Wednesday, 27 May 2009
Preparation


                         Grab gcc, autotools, flex-old,
                         bison

                         Make your directory ~/testfest




Wednesday, 27 May 2009
Snapshot

                         CVS Checkout

                         Snapshot (snaps.php.net)

                         Windows Snapshot
                         (windows.php.net/snapshots/)



Wednesday, 27 May 2009
Windows

                         run-tests.php

                           PHP 5.3 http://short.ie/yui3db

                           PHP 5.2 http://short.ie/zm5vwb

                         Relax


Wednesday, 27 May 2009
Building


                         cd ~/testfest

                         ./configure --disable-all --enable-spl

                         make / make -j3




Wednesday, 27 May 2009
Checking it worked


                         sapi/cli/php -v

                         make test (takes a while)

                         Submit a report



Wednesday, 27 May 2009
Running Selective
                               Tests


                         run run-tests.php manually

                         set TEST_PHP_EXECUTABLE




Wednesday, 27 May 2009
Demo




Wednesday, 27 May 2009
What makes a phpt?


                         Small Collection of PHP Scripts

                         Separated by section markers

                         TEST, FILE, EXPECT



Wednesday, 27 May 2009
phpt bits
                         --TEST--

                           Description of the test

                         --FILE--

                           Contents is passed to PHP

                         --EXPECT--

                           The expected output


Wednesday, 27 May 2009
A simple phpt




Wednesday, 27 May 2009
Other sections


                         --CREDITS--

                         --SKIPIF--

                         --EXPECTF--



Wednesday, 27 May 2009
Sample Test




Wednesday, 27 May 2009
SPL

                         Standard PHP Library

                         Solves Common Problems

                         Data structures, algorithms,
                         iterators



Wednesday, 27 May 2009
SPL Documentation


                         http://php.net/~helly/

                         http://uk2.php.net/spl




Wednesday, 27 May 2009
Our Goals

                         Write a simple basic test

                         Write a test for SPLFixedArray,
                         SPLDoublyLinkedList

                         Look at some iterator tests



Wednesday, 27 May 2009
SVN Checkout

                         SVN Command Line

                         Tortoise SVN

                         Versions on OSX

                         http://testfest.php.net/repos/
                         testfest/NorthWestUG/


Wednesday, 27 May 2009
Run test
                         SVN: http://testfest.php.net/repos/
                         testfest/NorthWestUG/

                         Linux: export TEST_PHP_EXECUTABLE=/path/
                         to/checkout/sapi/cli/php

                         Windows: set TEST_PHP_EXECUTABLE=c:path
                         tophp.exe

                         php run-tests.php /path/to/svntestfest/
                         ext/spl/tests


Wednesday, 27 May 2009
URLs

                         http://qa.php.net/
                         phpt_details.php

                         http://qa.php.net/write-test.php

                         http://uk.php.net/spl



Wednesday, 27 May 2009

Mais conteúdo relacionado

Semelhante a How to write PHPT tests

PHPNW Test Fest Pre-presentation
PHPNW Test Fest Pre-presentationPHPNW Test Fest Pre-presentation
PHPNW Test Fest Pre-presentationLorna Mitchell
 
intl me this, intl me that
intl me this, intl me thatintl me this, intl me that
intl me this, intl me thatAndrei Zmievski
 
Building a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQueryBuilding a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
Taming the Deployment Beast
Taming the Deployment BeastTaming the Deployment Beast
Taming the Deployment BeastChris Cornutt
 
Acceptance testing in php with Codeception - Techmeetup Edinburgh
Acceptance testing in php with Codeception - Techmeetup EdinburghAcceptance testing in php with Codeception - Techmeetup Edinburgh
Acceptance testing in php with Codeception - Techmeetup EdinburghEngineor
 
LMP1 IO and Filesystems=========================Welcome .docx
LMP1 IO and Filesystems=========================Welcome .docxLMP1 IO and Filesystems=========================Welcome .docx
LMP1 IO and Filesystems=========================Welcome .docxmanningchassidy
 
関西アンカンファレンス PHP ではじめるテストコード
関西アンカンファレンス PHP ではじめるテストコード関西アンカンファレンス PHP ではじめるテストコード
関西アンカンファレンス PHP ではじめるテストコードShinya Ohyanagi
 
MacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meetMacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meetMatt Aimonetti
 
Codeception: introduction to php testing (v2 - Aberdeen php)
Codeception: introduction to php testing (v2 - Aberdeen php)Codeception: introduction to php testing (v2 - Aberdeen php)
Codeception: introduction to php testing (v2 - Aberdeen php)Engineor
 
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009Jan Wedekind
 
Hacking Selenium @ JSConf
Hacking Selenium @ JSConfHacking Selenium @ JSConf
Hacking Selenium @ JSConfhugs
 
Design Patterns - LFM and POM
Design Patterns - LFM and POMDesign Patterns - LFM and POM
Design Patterns - LFM and POMJohn Staveley
 
Doctrine 2: Enterprise Persistence Layer for PHP
Doctrine 2: Enterprise Persistence Layer for PHPDoctrine 2: Enterprise Persistence Layer for PHP
Doctrine 2: Enterprise Persistence Layer for PHPJonathan Wage
 
Caching, Memcached And Rails
Caching, Memcached And RailsCaching, Memcached And Rails
Caching, Memcached And Railsguestac752c
 
Codeception: introduction to php testing
Codeception: introduction to php testingCodeception: introduction to php testing
Codeception: introduction to php testingEngineor
 

Semelhante a How to write PHPT tests (19)

PHPNW Test Fest Pre-presentation
PHPNW Test Fest Pre-presentationPHPNW Test Fest Pre-presentation
PHPNW Test Fest Pre-presentation
 
intl me this, intl me that
intl me this, intl me thatintl me this, intl me that
intl me this, intl me that
 
Building a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQueryBuilding a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQuery
 
Taming the Deployment Beast
Taming the Deployment BeastTaming the Deployment Beast
Taming the Deployment Beast
 
Acceptance testing in php with Codeception - Techmeetup Edinburgh
Acceptance testing in php with Codeception - Techmeetup EdinburghAcceptance testing in php with Codeception - Techmeetup Edinburgh
Acceptance testing in php with Codeception - Techmeetup Edinburgh
 
LMP1 IO and Filesystems=========================Welcome .docx
LMP1 IO and Filesystems=========================Welcome .docxLMP1 IO and Filesystems=========================Welcome .docx
LMP1 IO and Filesystems=========================Welcome .docx
 
関西アンカンファレンス PHP ではじめるテストコード
関西アンカンファレンス PHP ではじめるテストコード関西アンカンファレンス PHP ではじめるテストコード
関西アンカンファレンス PHP ではじめるテストコード
 
Unit Test Your Database! (PgCon 2009)
Unit Test Your Database! (PgCon 2009)Unit Test Your Database! (PgCon 2009)
Unit Test Your Database! (PgCon 2009)
 
LTP
LTPLTP
LTP
 
MacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meetMacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meet
 
Codeception: introduction to php testing (v2 - Aberdeen php)
Codeception: introduction to php testing (v2 - Aberdeen php)Codeception: introduction to php testing (v2 - Aberdeen php)
Codeception: introduction to php testing (v2 - Aberdeen php)
 
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
 
Hacking Selenium @ JSConf
Hacking Selenium @ JSConfHacking Selenium @ JSConf
Hacking Selenium @ JSConf
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Design Patterns - LFM and POM
Design Patterns - LFM and POMDesign Patterns - LFM and POM
Design Patterns - LFM and POM
 
Doctrine 2: Enterprise Persistence Layer for PHP
Doctrine 2: Enterprise Persistence Layer for PHPDoctrine 2: Enterprise Persistence Layer for PHP
Doctrine 2: Enterprise Persistence Layer for PHP
 
Caching, Memcached And Rails
Caching, Memcached And RailsCaching, Memcached And Rails
Caching, Memcached And Rails
 
Linq Refresher
Linq RefresherLinq Refresher
Linq Refresher
 
Codeception: introduction to php testing
Codeception: introduction to php testingCodeception: introduction to php testing
Codeception: introduction to php testing
 

Último

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 

Último (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

How to write PHPT tests

  • 1. Writing PHP Tests PHPNW TestFest 2009 Wednesday, 27 May 2009
  • 2. Goals Increase test coverage in PHP Win an elePHPant Have Fun Beat London Cheat if we have to Wednesday, 27 May 2009
  • 3. Preparation Grab gcc, autotools, flex-old, bison Make your directory ~/testfest Wednesday, 27 May 2009
  • 4. Snapshot CVS Checkout Snapshot (snaps.php.net) Windows Snapshot (windows.php.net/snapshots/) Wednesday, 27 May 2009
  • 5. Windows run-tests.php PHP 5.3 http://short.ie/yui3db PHP 5.2 http://short.ie/zm5vwb Relax Wednesday, 27 May 2009
  • 6. Building cd ~/testfest ./configure --disable-all --enable-spl make / make -j3 Wednesday, 27 May 2009
  • 7. Checking it worked sapi/cli/php -v make test (takes a while) Submit a report Wednesday, 27 May 2009
  • 8. Running Selective Tests run run-tests.php manually set TEST_PHP_EXECUTABLE Wednesday, 27 May 2009
  • 10. What makes a phpt? Small Collection of PHP Scripts Separated by section markers TEST, FILE, EXPECT Wednesday, 27 May 2009
  • 11. phpt bits --TEST-- Description of the test --FILE-- Contents is passed to PHP --EXPECT-- The expected output Wednesday, 27 May 2009
  • 13. Other sections --CREDITS-- --SKIPIF-- --EXPECTF-- Wednesday, 27 May 2009
  • 15. SPL Standard PHP Library Solves Common Problems Data structures, algorithms, iterators Wednesday, 27 May 2009
  • 16. SPL Documentation http://php.net/~helly/ http://uk2.php.net/spl Wednesday, 27 May 2009
  • 17. Our Goals Write a simple basic test Write a test for SPLFixedArray, SPLDoublyLinkedList Look at some iterator tests Wednesday, 27 May 2009
  • 18. SVN Checkout SVN Command Line Tortoise SVN Versions on OSX http://testfest.php.net/repos/ testfest/NorthWestUG/ Wednesday, 27 May 2009
  • 19. Run test SVN: http://testfest.php.net/repos/ testfest/NorthWestUG/ Linux: export TEST_PHP_EXECUTABLE=/path/ to/checkout/sapi/cli/php Windows: set TEST_PHP_EXECUTABLE=c:path tophp.exe php run-tests.php /path/to/svntestfest/ ext/spl/tests Wednesday, 27 May 2009
  • 20. URLs http://qa.php.net/ phpt_details.php http://qa.php.net/write-test.php http://uk.php.net/spl Wednesday, 27 May 2009