SlideShare a Scribd company logo
1 of 25
PHPUnit
Rinat Khabibiev
* www.ExigenServices.com
PHPUNIT: BEGINNING
Even good programmers make mistakes
* www.ExigenServices.com
PHPUNIT
• Beginning
• Installation
• Test Driven Development
• Parameterized Unit Testing
• Testing Exceptions
• Dependencies
• Fixtures
• Patterns and Antipatterns
Contents
* www.ExigenServices.com
PHPUNIT: BEGINNING
• easy to learn to write
• easy to write
• easy to read
• easy to execute
• quick to execute
• isolated
• composable
What should be the tests
* www.ExigenServices.com
PHPUNIT: BEGINNING
Very simple example
* www.ExigenServices.com
PHPUNIT: BEGINNING
Very simple example
* www.ExigenServices.com
PHPUNIT: BEGINNING
• assertEquals($expr1, $expr2, $fail_msg)
• assertTrue($expr, $fail_msg)
• assertFalse($expr, $fail_msg)
• assertInstanceOf($expected, $expr, $fail_msg)
• assertNull($expr, $fail_msg)
• assertEmpty($expr, $fail_msg)
• assertThat($expr, $constraint, $fail_msg)
Assertions
* www.ExigenServices.com
PHPUNIT: INSTALLATION
Installation using PEAR
cd <PHP_dir>
go-pear
pear upgrade PEAR
pear config-set auto_discover 1
pear install pear.phpunit.de/PHPUnit
• PHP 5.2.7 - minimum
• PHP 5.3.9 - recommended
* www.ExigenServices.com
PHPUNIT: TEST DRIVEN DEVELOPMENT
~/models/Weekday.php
* www.ExigenServices.com
PHPUNIT: TEST DRIVEN DEVELOPMENT
~/tests/models/WeekdayTest.php
* www.ExigenServices.com
PHPUNIT: TEST DRIVEN DEVELOPMENT
Tests execution
~# cd <tests_dir>/models
~# phpunit WeekdayTest
PHPUnit 3.6.0 by Sebastian Bergmann.
..
Time: 0 seconds, Memory: 5.25Mb
OK (2 test, 0 assertion)
* www.ExigenServices.com
PHPUNIT: TEST DRIVEN DEVELOPMENT
Tests execution results
. - success
F - assertion fails
E - error occurs
S - test skipped
I - test incomplete or not implemented
* www.ExigenServices.com
PHPUNIT: TEST DRIVEN DEVELOPMENT
~/tests/models/WeekdayTest.php
* www.ExigenServices.com
PHPUNIT: TEST DRIVEN DEVELOPMENT
~/tests/models/WeekdayTest.php
* www.ExigenServices.com
PHPUNIT: TEST DRIVEN DEVELOPMENT
~/models/Weekday.php
* www.ExigenServices.com
PHPUNIT: PARAMETERIZED UNIT TESTING
~/tests/models/WeekdayTest.php
* www.ExigenServices.com
PHPUNIT: TESTING EXCEPTIONS
~/models/Weekday.php
* www.ExigenServices.com
PHPUNIT: TESTING EXCEPTIONS
~/tests/models/WeekdayTest.php
* www.ExigenServices.com
PHPUNIT: DEPENDENCIES
~/tests/models/WeekdayTest.php
* www.ExigenServices.com
PHPUNIT: FIXTURES
~/tests/models/WeekdayTest.php
* www.ExigenServices.com
PHPUNIT: FIXTURES
• setUpBeforeClass (once before all tests)
• setUp (before each test)
• assertPreConditions (before each test)
• assertPostConditions (after each successful test)
• tearDown (after each test)
• onNotSuccessfulTest (after each failed test)
• tearDownAfterClass (once after all tests)
All methods available
* www.ExigenServices.com
PHPUNIT: PATTERNS AND ANTIPATTERNS
Unit tests are for testing source code units
* www.ExigenServices.com
PHPUNIT: PATTERNS AND ANTIPATTERNS
• assertEquals($expr1, $expr2, $fail_msg)
• assertTrue($expr, $fail_msg)
• assertFalse($expr, $fail_msg)
• assertInstanceOf($expected, $expr, $fail_msg)
• assertNull($expr, $fail_msg)
• assertEmpty($expr, $fail_msg)
• assertThat($expr, $constraint, $fail_msg)
Assertions
* www.ExigenServices.com
PHPUNIT: PATTERNS AND ANTIPATTERNS
Somewhere in our application
* www.ExigenServices.com
PHPUNIT
The End

More Related Content

What's hot

Detecting headless browsers
Detecting headless browsersDetecting headless browsers
Detecting headless browsersSergey Shekyan
 
Javascript Test Automation Workshop (21.08.2014)
Javascript Test Automation Workshop (21.08.2014)Javascript Test Automation Workshop (21.08.2014)
Javascript Test Automation Workshop (21.08.2014)Deutsche Post
 
Testing frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabsTesting frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabsTudor Barbu
 
Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817Tse-Ching Ho
 
Behaviour-Driven Development, Ruby Style
Behaviour-Driven Development, Ruby StyleBehaviour-Driven Development, Ruby Style
Behaviour-Driven Development, Ruby StyleOpenFest team
 
Backbone.js
Backbone.jsBackbone.js
Backbone.jsVO Tho
 
CasperJS and PhantomJS for Automated Testing
CasperJS and PhantomJS for Automated TestingCasperJS and PhantomJS for Automated Testing
CasperJS and PhantomJS for Automated TestingX-Team
 
Time for intersection observer
Time for intersection observerTime for intersection observer
Time for intersection observerJonas Ohlsson Aden
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to ProtractorJie-Wei Wu
 
Helma / RingoJS – Vienna.js Minitalk
Helma / RingoJS – Vienna.js MinitalkHelma / RingoJS – Vienna.js Minitalk
Helma / RingoJS – Vienna.js MinitalkPhilipp Naderer
 
Testing MeteorJS using CasperJS
Testing MeteorJS using CasperJSTesting MeteorJS using CasperJS
Testing MeteorJS using CasperJSStephan Hochhaus
 

What's hot (16)

Detecting headless browsers
Detecting headless browsersDetecting headless browsers
Detecting headless browsers
 
Javascript Test Automation Workshop (21.08.2014)
Javascript Test Automation Workshop (21.08.2014)Javascript Test Automation Workshop (21.08.2014)
Javascript Test Automation Workshop (21.08.2014)
 
Testing frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabsTesting frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabs
 
Jasmine with JS-Test-Driver
Jasmine with JS-Test-DriverJasmine with JS-Test-Driver
Jasmine with JS-Test-Driver
 
Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817
 
webworkers
webworkerswebworkers
webworkers
 
Zombiejs
ZombiejsZombiejs
Zombiejs
 
Behaviour-Driven Development, Ruby Style
Behaviour-Driven Development, Ruby StyleBehaviour-Driven Development, Ruby Style
Behaviour-Driven Development, Ruby Style
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
JavaScript Web Workers
JavaScript Web WorkersJavaScript Web Workers
JavaScript Web Workers
 
CasperJS and PhantomJS for Automated Testing
CasperJS and PhantomJS for Automated TestingCasperJS and PhantomJS for Automated Testing
CasperJS and PhantomJS for Automated Testing
 
Time for intersection observer
Time for intersection observerTime for intersection observer
Time for intersection observer
 
Code ceptioninstallation
Code ceptioninstallationCode ceptioninstallation
Code ceptioninstallation
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to Protractor
 
Helma / RingoJS – Vienna.js Minitalk
Helma / RingoJS – Vienna.js MinitalkHelma / RingoJS – Vienna.js Minitalk
Helma / RingoJS – Vienna.js Minitalk
 
Testing MeteorJS using CasperJS
Testing MeteorJS using CasperJSTesting MeteorJS using CasperJS
Testing MeteorJS using CasperJS
 

Viewers also liked

Investment_Attraction_Strategy_2016-2019 (1)
Investment_Attraction_Strategy_2016-2019 (1)Investment_Attraction_Strategy_2016-2019 (1)
Investment_Attraction_Strategy_2016-2019 (1)Kwabena Ansah
 
Fabricio - Docker deploy automation
Fabricio - Docker deploy automationFabricio - Docker deploy automation
Fabricio - Docker deploy automationRinat Khabibiev
 
Enriquez adriana portfolio binder
Enriquez adriana portfolio binderEnriquez adriana portfolio binder
Enriquez adriana portfolio binderAdriana Enriquez
 
Design principles in software development
Design principles in software developmentDesign principles in software development
Design principles in software developmentRinat Khabibiev
 
Học cách sống hòa bình với bệnh khớp
Học cách sống hòa bình với bệnh khớpHọc cách sống hòa bình với bệnh khớp
Học cách sống hòa bình với bệnh khớpjoellen270
 
Houseknecht Data Project Presentation
Houseknecht Data Project PresentationHouseknecht Data Project Presentation
Houseknecht Data Project PresentationAngela Kambic
 
Cẩn thận với thoái hóa đốt sống cổ
Cẩn thận với thoái hóa đốt sống cổCẩn thận với thoái hóa đốt sống cổ
Cẩn thận với thoái hóa đốt sống cổjoesph652
 
Pacific earthquake engineering research center
Pacific earthquake engineering research centerPacific earthquake engineering research center
Pacific earthquake engineering research centerJaime Espinoza Skinfield
 
Drakkar J. - Social Media Portfolio
Drakkar J. - Social Media PortfolioDrakkar J. - Social Media Portfolio
Drakkar J. - Social Media PortfolioDrakkar Jones
 
S. Jones Resume - 0215
S. Jones Resume - 0215S. Jones Resume - 0215
S. Jones Resume - 0215Shelly Jones
 
Chef a la local [autosaved]
Chef a la local [autosaved]Chef a la local [autosaved]
Chef a la local [autosaved]Drakkar Jones
 
Il Maquillage - Aspetti antropologici
Il Maquillage - Aspetti antropologiciIl Maquillage - Aspetti antropologici
Il Maquillage - Aspetti antropologici1003155
 

Viewers also liked (17)

Investment_Attraction_Strategy_2016-2019 (1)
Investment_Attraction_Strategy_2016-2019 (1)Investment_Attraction_Strategy_2016-2019 (1)
Investment_Attraction_Strategy_2016-2019 (1)
 
Fabricio - Docker deploy automation
Fabricio - Docker deploy automationFabricio - Docker deploy automation
Fabricio - Docker deploy automation
 
Photosynthesis
PhotosynthesisPhotosynthesis
Photosynthesis
 
Enriquez adriana portfolio binder
Enriquez adriana portfolio binderEnriquez adriana portfolio binder
Enriquez adriana portfolio binder
 
Design principles in software development
Design principles in software developmentDesign principles in software development
Design principles in software development
 
resume (1)
resume (1)resume (1)
resume (1)
 
Teeneger
TeenegerTeeneger
Teeneger
 
fagu Resume final
fagu Resume finalfagu Resume final
fagu Resume final
 
Học cách sống hòa bình với bệnh khớp
Học cách sống hòa bình với bệnh khớpHọc cách sống hòa bình với bệnh khớp
Học cách sống hòa bình với bệnh khớp
 
Houseknecht Data Project Presentation
Houseknecht Data Project PresentationHouseknecht Data Project Presentation
Houseknecht Data Project Presentation
 
Cẩn thận với thoái hóa đốt sống cổ
Cẩn thận với thoái hóa đốt sống cổCẩn thận với thoái hóa đốt sống cổ
Cẩn thận với thoái hóa đốt sống cổ
 
Pacific earthquake engineering research center
Pacific earthquake engineering research centerPacific earthquake engineering research center
Pacific earthquake engineering research center
 
I'm designer!
I'm designer!I'm designer!
I'm designer!
 
Drakkar J. - Social Media Portfolio
Drakkar J. - Social Media PortfolioDrakkar J. - Social Media Portfolio
Drakkar J. - Social Media Portfolio
 
S. Jones Resume - 0215
S. Jones Resume - 0215S. Jones Resume - 0215
S. Jones Resume - 0215
 
Chef a la local [autosaved]
Chef a la local [autosaved]Chef a la local [autosaved]
Chef a la local [autosaved]
 
Il Maquillage - Aspetti antropologici
Il Maquillage - Aspetti antropologiciIl Maquillage - Aspetti antropologici
Il Maquillage - Aspetti antropologici
 

Similar to PHPUnit

Supermondays: Jenkins CI lightning talk
Supermondays: Jenkins CI lightning talkSupermondays: Jenkins CI lightning talk
Supermondays: Jenkins CI lightning talkMichael Peacock
 
Node.js Development Workflow Automation with Grunt.js
Node.js Development Workflow Automation with Grunt.jsNode.js Development Workflow Automation with Grunt.js
Node.js Development Workflow Automation with Grunt.jskiyanwang
 
Bootify your spring application
Bootify your spring applicationBootify your spring application
Bootify your spring applicationJimmy Lu
 
Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Mark Niebergall
 
Continuous Integration at Mollie
Continuous Integration at MollieContinuous Integration at Mollie
Continuous Integration at Molliewillemstuursma
 
Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022Mark Niebergall
 
Quality code in wordpress
Quality code in wordpressQuality code in wordpress
Quality code in wordpressRan Bar-Zik
 
API Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj RollisonAPI Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj RollisonTEST Huddle
 
JavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A Cookbook
JavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A CookbookJavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A Cookbook
JavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A CookbookJorge Hidalgo
 
The what, why and how of web analytics testing
The what, why and how of web analytics testingThe what, why and how of web analytics testing
The what, why and how of web analytics testingAnand Bagmar
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsTaylor Lovett
 
Continuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CIContinuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CIwajrcs
 
Getting Started with Test-Driven Development at PHPtek 2023
Getting Started with Test-Driven Development at PHPtek 2023Getting Started with Test-Driven Development at PHPtek 2023
Getting Started with Test-Driven Development at PHPtek 2023Scott Keck-Warren
 
JUC Europe 2015: How to Optimize Automated Testing with Everyone's Favorite B...
JUC Europe 2015: How to Optimize Automated Testing with Everyone's Favorite B...JUC Europe 2015: How to Optimize Automated Testing with Everyone's Favorite B...
JUC Europe 2015: How to Optimize Automated Testing with Everyone's Favorite B...CloudBees
 
Automated Smoke Tests with Protractor
Automated Smoke Tests with ProtractorAutomated Smoke Tests with Protractor
Automated Smoke Tests with Protractor🌱 Dale Spoonemore
 
Treat your servers like your Ruby App: Infrastructure as Code
Treat your servers like your Ruby App: Infrastructure as CodeTreat your servers like your Ruby App: Infrastructure as Code
Treat your servers like your Ruby App: Infrastructure as CodeRakuten Group, Inc.
 
Developer testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing FanaticDeveloper testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing FanaticLB Denker
 

Similar to PHPUnit (20)

Continuous feature-development
Continuous feature-developmentContinuous feature-development
Continuous feature-development
 
Test
TestTest
Test
 
Supermondays: Jenkins CI lightning talk
Supermondays: Jenkins CI lightning talkSupermondays: Jenkins CI lightning talk
Supermondays: Jenkins CI lightning talk
 
Node.js Development Workflow Automation with Grunt.js
Node.js Development Workflow Automation with Grunt.jsNode.js Development Workflow Automation with Grunt.js
Node.js Development Workflow Automation with Grunt.js
 
Bootify your spring application
Bootify your spring applicationBootify your spring application
Bootify your spring application
 
Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023
 
Continuous Integration at Mollie
Continuous Integration at MollieContinuous Integration at Mollie
Continuous Integration at Mollie
 
Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022
 
Quality code in wordpress
Quality code in wordpressQuality code in wordpress
Quality code in wordpress
 
API Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj RollisonAPI Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj Rollison
 
JavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A Cookbook
JavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A CookbookJavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A Cookbook
JavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A Cookbook
 
The what, why and how of web analytics testing
The what, why and how of web analytics testingThe what, why and how of web analytics testing
The what, why and how of web analytics testing
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress Applications
 
Continuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CIContinuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CI
 
Getting Started with Test-Driven Development at PHPtek 2023
Getting Started with Test-Driven Development at PHPtek 2023Getting Started with Test-Driven Development at PHPtek 2023
Getting Started with Test-Driven Development at PHPtek 2023
 
JUC Europe 2015: How to Optimize Automated Testing with Everyone's Favorite B...
JUC Europe 2015: How to Optimize Automated Testing with Everyone's Favorite B...JUC Europe 2015: How to Optimize Automated Testing with Everyone's Favorite B...
JUC Europe 2015: How to Optimize Automated Testing with Everyone's Favorite B...
 
Automated Smoke Tests with Protractor
Automated Smoke Tests with ProtractorAutomated Smoke Tests with Protractor
Automated Smoke Tests with Protractor
 
Treat your servers like your Ruby App: Infrastructure as Code
Treat your servers like your Ruby App: Infrastructure as CodeTreat your servers like your Ruby App: Infrastructure as Code
Treat your servers like your Ruby App: Infrastructure as Code
 
Automate Thyself
Automate ThyselfAutomate Thyself
Automate Thyself
 
Developer testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing FanaticDeveloper testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing Fanatic
 

Recently uploaded

Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhimiss dipika
 
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Lucknow
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一Fs
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一Fs
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationLinaWolf1
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一z xss
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一Fs
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Sonam Pathan
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Paul Calvano
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITMgdsc13
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)Christopher H Felton
 
Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Excelmac1
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Dana Luther
 

Recently uploaded (20)

Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhi
 
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
 
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
 
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 Documentation
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24
 
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
 
Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
 

PHPUnit

Editor's Notes

  1. The difference between good programmer and bad programmer is that good programmer uses unit tests.
  2. Some of these constraints always conflict with each other. For example, "easy to learn write" conflicts with "easy to write" - later you'll see that this is true. Composable is ability to run tests in any combination.
  3. Name of the file with tests also should contains "Test".
  4. assertEquals also useful for array comparison
  5. You should have root privileges to execute these commands.
  6. Let's assume that we have to develop a model of week day which should have such methods. First of all we'll create a PHP file with following content. After that we may start to write tests.
  7. It is highly recommended to use same directory structure as the original code. Let's create a file with the following content. The above PHPDoc like expressions are PHPUnit specific constraints.
  8. You have to remember about including file with definitions of necessary classes in your tests (require_once). You may also register your own autoload method in a bootstrap file which name can be transferred through the special command-line option. After execution of previous empty tests we'll see that all was successful because of no any assertion was written yet.
  9. Now when we execute these tests we'll see info about two failed tests. It's not bad, we expected it because of we didn't implement our model yet. Let's do it!
  10. There is another way to write parameterized unit tests using @assert decorator
  11. There is another way to test expectation of exception: using @expectedException decorator. For test PHP errors you can use special type of exceptions: PHPUnit_Framework_Error.
  12. Units are separate functions and methods.
  13. Friendly reminder before practical task
  14. Who may tell about what is wrong in this example? There are at least three separate places that should to be tested: getting comments from DB by post_id, comments filtering and viewing result. So there must be three separate units. Also following the concepts of MVC pattern viewComments() should be placed in the Controller, not in the Model.