SlideShare a Scribd company logo
1 of 20
Download to read 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

More Related Content

Similar to 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
 

Similar to 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
 

Recently uploaded

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
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
 

Recently uploaded (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

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