This document provides an overview of PHPUnit, a unit testing framework for PHP. It introduces Sebastian Bergmann, the creator of PHPUnit, and describes some of PHPUnit's key features like test frameworks, integration with other tools, code coverage, and more. Examples are provided of writing unit tests with PHPUnit using the PHPUnit_Framework_TestCase class. Additional features like annotations, data providers, exceptions, groups, and behavior-driven development styles are also demonstrated.
This presentation would help learn how to install, integrate, write automated test script with PHPUnit.Would also involve looking into different example and execute them.
Test your code like a pro - PHPUnit in practiceSebastian Marek
The day you realised that you can’t really tell what your code does is the day you stop being an amateur programmer and you turn into a professional developer. During this workshop you will learn about the most famous unit testing framework – PHPUnit, how it can help you gain confidence in your code and what to do (and what to avoid) to make your code testable. We will discuss unit testing best practices and talk about tools that can help you automate the whole process, so it becomes more of a habit then a necessity.
This presentation would help learn how to install, integrate, write automated test script with PHPUnit.Would also involve looking into different example and execute them.
Test your code like a pro - PHPUnit in practiceSebastian Marek
The day you realised that you can’t really tell what your code does is the day you stop being an amateur programmer and you turn into a professional developer. During this workshop you will learn about the most famous unit testing framework – PHPUnit, how it can help you gain confidence in your code and what to do (and what to avoid) to make your code testable. We will discuss unit testing best practices and talk about tools that can help you automate the whole process, so it becomes more of a habit then a necessity.
Unit testing with PHPUnit - there's life outside of TDDPaweł Michalik
Basics of PHPUnit and why is it even more relevant in legacy code. Key points of the framework are explained, along with mocking objects, test organisation, creating documentations with tests and accessing non-public objects (where applicable).
Live version with additional notes available at: http://pawelmichalik.net/presentations/unit-testing-with-phpunit?showNotes=true
Prezentacja dostępna także w języku polskim: http://pawelmichalik.net/prezentacje/testy-jednostkowe-w-phpunit?showNotes=true
Unit testing, everyone talks about it and wants to do it but never gets around to actually start testing. Complex spaghetti code and time / budget pressures are often the reasons why nobody dives in and gets started with testing. But when the application breaks, and people loose money or worse it's often too late.
In this talk I will take you on a journey with real examples that will show you how you can set up your tests, how to test complex situations with legacy spaghetti code, test web services, database interactions and how to gradually build a solid foundation to safeguard the core code base and everything around it.
Don't you want to be confident when you walk out the office?
phpunit is testing framework for php testing.
A browser is able to give the syntax error but what if in case of some logical error.
Phpunit testing enables you to check your logic.
It is fully object oriented framework.
It also can be enabled in Netbeans.
you can find the option of phpunit testing in Netbeans
The presentation explains the PHP unit testing framework and provides a basic training on Testing with PHPunit. It Covers fundamental of unit testing, unit testing benefits and best practices. Starting ground up from PHP unit fundamentals, features of unit testing tries to explore advanced topics like Data providers, Fuxtures, Test doubles and more...
EPHPC Webinar
Unit Testing
Merangkak Menuju Pengembangan Aplikasi PHP yang Berkualitas dan Tahan Banting.
Date: Wednesday, April 6, 2011
Time: 1:00 pm, Bangkok Time (Bangkok, GMT+07:00)
Unlock The Mystery Of PHPUnit (Wave PHP 2018)ENDelt260
You know you're supposed to write unit tests, but you're not quite sure where to start. This session is for you. We will start from ground zero and go from zero unit test writing experience to functional test-driven developed code.
Using the current version of PHPUnit we will cover:
* writing basic test cases
* simple assertions and constraints
* mocking and data providers
* testing exceptions and errors
* and more!
You will leave this session fully ready to write tests for your own code.
Presentation showing that writing tests is not really hard with examples on testing a simple class, testing with dataproviders, fixtures, mocks, stubs, databases and how to use zend framework bootstrap for MVC testing.
Given at php|tek 09 unconf sessions.
Everyone talks about raising the bar on quality of code, but it's always hard to start implementing it when you have no clue where to start. With this talk I'm shooing that there are many levels developers can improve themselves by using the right tools. In this talk I'll go over each tool with examples how to use them against your codebase. A must attend talk for every developer that wants to scale up their quality. Most PHP developers deploy code that does what the customer requested but they don't have a clue about the quality of the product they deliver. Without this knowledge, maintenance can be a hell and very expensive. In this workshop I cover unit testing, code measuring, performance testing, debugging and profiling and give tips and tricks how to continue after this workshop.
Nothing is as frustrated as deploying a new release of your web application to find out functionality you had doesn't work anymore. Of course you have all your unit tests in place and you run them through your CI environment, but nothing prepared you to a failing javascript error or a link that doesn't work anymore. Welcome to User Acceptance testing or UAT. Before you start putting real people in front of your application, create macros and export them as PHPUnit test classes. Then run them in an automated way just like your unit tests and hook them into your CI. In this talk I will show you how easy it is to create Selenium macros that can be converted into PHPUnit scripts and run automatically on different virtual machines (VM's) so you can test all different browsers on a diversity of operating systems.
Thoughts and ideas on why and how to maintain a code repository with special attention to code style and documentation.
Includes some tips and recommendations about tools and standards you use or get inspiration from to keep your project in a good shape.
Unit testing with PHPUnit - there's life outside of TDDPaweł Michalik
Basics of PHPUnit and why is it even more relevant in legacy code. Key points of the framework are explained, along with mocking objects, test organisation, creating documentations with tests and accessing non-public objects (where applicable).
Live version with additional notes available at: http://pawelmichalik.net/presentations/unit-testing-with-phpunit?showNotes=true
Prezentacja dostępna także w języku polskim: http://pawelmichalik.net/prezentacje/testy-jednostkowe-w-phpunit?showNotes=true
Unit testing, everyone talks about it and wants to do it but never gets around to actually start testing. Complex spaghetti code and time / budget pressures are often the reasons why nobody dives in and gets started with testing. But when the application breaks, and people loose money or worse it's often too late.
In this talk I will take you on a journey with real examples that will show you how you can set up your tests, how to test complex situations with legacy spaghetti code, test web services, database interactions and how to gradually build a solid foundation to safeguard the core code base and everything around it.
Don't you want to be confident when you walk out the office?
phpunit is testing framework for php testing.
A browser is able to give the syntax error but what if in case of some logical error.
Phpunit testing enables you to check your logic.
It is fully object oriented framework.
It also can be enabled in Netbeans.
you can find the option of phpunit testing in Netbeans
The presentation explains the PHP unit testing framework and provides a basic training on Testing with PHPunit. It Covers fundamental of unit testing, unit testing benefits and best practices. Starting ground up from PHP unit fundamentals, features of unit testing tries to explore advanced topics like Data providers, Fuxtures, Test doubles and more...
EPHPC Webinar
Unit Testing
Merangkak Menuju Pengembangan Aplikasi PHP yang Berkualitas dan Tahan Banting.
Date: Wednesday, April 6, 2011
Time: 1:00 pm, Bangkok Time (Bangkok, GMT+07:00)
Unlock The Mystery Of PHPUnit (Wave PHP 2018)ENDelt260
You know you're supposed to write unit tests, but you're not quite sure where to start. This session is for you. We will start from ground zero and go from zero unit test writing experience to functional test-driven developed code.
Using the current version of PHPUnit we will cover:
* writing basic test cases
* simple assertions and constraints
* mocking and data providers
* testing exceptions and errors
* and more!
You will leave this session fully ready to write tests for your own code.
Presentation showing that writing tests is not really hard with examples on testing a simple class, testing with dataproviders, fixtures, mocks, stubs, databases and how to use zend framework bootstrap for MVC testing.
Given at php|tek 09 unconf sessions.
Everyone talks about raising the bar on quality of code, but it's always hard to start implementing it when you have no clue where to start. With this talk I'm shooing that there are many levels developers can improve themselves by using the right tools. In this talk I'll go over each tool with examples how to use them against your codebase. A must attend talk for every developer that wants to scale up their quality. Most PHP developers deploy code that does what the customer requested but they don't have a clue about the quality of the product they deliver. Without this knowledge, maintenance can be a hell and very expensive. In this workshop I cover unit testing, code measuring, performance testing, debugging and profiling and give tips and tricks how to continue after this workshop.
Nothing is as frustrated as deploying a new release of your web application to find out functionality you had doesn't work anymore. Of course you have all your unit tests in place and you run them through your CI environment, but nothing prepared you to a failing javascript error or a link that doesn't work anymore. Welcome to User Acceptance testing or UAT. Before you start putting real people in front of your application, create macros and export them as PHPUnit test classes. Then run them in an automated way just like your unit tests and hook them into your CI. In this talk I will show you how easy it is to create Selenium macros that can be converted into PHPUnit scripts and run automatically on different virtual machines (VM's) so you can test all different browsers on a diversity of operating systems.
Thoughts and ideas on why and how to maintain a code repository with special attention to code style and documentation.
Includes some tips and recommendations about tools and standards you use or get inspiration from to keep your project in a good shape.
This workshop is a hands-on training where a real Zend Framework application is used as an example to start improving QA using tools to test, document and perform software metric calculations to indicate where the software can be improved. I also explain the reports produced by a CI system.
Starting unit testing on a project can seem like a daunting task, and earning team and leadership buy-in can be challenging. We'll walk-through setup with composer, creating the first test, restructuring existing classes with dependency injection to allow unit testing, and releasing code confidently with test coverage. We'll also discuss overcoming common biases, unit testing challenges, and shortcomings of unit testing.
Watch the presentation at https://www.youtube.com/watch?v=6v4_bEajDUk
A lot of people using PHPunit for testing their source code. While I was observing my team I recognized most of them are only using the standard assertions like 'assertEquals()' and are complaining about how hard it is to test the code even when the tests are written first. This talk is about all the stuff not used on a daily basis and it digs deep into uncommon features of PHPUnit.
● What is Unit Testing?
● Benefits
● What is PHPUnit?
● Installation
● The Bank Account Example
● Categories of (Unit) Tests / Software Testing
Pyramid
● Links
Leveling Up With Unit Testing - php[tek] 2023Mark Niebergall
Writing unit testing on a project can seem like a daunting task, and earning team and leadership buy-in can be challenging. Level up your skillset as we cover PHPUnit and Prophecy setup with composer, writing meaningful tests, restructuring existing classes with dependency injection to allow for unit testing, using mock objects, and releasing code confidently with test coverage. We will also discuss overcoming common biases, unit testing challenges, and shortcomings of unit testing.
In 2010, I told everyone how to start unit testing Zend Framework applications. In 2011, let’s take this a step further by testing services, work flows and performance. Looking to raise the bar on quality? Let this talk be the push you need to improve your Zend Framework projects.
Similar to New Features PHPUnit 3.3 - Sebastian Bergmann (20)
Premium MEAN Stack Development Solutions for Modern BusinessesSynapseIndia
Stay ahead of the curve with our premium MEAN Stack Development Solutions. Our expert developers utilize MongoDB, Express.js, AngularJS, and Node.js to create modern and responsive web applications. Trust us for cutting-edge solutions that drive your business growth and success.
Know more: https://www.synapseindia.com/technology/mean-stack-development-company.html
Understanding User Needs and Satisfying ThemAggregage
https://www.productmanagementtoday.com/frs/26903918/understanding-user-needs-and-satisfying-them
We know we want to create products which our customers find to be valuable. Whether we label it as customer-centric or product-led depends on how long we've been doing product management. There are three challenges we face when doing this. The obvious challenge is figuring out what our users need; the non-obvious challenges are in creating a shared understanding of those needs and in sensing if what we're doing is meeting those needs.
In this webinar, we won't focus on the research methods for discovering user-needs. We will focus on synthesis of the needs we discover, communication and alignment tools, and how we operationalize addressing those needs.
Industry expert Scott Sehlhorst will:
• Introduce a taxonomy for user goals with real world examples
• Present the Onion Diagram, a tool for contextualizing task-level goals
• Illustrate how customer journey maps capture activity-level and task-level goals
• Demonstrate the best approach to selection and prioritization of user-goals to address
• Highlight the crucial benchmarks, observable changes, in ensuring fulfillment of customer needs
Recruiting in the Digital Age: A Social Media MasterclassLuanWise
In this masterclass, presented at the Global HR Summit on 5th June 2024, Luan Wise explored the essential features of social media platforms that support talent acquisition, including LinkedIn, Facebook, Instagram, X (formerly Twitter) and TikTok.
Company Valuation webinar series - Tuesday, 4 June 2024FelixPerez547899
This session provided an update as to the latest valuation data in the UK and then delved into a discussion on the upcoming election and the impacts on valuation. We finished, as always with a Q&A
Putting the SPARK into Virtual Training.pptxCynthia Clay
This 60-minute webinar, sponsored by Adobe, was delivered for the Training Mag Network. It explored the five elements of SPARK: Storytelling, Purpose, Action, Relationships, and Kudos. Knowing how to tell a well-structured story is key to building long-term memory. Stating a clear purpose that doesn't take away from the discovery learning process is critical. Ensuring that people move from theory to practical application is imperative. Creating strong social learning is the key to commitment and engagement. Validating and affirming participants' comments is the way to create a positive learning environment.
B2B payments are rapidly changing. Find out the 5 key questions you need to be asking yourself to be sure you are mastering B2B payments today. Learn more at www.BlueSnap.com.
LA HUG - Video Testimonials with Chynna Morgan - June 2024Lital Barkan
Have you ever heard that user-generated content or video testimonials can take your brand to the next level? We will explore how you can effectively use video testimonials to leverage and boost your sales, content strategy, and increase your CRM data.🤯
We will dig deeper into:
1. How to capture video testimonials that convert from your audience 🎥
2. How to leverage your testimonials to boost your sales 💲
3. How you can capture more CRM data to understand your audience better through video testimonials. 📊
Buy Verified PayPal Account | Buy Google 5 Star Reviewsusawebmarket
Buy Verified PayPal Account
Looking to buy verified PayPal accounts? Discover 7 expert tips for safely purchasing a verified PayPal account in 2024. Ensure security and reliability for your transactions.
PayPal Services Features-
🟢 Email Access
🟢 Bank Added
🟢 Card Verified
🟢 Full SSN Provided
🟢 Phone Number Access
🟢 Driving License Copy
🟢 Fasted Delivery
Client Satisfaction is Our First priority. Our services is very appropriate to buy. We assume that the first-rate way to purchase our offerings is to order on the website. If you have any worry in our cooperation usually You can order us on Skype or Telegram.
24/7 Hours Reply/Please Contact
usawebmarketEmail: support@usawebmarket.com
Skype: usawebmarket
Telegram: @usawebmarket
WhatsApp: +1(218) 203-5951
USA WEB MARKET is the Best Verified PayPal, Payoneer, Cash App, Skrill, Neteller, Stripe Account and SEO, SMM Service provider.100%Satisfection granted.100% replacement Granted.
Digital Transformation and IT Strategy Toolkit and TemplatesAurelien Domont, MBA
This Digital Transformation and IT Strategy Toolkit was created by ex-McKinsey, Deloitte and BCG Management Consultants, after more than 5,000 hours of work. It is considered the world's best & most comprehensive Digital Transformation and IT Strategy Toolkit. It includes all the Frameworks, Best Practices & Templates required to successfully undertake the Digital Transformation of your organization and define a robust IT Strategy.
Editable Toolkit to help you reuse our content: 700 Powerpoint slides | 35 Excel sheets | 84 minutes of Video training
This PowerPoint presentation is only a small preview of our Toolkits. For more details, visit www.domontconsulting.com
An introduction to the cryptocurrency investment platform Binance Savings.Any kyc Account
Learn how to use Binance Savings to expand your bitcoin holdings. Discover how to maximize your earnings on one of the most reliable cryptocurrency exchange platforms, as well as how to earn interest on your cryptocurrency holdings and the various savings choices available.
Authentically Social by Corey Perlman - EO Puerto Rico
New Features PHPUnit 3.3 - Sebastian Bergmann
1. Welcome!
New Features in PHPUnit 3.3
Sebastian Bergmann
http://sebastian-bergmann.de/
June 14th 2008
2. Who I am
● Sebastian Bergmann
● Involved in the
PHP Project since 2000
● Developer of PHPUnit
● Author, Consultant,
Coach, Trainer
3. PHPUnit
● Test Framework
– Member of the xUnit family of test frameworks
– Mock Objects
– DbUnit
● Integration
– Selenium RC
– phpUnderControl, CruiseControl, ...
● Even More Cool Stuff :-)
– Code Coverage, Software Metrics, and “Mess Detection”
– Test Database
– Mutation Testing (GSoC07 project)
4. Unit Tests with PHPUnit
<?php
require_once 'PHPUnit/Framework/TestCase.php';
class BowlingGameTest extends PHPUnit_Framework_TestCase
{
}
5. Unit Tests with PHPUnit
<?php
require_once 'PHPUnit/Framework/TestCase.php';
class BowlingGameTest extends PHPUnit_Framework_TestCase
{
public function testScoreForOneSpareAnd3Is16()
{
}
}
6. Unit Tests with PHPUnit
<?php
require_once 'PHPUnit/Framework/TestCase.php';
require_once 'BowlingGame.php';
class BowlingGameTest extends PHPUnit_Framework_TestCase
{
public function testScoreForOneSpareAnd3Is16()
{
$game = new BowlingGame;
}
}
7. Unit Tests with PHPUnit
<?php
require_once 'PHPUnit/Framework/TestCase.php';
require_once 'BowlingGame.php';
class BowlingGameTest extends PHPUnit_Framework_TestCase
{
public function testScoreForOneSpareAnd3Is16()
{
$game = new BowlingGame;
$game->roll(5);
$game->roll(5);
$game->roll(3);
for ($i = 4; $i <= 20; $i++) {
$game->roll(0);
}
}
}
8. Unit Tests with PHPUnit
<?php
require_once 'PHPUnit/Framework/TestCase.php';
require_once 'BowlingGame.php';
class BowlingGameTest extends PHPUnit_Framework_TestCase
{
public function testScoreForOneSpareAnd3Is16()
{
$game = new BowlingGame;
$game->roll(5);
$game->roll(5);
$game->roll(3);
for ($i = 4; $i <= 20; $i++) {
$game->roll(0);
}
$this->assertEquals(16, $this->game->score());
}
}
9. Unit Tests with PHPUnit
sb@vmware ~ % phpunit BowlingGameTest
PHPUnit 3.3.0 by Sebastian Bergmann.
.
Time: 0 seconds
OK (1 test, 1 annotation)
10. Annotations
@assert
<?php
class Calculator
{
/**
* @assert (1, 2) == 3
*/
public function add($a, $b)
{
return $a + $b;
}
/**
* @assert (2, 1) == 1
*/
public function sub($a, $b)
{
return $a - $b;
}
}
11. Annotations
@assert
sb@vmware ~ % phpunit Calculator
PHPUnit 3.3.0 by Sebastian Bergmann.
..
Time: 0 seconds
OK (2 tests, 2 annotations)
19. Annotations
@test
sb@vmware ~ % phpunit --testdox Specification
PHPUnit 3.3.0 by Sebastian Bergmann.
Specification
[x] Should do something
[x] Should do something else
20. Behaviour-Driven Development
● Extreme Programming originally had the rule to
test everything that could possibly break
● Now, however, the practice of testing in
Extreme Programming has evolved into
Test-Driven Development
● But the tools still force developers to think in terms
of tests and assertions instead of specifications
A New Look At Test-Driven Development,
Dave Astels.
http://blog.daveastels.com/files/BDD_Intro.pdf
28. Behaviour-Driven Development
<?php
require_once 'PHPUnit/Extensions/Story/TestCase.php';
require_once 'BowlingGame.php';
class BowlingGameSpec extends PHPUnit_Extensions_Story_TestCase
{
// ...
public function runGiven(&$world, $action, $arguments)
{
switch($action) {
case 'New game': {
$world['game'] = new BowlingGame;
$world['rolls'] = 0;
}
break;
default: {
return $this->notImplemented($action);
}
}
}
}
29. Behaviour-Driven Development
<?php
require_once 'PHPUnit/Extensions/Story/TestCase.php';
require_once 'BowlingGame.php';
class BowlingGameSpec extends PHPUnit_Extensions_Story_TestCase
{
// ...
public function runWhen(&$world, $action, $arguments)
{
switch($action) {
case 'Player rolls': {
$world['game']->roll($arguments[0]);
$world['rolls']++;
}
break;
default: {
return $this->notImplemented($action);
}
}
}
}
30. Behaviour-Driven Development
<?php
require_once 'PHPUnit/Extensions/Story/TestCase.php';
require_once 'BowlingGame.php';
class BowlingGameSpec extends PHPUnit_Extensions_Story_TestCase
{
// ...
public function runThen(&$world, $action, $arguments)
{
switch($action) {
case 'Score should be': {
for ($i = $world['rolls']; $i < 20; $i++) {
$world['game']->roll(0);
}
$this->assertEquals($arguments[0], $world['game']->score());
}
break;
default: {
return $this->notImplemented($action);
}
}
}
}
31. Behaviour-Driven Development
sb@vmware ~ % phpunit --story BowlingGameSpec
PHPUnit 3.3.0 by Sebastian Bergmann.
BowlingGameSpec
- Score for one spare and 3 is 16 [successful]
Given New game
When Player rolls 5
and Player rolls 5
and Player rolls 3
Then Score should be 16
Scenarios: 1, Failed: 0, Skipped: 0, Incomplete: 0.
sb@vmware ~ % phpunit --testdox BowlingGameSpec
PHPUnit 3.3.0 by Sebastian Bergmann.
BowlingGameSpec
[x] Score for one spare and 3 is 16
32. Generating Code from Tests
<?php
class BowlingGameTest extends PHPUnit_Framework_TestCase {
protected $game;
protected function setUp() {
$this->game = new BowlingGame;
}
protected function rollMany($n, $pins) {
for ($i = 0; $i < $n; $i++) {
$this->game->roll($pins);
}
}
public function testScoreForGutterGameIs0() {
$this->rollMany(20, 0);
$this->assertEquals(0, $this->game->score());
}
}
33. Generating Code from Tests
sb@vmware ~ % phpunit --skeleton-class BowlingGameTest
PHPUnit 3.3.0 by Sebastian Bergmann.
Wrote skeleton for quot;BowlingGamequot; to quot;BowlingGame.phpquot;.
<?php
class BowlingGame
{
/**
* @todo Implement roll().
*/
public function roll()
{
// Remove the following line when you implement this method.
throw new RuntimeException('Not yet implemented.');
}
/**
* @todo Implement score().
*/
public function score()
{
// Remove the following line when you implement this method.
throw new RuntimeException('Not yet implemented.');
}
}
?>
34. Generating Code from Tests
<?php
class BowlingGameTest extends PHPUnit_Framework_TestCase {
protected $game;
protected function setUp() {
$this->game = new BowlingGame;
}
protected function rollMany($n, $pins) {
for ($i = 0; $i < $n; $i++) {
$this->game->roll($pins);
}
}
public function testScoreForGutterGameIs0() {
$this->rollMany(20, 0);
$this->assertEquals(0, $this->game->score());
}
}
35. Generating Code from Tests
<?php
class BowlingGameTest extends PHPUnit_Framework_TestCase {
protected $game;
protected function setUp() {
$this->game = new BowlingGame;
}
protected function rollMany($n, $pins) {
for ($i = 0; $i < $n; $i++) {
$this->game->roll($pins);
}
}
public function testScoreForGutterGameIs0() {
$this->rollMany(20, 0);
$this->assertEquals(0, $this->game->score());
}
}
36. Generating Code from Tests
<?php
class BowlingGameTest extends PHPUnit_Framework_TestCase {
protected $game;
protected function setUp() {
$this->game = new BowlingGame;
}
protected function rollMany($n, $pins) {
for ($i = 0; $i < $n; $i++) {
$this->game->roll($pins);
}
}
public function testScoreForGutterGameIs0() {
$this->rollMany(20, 0);
$this->assertEquals(0, $this->game->score());
}
}
37. Generating Code from Tests
<?php
class BowlingGameTest extends PHPUnit_Framework_TestCase {
protected $game;
protected function setUp() {
$this->game = new BowlingGame;
}
protected function rollMany($n, $pins) {
for ($i = 0; $i < $n; $i++) {
$this->game->roll($pins);
}
}
public function testScoreForGutterGameIs0() {
$this->rollMany(20, 0);
$this->assertEquals(0, $this->game->score());
}
}
38. Generating Code from Tests
<?php
class BowlingGameTest extends PHPUnit_Framework_TestCase {
protected $game;
protected function setUp() {
$this->game = new BowlingGame;
}
protected function rollMany($n, $pins) {
for ($i = 0; $i < $n; $i++) {
$this->game->roll($pins);
}
}
public function testScoreForGutterGameIs0() {
$this->rollMany(20, 0);
$this->assertEquals(0, $this->game->score());
}
}
40. Mock Objects
returnCallback()
<?php
class StubTest extends PHPUnit_Framework_TestCase
{
public function testReturnCallbackStub()
{
$stub = $this->getMock(
'SomeClass', array('doSomething')
);
$stub->expects($this->any())
->method('doSomething')
->will($this->returnCallback('callback'));
// $stub->doSomething() returns callback(...)
}
}
function callback() {
$args = func_get_args();
// ...
}
41. TextUI Testrunner
Counting of assertions
sb@vmware ~ % phpunit BowlingGameTest
PHPUnit 3.3.0 by Sebastian Bergmann.
.
Time: 0 seconds
OK (1 test, 1 assertions)
42. TextUI Testrunner
Colours!
sb@vmware ~ % phpunit --ansi BowlingGameTest
PHPUnit 3.3.0 by Sebastian Bergmann.
.
Time: 0 seconds
1
OK (1 test, 0 assertions)
43. TextUI Testrunner
Counting of assertions
sb@vmware ~ % phpunit BowlingGameTest
PHPUnit 3.3.0 by Sebastian Bergmann.
.F
Time: 0 seconds
There was 1 failure:
1) testAllOnes(BowlingGameTest)
Failed asserting that <integer:0> matches expected value <integer:20>.
/home/sb/BowlingGameTest.php:25
FAILURES!
Tests: 2, Assertions: 2, Failures: 1.
44. TextUI Testrunner
Colours!
sb@vmware ~ % phpunit --ansi BowlingGameTest
PHPUnit 3.3.0 by Sebastian Bergmann.
.F
Time: 0 seconds
There was 1 failure:
1) testAllOnes(BowlingGameTest)
Failed asserting that <integer:0> matches expected value <integer:20>.
/home/sb/BowlingGameTest.php:25
FAILURES!
Tests: 1, Failures: 1.2, Failures: 1.
2, Assertions:
45. PHPUnit 3.3
Other new features
● New assertions
– assertXmlFileTag(), assertXmlFileNotTag()
– assertXmlStringTag(), assertXmlStringNotTag()
– assertXmlFileSelect(), assertXmlStringSelect()
– assertEqualXMLStructure()
● Changes to existing assertions
– EOL canonicalization for
● assertEquals(), assertNotEquals(),
● assertFileEquals(), assertFileNotEquals()
● PHPUnit_Util_ErrorHandler::getErrorStack()
46. PHPUnit 3.3
Other new features
● Mock Objects are faster
● SeleniumTestCase supports verify*()
● Feature and Memory Performance
improvements for the code coverage
reporting
47. PHPUnit 3.3
Backwards Compatibility Breaking Changes
● Removed PHPUnit_Extensions_ExceptionTestCase
– Functionality had been merged into
PHPUnit_Framework_TestCase in PHPUnit 3.2
– Marked as deprecated in PHPUnit 3.2
● Removed PHPUnit_Extensions_TestSetup
– Functionality had been merged into
PHPUnit_Framework_TestSuite in PHPUnit 3.2
– Marked as deprecated in PHPUnit 3.2
48. The End
● Thank you for your interest!
● These slides will be available shortly on
http://sebastian-bergmann.de/talks/.
49. License
This presentation material is published under the Attribution-Share Alike 3.0 Unported
license.
You are free:
✔ to Share – to copy, distribute and transmit the work.
✔ to Remix – to adapt the work.
Under the following conditions:
● Attribution. You must attribute the work in the manner specified by the author or
licensor (but not in any way that suggests that they endorse you or your use of the
work).
● Share Alike. If you alter, transform, or build upon this work, you may distribute the
resulting work only under the same, similar or a compatible license.
For any reuse or distribution, you must make clear to others the license terms of this
work.
Any of the above conditions can be waived if you get permission from the copyright
holder.
Nothing in this license impairs or restricts the author's moral rights.