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

DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024APNIC
 
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With RoomVIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Roomgirls4nights
 
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)Damian Radcliffe
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Roomdivyansh0kumar0
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Roomdivyansh0kumar0
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...aditipandeya
 
Russian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
Russian Call Girls Thane Swara 8617697112 Independent Escort Service ThaneRussian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
Russian Call Girls Thane Swara 8617697112 Independent Escort Service ThaneCall girls in Ahmedabad High profile
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Delhi Call girls
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirtrahman018755
 
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service PuneVIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service PuneCall girls in Ahmedabad High profile
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
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
 
Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of indiaimessage0108
 

Recently uploaded (20)

DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With RoomVIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
 
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
Russian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
Russian Call Girls Thane Swara 8617697112 Independent Escort Service ThaneRussian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
Russian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
 
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service PuneVIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girls
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
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🔝
 
Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of india
 
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 

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.