the state of phpunit

Post on 08-May-2015

2.060 Views

Category:

Education

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

THE STATE OF PHPUNIT

Volker Dusch _ _edorian

ABOUT MEPHP since 10 yearsCICleanCodeDevOpsTDDShipping

INSTEAD OF ME

WORKING FOR

ResearchGate gives science back to the people who make it happen

We help researchers build reputation and accelerate scientificprogress

On their terms

GET IN TOUCHstackoverflow

Twitter __edorianXing G+ Volker DuschIRC edorianMail phpwallbashcom

LETS GO

Unit testing in PHP got mainstream

THATS A GOOD THINGUnit testing got normal in PHP

Even people that dont really know PHP or even the CLI know that theyshould write unit tests

AGENDACurrent StateThe EcoSystemPHPUnit 37Annoying things we got rid ofFeatures you might have missedShiny new thingsTest suite organizationDiscussion

CURRENT STATEVersions 3612 and hot from the presses githubs 375Over 70 contributors since 360One last 36 release to help with dependencies37 is early in the bugfix cycle no new features will be added Thosego into nextFrench docs thanks to poum and still current Japanese docs thanksto m-takagiIf you want to help outhttpsgithubcomsebastianbergmannphpunitcontributing

THE ECOSYSTEMhttpphpqatoolsorg amp friends

BDDUse Behat Its great

Were not going to remove the BDD stuff in PHPUnit but Its not beingworked on

WEB INTERFACENot sure why youd want that but someone solved that for you

httpsgithubcomNSinopoliVisualPHPUnit

MOCKING IS UGLYReal world problems and solutions

httpstackoverflowcomsearchtab=votesampq=[phpunit] mock

MOCKERYTry it Its great

Afraid it might be hard to set up and use

Look into httpsgithubcometsyphpunit-extensionswikiMockery

Works with strict mode leaves the old API intact and is as easy aswriting a comment

class MyTest extends PHPUnit_Extensions_Mockery_TestCase

mockery Foo protected $foo

LOTS OF LEGACY CODEOr whatever hard to test is called these days

httpsgithubcomlapistanoproxy-object

One of the main purpose of this library is to expose invisible (private orprotected) methods and properties to the SUT

TESTING WEB SERVICESUnit and Integration test web services with the same code

Try wsUnit httpsgithubcomlapistanowsunit

IDE SUPPORTNetbeans support improved and they adopted the skeleton-generatorHonestly I have no clue about eclipsePHPStorm has really beautiful coverage support by nowvim user phpunit --coverage-text

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

ABOUT MEPHP since 10 yearsCICleanCodeDevOpsTDDShipping

INSTEAD OF ME

WORKING FOR

ResearchGate gives science back to the people who make it happen

We help researchers build reputation and accelerate scientificprogress

On their terms

GET IN TOUCHstackoverflow

Twitter __edorianXing G+ Volker DuschIRC edorianMail phpwallbashcom

LETS GO

Unit testing in PHP got mainstream

THATS A GOOD THINGUnit testing got normal in PHP

Even people that dont really know PHP or even the CLI know that theyshould write unit tests

AGENDACurrent StateThe EcoSystemPHPUnit 37Annoying things we got rid ofFeatures you might have missedShiny new thingsTest suite organizationDiscussion

CURRENT STATEVersions 3612 and hot from the presses githubs 375Over 70 contributors since 360One last 36 release to help with dependencies37 is early in the bugfix cycle no new features will be added Thosego into nextFrench docs thanks to poum and still current Japanese docs thanksto m-takagiIf you want to help outhttpsgithubcomsebastianbergmannphpunitcontributing

THE ECOSYSTEMhttpphpqatoolsorg amp friends

BDDUse Behat Its great

Were not going to remove the BDD stuff in PHPUnit but Its not beingworked on

WEB INTERFACENot sure why youd want that but someone solved that for you

httpsgithubcomNSinopoliVisualPHPUnit

MOCKING IS UGLYReal world problems and solutions

httpstackoverflowcomsearchtab=votesampq=[phpunit] mock

MOCKERYTry it Its great

Afraid it might be hard to set up and use

Look into httpsgithubcometsyphpunit-extensionswikiMockery

Works with strict mode leaves the old API intact and is as easy aswriting a comment

class MyTest extends PHPUnit_Extensions_Mockery_TestCase

mockery Foo protected $foo

LOTS OF LEGACY CODEOr whatever hard to test is called these days

httpsgithubcomlapistanoproxy-object

One of the main purpose of this library is to expose invisible (private orprotected) methods and properties to the SUT

TESTING WEB SERVICESUnit and Integration test web services with the same code

Try wsUnit httpsgithubcomlapistanowsunit

IDE SUPPORTNetbeans support improved and they adopted the skeleton-generatorHonestly I have no clue about eclipsePHPStorm has really beautiful coverage support by nowvim user phpunit --coverage-text

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

INSTEAD OF ME

WORKING FOR

ResearchGate gives science back to the people who make it happen

We help researchers build reputation and accelerate scientificprogress

On their terms

GET IN TOUCHstackoverflow

Twitter __edorianXing G+ Volker DuschIRC edorianMail phpwallbashcom

LETS GO

Unit testing in PHP got mainstream

THATS A GOOD THINGUnit testing got normal in PHP

Even people that dont really know PHP or even the CLI know that theyshould write unit tests

AGENDACurrent StateThe EcoSystemPHPUnit 37Annoying things we got rid ofFeatures you might have missedShiny new thingsTest suite organizationDiscussion

CURRENT STATEVersions 3612 and hot from the presses githubs 375Over 70 contributors since 360One last 36 release to help with dependencies37 is early in the bugfix cycle no new features will be added Thosego into nextFrench docs thanks to poum and still current Japanese docs thanksto m-takagiIf you want to help outhttpsgithubcomsebastianbergmannphpunitcontributing

THE ECOSYSTEMhttpphpqatoolsorg amp friends

BDDUse Behat Its great

Were not going to remove the BDD stuff in PHPUnit but Its not beingworked on

WEB INTERFACENot sure why youd want that but someone solved that for you

httpsgithubcomNSinopoliVisualPHPUnit

MOCKING IS UGLYReal world problems and solutions

httpstackoverflowcomsearchtab=votesampq=[phpunit] mock

MOCKERYTry it Its great

Afraid it might be hard to set up and use

Look into httpsgithubcometsyphpunit-extensionswikiMockery

Works with strict mode leaves the old API intact and is as easy aswriting a comment

class MyTest extends PHPUnit_Extensions_Mockery_TestCase

mockery Foo protected $foo

LOTS OF LEGACY CODEOr whatever hard to test is called these days

httpsgithubcomlapistanoproxy-object

One of the main purpose of this library is to expose invisible (private orprotected) methods and properties to the SUT

TESTING WEB SERVICESUnit and Integration test web services with the same code

Try wsUnit httpsgithubcomlapistanowsunit

IDE SUPPORTNetbeans support improved and they adopted the skeleton-generatorHonestly I have no clue about eclipsePHPStorm has really beautiful coverage support by nowvim user phpunit --coverage-text

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

WORKING FOR

ResearchGate gives science back to the people who make it happen

We help researchers build reputation and accelerate scientificprogress

On their terms

GET IN TOUCHstackoverflow

Twitter __edorianXing G+ Volker DuschIRC edorianMail phpwallbashcom

LETS GO

Unit testing in PHP got mainstream

THATS A GOOD THINGUnit testing got normal in PHP

Even people that dont really know PHP or even the CLI know that theyshould write unit tests

AGENDACurrent StateThe EcoSystemPHPUnit 37Annoying things we got rid ofFeatures you might have missedShiny new thingsTest suite organizationDiscussion

CURRENT STATEVersions 3612 and hot from the presses githubs 375Over 70 contributors since 360One last 36 release to help with dependencies37 is early in the bugfix cycle no new features will be added Thosego into nextFrench docs thanks to poum and still current Japanese docs thanksto m-takagiIf you want to help outhttpsgithubcomsebastianbergmannphpunitcontributing

THE ECOSYSTEMhttpphpqatoolsorg amp friends

BDDUse Behat Its great

Were not going to remove the BDD stuff in PHPUnit but Its not beingworked on

WEB INTERFACENot sure why youd want that but someone solved that for you

httpsgithubcomNSinopoliVisualPHPUnit

MOCKING IS UGLYReal world problems and solutions

httpstackoverflowcomsearchtab=votesampq=[phpunit] mock

MOCKERYTry it Its great

Afraid it might be hard to set up and use

Look into httpsgithubcometsyphpunit-extensionswikiMockery

Works with strict mode leaves the old API intact and is as easy aswriting a comment

class MyTest extends PHPUnit_Extensions_Mockery_TestCase

mockery Foo protected $foo

LOTS OF LEGACY CODEOr whatever hard to test is called these days

httpsgithubcomlapistanoproxy-object

One of the main purpose of this library is to expose invisible (private orprotected) methods and properties to the SUT

TESTING WEB SERVICESUnit and Integration test web services with the same code

Try wsUnit httpsgithubcomlapistanowsunit

IDE SUPPORTNetbeans support improved and they adopted the skeleton-generatorHonestly I have no clue about eclipsePHPStorm has really beautiful coverage support by nowvim user phpunit --coverage-text

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

GET IN TOUCHstackoverflow

Twitter __edorianXing G+ Volker DuschIRC edorianMail phpwallbashcom

LETS GO

Unit testing in PHP got mainstream

THATS A GOOD THINGUnit testing got normal in PHP

Even people that dont really know PHP or even the CLI know that theyshould write unit tests

AGENDACurrent StateThe EcoSystemPHPUnit 37Annoying things we got rid ofFeatures you might have missedShiny new thingsTest suite organizationDiscussion

CURRENT STATEVersions 3612 and hot from the presses githubs 375Over 70 contributors since 360One last 36 release to help with dependencies37 is early in the bugfix cycle no new features will be added Thosego into nextFrench docs thanks to poum and still current Japanese docs thanksto m-takagiIf you want to help outhttpsgithubcomsebastianbergmannphpunitcontributing

THE ECOSYSTEMhttpphpqatoolsorg amp friends

BDDUse Behat Its great

Were not going to remove the BDD stuff in PHPUnit but Its not beingworked on

WEB INTERFACENot sure why youd want that but someone solved that for you

httpsgithubcomNSinopoliVisualPHPUnit

MOCKING IS UGLYReal world problems and solutions

httpstackoverflowcomsearchtab=votesampq=[phpunit] mock

MOCKERYTry it Its great

Afraid it might be hard to set up and use

Look into httpsgithubcometsyphpunit-extensionswikiMockery

Works with strict mode leaves the old API intact and is as easy aswriting a comment

class MyTest extends PHPUnit_Extensions_Mockery_TestCase

mockery Foo protected $foo

LOTS OF LEGACY CODEOr whatever hard to test is called these days

httpsgithubcomlapistanoproxy-object

One of the main purpose of this library is to expose invisible (private orprotected) methods and properties to the SUT

TESTING WEB SERVICESUnit and Integration test web services with the same code

Try wsUnit httpsgithubcomlapistanowsunit

IDE SUPPORTNetbeans support improved and they adopted the skeleton-generatorHonestly I have no clue about eclipsePHPStorm has really beautiful coverage support by nowvim user phpunit --coverage-text

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

LETS GO

Unit testing in PHP got mainstream

THATS A GOOD THINGUnit testing got normal in PHP

Even people that dont really know PHP or even the CLI know that theyshould write unit tests

AGENDACurrent StateThe EcoSystemPHPUnit 37Annoying things we got rid ofFeatures you might have missedShiny new thingsTest suite organizationDiscussion

CURRENT STATEVersions 3612 and hot from the presses githubs 375Over 70 contributors since 360One last 36 release to help with dependencies37 is early in the bugfix cycle no new features will be added Thosego into nextFrench docs thanks to poum and still current Japanese docs thanksto m-takagiIf you want to help outhttpsgithubcomsebastianbergmannphpunitcontributing

THE ECOSYSTEMhttpphpqatoolsorg amp friends

BDDUse Behat Its great

Were not going to remove the BDD stuff in PHPUnit but Its not beingworked on

WEB INTERFACENot sure why youd want that but someone solved that for you

httpsgithubcomNSinopoliVisualPHPUnit

MOCKING IS UGLYReal world problems and solutions

httpstackoverflowcomsearchtab=votesampq=[phpunit] mock

MOCKERYTry it Its great

Afraid it might be hard to set up and use

Look into httpsgithubcometsyphpunit-extensionswikiMockery

Works with strict mode leaves the old API intact and is as easy aswriting a comment

class MyTest extends PHPUnit_Extensions_Mockery_TestCase

mockery Foo protected $foo

LOTS OF LEGACY CODEOr whatever hard to test is called these days

httpsgithubcomlapistanoproxy-object

One of the main purpose of this library is to expose invisible (private orprotected) methods and properties to the SUT

TESTING WEB SERVICESUnit and Integration test web services with the same code

Try wsUnit httpsgithubcomlapistanowsunit

IDE SUPPORTNetbeans support improved and they adopted the skeleton-generatorHonestly I have no clue about eclipsePHPStorm has really beautiful coverage support by nowvim user phpunit --coverage-text

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

Unit testing in PHP got mainstream

THATS A GOOD THINGUnit testing got normal in PHP

Even people that dont really know PHP or even the CLI know that theyshould write unit tests

AGENDACurrent StateThe EcoSystemPHPUnit 37Annoying things we got rid ofFeatures you might have missedShiny new thingsTest suite organizationDiscussion

CURRENT STATEVersions 3612 and hot from the presses githubs 375Over 70 contributors since 360One last 36 release to help with dependencies37 is early in the bugfix cycle no new features will be added Thosego into nextFrench docs thanks to poum and still current Japanese docs thanksto m-takagiIf you want to help outhttpsgithubcomsebastianbergmannphpunitcontributing

THE ECOSYSTEMhttpphpqatoolsorg amp friends

BDDUse Behat Its great

Were not going to remove the BDD stuff in PHPUnit but Its not beingworked on

WEB INTERFACENot sure why youd want that but someone solved that for you

httpsgithubcomNSinopoliVisualPHPUnit

MOCKING IS UGLYReal world problems and solutions

httpstackoverflowcomsearchtab=votesampq=[phpunit] mock

MOCKERYTry it Its great

Afraid it might be hard to set up and use

Look into httpsgithubcometsyphpunit-extensionswikiMockery

Works with strict mode leaves the old API intact and is as easy aswriting a comment

class MyTest extends PHPUnit_Extensions_Mockery_TestCase

mockery Foo protected $foo

LOTS OF LEGACY CODEOr whatever hard to test is called these days

httpsgithubcomlapistanoproxy-object

One of the main purpose of this library is to expose invisible (private orprotected) methods and properties to the SUT

TESTING WEB SERVICESUnit and Integration test web services with the same code

Try wsUnit httpsgithubcomlapistanowsunit

IDE SUPPORTNetbeans support improved and they adopted the skeleton-generatorHonestly I have no clue about eclipsePHPStorm has really beautiful coverage support by nowvim user phpunit --coverage-text

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

THATS A GOOD THINGUnit testing got normal in PHP

Even people that dont really know PHP or even the CLI know that theyshould write unit tests

AGENDACurrent StateThe EcoSystemPHPUnit 37Annoying things we got rid ofFeatures you might have missedShiny new thingsTest suite organizationDiscussion

CURRENT STATEVersions 3612 and hot from the presses githubs 375Over 70 contributors since 360One last 36 release to help with dependencies37 is early in the bugfix cycle no new features will be added Thosego into nextFrench docs thanks to poum and still current Japanese docs thanksto m-takagiIf you want to help outhttpsgithubcomsebastianbergmannphpunitcontributing

THE ECOSYSTEMhttpphpqatoolsorg amp friends

BDDUse Behat Its great

Were not going to remove the BDD stuff in PHPUnit but Its not beingworked on

WEB INTERFACENot sure why youd want that but someone solved that for you

httpsgithubcomNSinopoliVisualPHPUnit

MOCKING IS UGLYReal world problems and solutions

httpstackoverflowcomsearchtab=votesampq=[phpunit] mock

MOCKERYTry it Its great

Afraid it might be hard to set up and use

Look into httpsgithubcometsyphpunit-extensionswikiMockery

Works with strict mode leaves the old API intact and is as easy aswriting a comment

class MyTest extends PHPUnit_Extensions_Mockery_TestCase

mockery Foo protected $foo

LOTS OF LEGACY CODEOr whatever hard to test is called these days

httpsgithubcomlapistanoproxy-object

One of the main purpose of this library is to expose invisible (private orprotected) methods and properties to the SUT

TESTING WEB SERVICESUnit and Integration test web services with the same code

Try wsUnit httpsgithubcomlapistanowsunit

IDE SUPPORTNetbeans support improved and they adopted the skeleton-generatorHonestly I have no clue about eclipsePHPStorm has really beautiful coverage support by nowvim user phpunit --coverage-text

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

AGENDACurrent StateThe EcoSystemPHPUnit 37Annoying things we got rid ofFeatures you might have missedShiny new thingsTest suite organizationDiscussion

CURRENT STATEVersions 3612 and hot from the presses githubs 375Over 70 contributors since 360One last 36 release to help with dependencies37 is early in the bugfix cycle no new features will be added Thosego into nextFrench docs thanks to poum and still current Japanese docs thanksto m-takagiIf you want to help outhttpsgithubcomsebastianbergmannphpunitcontributing

THE ECOSYSTEMhttpphpqatoolsorg amp friends

BDDUse Behat Its great

Were not going to remove the BDD stuff in PHPUnit but Its not beingworked on

WEB INTERFACENot sure why youd want that but someone solved that for you

httpsgithubcomNSinopoliVisualPHPUnit

MOCKING IS UGLYReal world problems and solutions

httpstackoverflowcomsearchtab=votesampq=[phpunit] mock

MOCKERYTry it Its great

Afraid it might be hard to set up and use

Look into httpsgithubcometsyphpunit-extensionswikiMockery

Works with strict mode leaves the old API intact and is as easy aswriting a comment

class MyTest extends PHPUnit_Extensions_Mockery_TestCase

mockery Foo protected $foo

LOTS OF LEGACY CODEOr whatever hard to test is called these days

httpsgithubcomlapistanoproxy-object

One of the main purpose of this library is to expose invisible (private orprotected) methods and properties to the SUT

TESTING WEB SERVICESUnit and Integration test web services with the same code

Try wsUnit httpsgithubcomlapistanowsunit

IDE SUPPORTNetbeans support improved and they adopted the skeleton-generatorHonestly I have no clue about eclipsePHPStorm has really beautiful coverage support by nowvim user phpunit --coverage-text

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

CURRENT STATEVersions 3612 and hot from the presses githubs 375Over 70 contributors since 360One last 36 release to help with dependencies37 is early in the bugfix cycle no new features will be added Thosego into nextFrench docs thanks to poum and still current Japanese docs thanksto m-takagiIf you want to help outhttpsgithubcomsebastianbergmannphpunitcontributing

THE ECOSYSTEMhttpphpqatoolsorg amp friends

BDDUse Behat Its great

Were not going to remove the BDD stuff in PHPUnit but Its not beingworked on

WEB INTERFACENot sure why youd want that but someone solved that for you

httpsgithubcomNSinopoliVisualPHPUnit

MOCKING IS UGLYReal world problems and solutions

httpstackoverflowcomsearchtab=votesampq=[phpunit] mock

MOCKERYTry it Its great

Afraid it might be hard to set up and use

Look into httpsgithubcometsyphpunit-extensionswikiMockery

Works with strict mode leaves the old API intact and is as easy aswriting a comment

class MyTest extends PHPUnit_Extensions_Mockery_TestCase

mockery Foo protected $foo

LOTS OF LEGACY CODEOr whatever hard to test is called these days

httpsgithubcomlapistanoproxy-object

One of the main purpose of this library is to expose invisible (private orprotected) methods and properties to the SUT

TESTING WEB SERVICESUnit and Integration test web services with the same code

Try wsUnit httpsgithubcomlapistanowsunit

IDE SUPPORTNetbeans support improved and they adopted the skeleton-generatorHonestly I have no clue about eclipsePHPStorm has really beautiful coverage support by nowvim user phpunit --coverage-text

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

THE ECOSYSTEMhttpphpqatoolsorg amp friends

BDDUse Behat Its great

Were not going to remove the BDD stuff in PHPUnit but Its not beingworked on

WEB INTERFACENot sure why youd want that but someone solved that for you

httpsgithubcomNSinopoliVisualPHPUnit

MOCKING IS UGLYReal world problems and solutions

httpstackoverflowcomsearchtab=votesampq=[phpunit] mock

MOCKERYTry it Its great

Afraid it might be hard to set up and use

Look into httpsgithubcometsyphpunit-extensionswikiMockery

Works with strict mode leaves the old API intact and is as easy aswriting a comment

class MyTest extends PHPUnit_Extensions_Mockery_TestCase

mockery Foo protected $foo

LOTS OF LEGACY CODEOr whatever hard to test is called these days

httpsgithubcomlapistanoproxy-object

One of the main purpose of this library is to expose invisible (private orprotected) methods and properties to the SUT

TESTING WEB SERVICESUnit and Integration test web services with the same code

Try wsUnit httpsgithubcomlapistanowsunit

IDE SUPPORTNetbeans support improved and they adopted the skeleton-generatorHonestly I have no clue about eclipsePHPStorm has really beautiful coverage support by nowvim user phpunit --coverage-text

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

BDDUse Behat Its great

Were not going to remove the BDD stuff in PHPUnit but Its not beingworked on

WEB INTERFACENot sure why youd want that but someone solved that for you

httpsgithubcomNSinopoliVisualPHPUnit

MOCKING IS UGLYReal world problems and solutions

httpstackoverflowcomsearchtab=votesampq=[phpunit] mock

MOCKERYTry it Its great

Afraid it might be hard to set up and use

Look into httpsgithubcometsyphpunit-extensionswikiMockery

Works with strict mode leaves the old API intact and is as easy aswriting a comment

class MyTest extends PHPUnit_Extensions_Mockery_TestCase

mockery Foo protected $foo

LOTS OF LEGACY CODEOr whatever hard to test is called these days

httpsgithubcomlapistanoproxy-object

One of the main purpose of this library is to expose invisible (private orprotected) methods and properties to the SUT

TESTING WEB SERVICESUnit and Integration test web services with the same code

Try wsUnit httpsgithubcomlapistanowsunit

IDE SUPPORTNetbeans support improved and they adopted the skeleton-generatorHonestly I have no clue about eclipsePHPStorm has really beautiful coverage support by nowvim user phpunit --coverage-text

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

WEB INTERFACENot sure why youd want that but someone solved that for you

httpsgithubcomNSinopoliVisualPHPUnit

MOCKING IS UGLYReal world problems and solutions

httpstackoverflowcomsearchtab=votesampq=[phpunit] mock

MOCKERYTry it Its great

Afraid it might be hard to set up and use

Look into httpsgithubcometsyphpunit-extensionswikiMockery

Works with strict mode leaves the old API intact and is as easy aswriting a comment

class MyTest extends PHPUnit_Extensions_Mockery_TestCase

mockery Foo protected $foo

LOTS OF LEGACY CODEOr whatever hard to test is called these days

httpsgithubcomlapistanoproxy-object

One of the main purpose of this library is to expose invisible (private orprotected) methods and properties to the SUT

TESTING WEB SERVICESUnit and Integration test web services with the same code

Try wsUnit httpsgithubcomlapistanowsunit

IDE SUPPORTNetbeans support improved and they adopted the skeleton-generatorHonestly I have no clue about eclipsePHPStorm has really beautiful coverage support by nowvim user phpunit --coverage-text

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

MOCKING IS UGLYReal world problems and solutions

httpstackoverflowcomsearchtab=votesampq=[phpunit] mock

MOCKERYTry it Its great

Afraid it might be hard to set up and use

Look into httpsgithubcometsyphpunit-extensionswikiMockery

Works with strict mode leaves the old API intact and is as easy aswriting a comment

class MyTest extends PHPUnit_Extensions_Mockery_TestCase

mockery Foo protected $foo

LOTS OF LEGACY CODEOr whatever hard to test is called these days

httpsgithubcomlapistanoproxy-object

One of the main purpose of this library is to expose invisible (private orprotected) methods and properties to the SUT

TESTING WEB SERVICESUnit and Integration test web services with the same code

Try wsUnit httpsgithubcomlapistanowsunit

IDE SUPPORTNetbeans support improved and they adopted the skeleton-generatorHonestly I have no clue about eclipsePHPStorm has really beautiful coverage support by nowvim user phpunit --coverage-text

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

MOCKERYTry it Its great

Afraid it might be hard to set up and use

Look into httpsgithubcometsyphpunit-extensionswikiMockery

Works with strict mode leaves the old API intact and is as easy aswriting a comment

class MyTest extends PHPUnit_Extensions_Mockery_TestCase

mockery Foo protected $foo

LOTS OF LEGACY CODEOr whatever hard to test is called these days

httpsgithubcomlapistanoproxy-object

One of the main purpose of this library is to expose invisible (private orprotected) methods and properties to the SUT

TESTING WEB SERVICESUnit and Integration test web services with the same code

Try wsUnit httpsgithubcomlapistanowsunit

IDE SUPPORTNetbeans support improved and they adopted the skeleton-generatorHonestly I have no clue about eclipsePHPStorm has really beautiful coverage support by nowvim user phpunit --coverage-text

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

LOTS OF LEGACY CODEOr whatever hard to test is called these days

httpsgithubcomlapistanoproxy-object

One of the main purpose of this library is to expose invisible (private orprotected) methods and properties to the SUT

TESTING WEB SERVICESUnit and Integration test web services with the same code

Try wsUnit httpsgithubcomlapistanowsunit

IDE SUPPORTNetbeans support improved and they adopted the skeleton-generatorHonestly I have no clue about eclipsePHPStorm has really beautiful coverage support by nowvim user phpunit --coverage-text

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

TESTING WEB SERVICESUnit and Integration test web services with the same code

Try wsUnit httpsgithubcomlapistanowsunit

IDE SUPPORTNetbeans support improved and they adopted the skeleton-generatorHonestly I have no clue about eclipsePHPStorm has really beautiful coverage support by nowvim user phpunit --coverage-text

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

IDE SUPPORTNetbeans support improved and they adopted the skeleton-generatorHonestly I have no clue about eclipsePHPStorm has really beautiful coverage support by nowvim user phpunit --coverage-text

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

JENKINSJenkins template jenkins-phporgclover php plugin

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

TRAVIS CIAwesome for GitHub and collaborationEveryone has the way to run their tests documented by nowNo really CI but a very cool test runnerUse --coverage-text if you want to show off )

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

PHPUNIT 3715+ features20+ issues fixedDetails later

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

COMPOSER

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

COMPOSERFor a long timeWhen someone does the work it it will happen

A couple of weeks agoclaylo came along and did the work Tweet him a thanks

YesterdayStill some issues Wait for 372 and try again It might take a fewiterations but Jordi ( Seldaek ) is helping out too so well get thereeventually )

TodayPHPUnit 375 was released and it works

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

PHAR - THE PHP TOOL FORMATIssues with process isolationTimeMaintanceTooling

Yesterday Sebastian published something that works for us Please testit

Have a look at

httpsebastian-bergmanndearchives924-Using-PHPUnit-from-a-PHP-Archive-PHARhtml

wget httppearphpunitdegetphpunit-375pharchmod +x phpunit-375pharphpunit-375phar

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

PHPUNIT-SELENIUMNow maintained by giorgiosironiCode coverage support

If you ask me Dont drive your web tests with phpunit

Use Behat or something non php

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

BCDid you like upgrading to PHPUnit 36

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

BC FREE-ISHWe are trying really hard to not introduce any BC breaks

cwd gets restored after test caseparameter cloning behaviorRemoved deprecated OutputTestCaseaddUncoveredFilesFromWhitelist changed intoprocessUncoveredFilesFromWhitelistCodeCoverage includes more files by defaultTest listeners trigger one autoload calland thats itIve written it all down for youhttpwwwphpunitdemanualcurrenteninstallationhtmlinstallingupgrading

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

ANNOYING THINGS WE GOTRID OF

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

BLOCKWhen using process-isolation PHPUnit wont die silently when

unserializing of the test result fails

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

HEY LISTENTest listeners now trigger one autoload call instead of being silently

ignored when the class was not loaded

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

EXCEPTIONALImproved reporting of exceptions

because it only told you

but now

public function testNestedExceptions() $e3 = new Exception(Three) $e2 = new InvalidArgumentException(Two 0 $e3) $e1 = new Exception(One 0 $e2) throw $e1

ExceptionStackTesttestNestedExceptionsException One

[trace]

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

EXCEPTIONALwe are printing out the previous exception names messages and

traces

ExceptionStackTesttestNestedExceptionsException One

[trace]

Caused byInvalidArgumentException Two

[trace]

Caused byException Three

[trace]

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

Fixed an annoying crash when using --process-isolation with PHP 53

and detect_unicode=on

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

EVEN MORE EXCEPTIONAL

Works again

expectedException Exception

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

ONE MORE THING

That one is still alive Sorry )

It just means that PHPUnit cant find any tests

Fatal error Uncaught exception PHPUnit_Framework_Exception with message Neither testsphp nor testsphp could be opened in

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

FEATURES YOU MIGHT HAVEMISSED

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

LINE ENDINGS MISMATCHIssue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

IMPROVED THE JSON LOGIf tests produce output it is now properly included in the log

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

BOOTSTRAP ORDERBootstrap script should be loaded before trying to load

testSuiteLoaderClass

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

PROCESS ISOLATION FOR EVERYONEProcess Isolation did not work when PHPUnit is invoked through arunner like Ant Phing Bash or Make due to PHP binary detection

issues

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

EXPECTEDEXCEPTIONCODENow can be 0 or a string

Useful for PDO

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

BINARY MESSBefore it broke your terminal and BEEPed at you

Now it shows a hex dump

1) FooTesttestFooFailed asserting that two strings are equal--- Expected+++ Actual -+ heartsdiams++parasectuarrdarrrarrlarr∟harr

Binary String 0x000102030405

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

ONE LINE ANNOTATIONSYou can use

or

expectedException FubarException

covers MyClass

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

COUNTING ON ITNow working with Countable and Iterator Interfaces

assertCount()assertAttributeCount()assertNotCount()assertAttributeNotCount()assertSameSize()assertNotSameSize()

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

FLUENT INTERFACESA little mock improvement

-gtwill($this-gtreturnSelf())

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

REQUIRES requires PHP 54 public function testTrait()

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

REQUIRESlttestsuitegt ltfile phpVersion=540 phpVersionOperator=gt=gt testsunitMyTraitTestphp ltfilegtlttestsuitegt

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

MAGIC SUPPORTassertEquals() now looks for (and invokes) a __toString() method when

an object and string are compared

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

PERFORMANCEsetUpBeforeClass() and tearDownAfterClass() are no longer invoked

when all tests of the class are skipped

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

SHINY NEW THINGS

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

LESS MAGIC NUMBERSexpectedException now works with constants

Reduce copy paste testing

expectedException Class expectedExceptionCode ClassTEAPOT_MISSING expectedExceptionMessage ClassTEAPOT_MISSING_MESSAGE

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

TESTPHP IS TOO MAINSTREAMAdded --test-suffix that allows specifying which filename suffixes are

recognised by PHPUnit

Helps out some projects with their CI

I dont see a general use case

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

JSON YES PLEASEWe added assertJson functions that work like the existing assertXml

functions

assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString()

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

CALLBACK MATCHERHelps with complex assertions on mocks

Its not pretty but it might solve that one annoying problem

public function send($message EndpointConfig $config)

$foo-gtexpects($this-gtonce()) -gtmethod(send) -gtwith( $this-gtequalTo(syn) $this-gtcallback( function ($config) $url = $config-gtgetUrl() if($url) throw new Exception() return $url-gtgetHost() === httpexamplecom ) )

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

OO-ARRAYS

Now work with objects that implement ArrayAccess

assertArrayHasKey()assertArrayNotHasKey()

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

PHPUNITXSDPHPUnit now provides a configurationxsd schema file

httpschemaphpunitdeconfigurationxsd

Useful to validate your phpunitxml and phpunitxmldist configurationfiles

ltxml version=10 encoding=UTF-8gtltphpunit xmlnsxsi=httpwwww3org2001XMLSchema-instance xsinoNamespaceSchemaLocation =httpschemaphpunitdeconfigurationxsd []gt

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

MORE REQUIRES

Require functions methods and extensionsMerges Class amp Method doc blocksPHP amp PHPUnit version get override

requires PHP 54-dev requires PHPUnit 37-dev requires function someFunc requires function Classfoo requires extension apc requires extension mysqli

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

PHPT IMPROVEMENTS--TEST--

GH-503 assertEquals() Line Ending Differences Are Obscure

--FILE--ltphp

$_SERVER[argv][1] = --no-configuration$_SERVER[argv][2] = Issue503Test$_SERVER[argv][3] = __DIR__)503Issue503Testphp

require_once __DIR__ PHPUnitAutoloadphpPHPUnit_TextUI_Commandmain()gt--EXPECTF--[]

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

PHPT IMPROVEMENTS--EXPECTF--PHPUnit s by Sebastian BergmannFTime i s Memory sMb

There was 1 failure

1) Issue503TesttestCompareDifferentLineEndingsFailed asserting that two strings are identical--- Expected+++ Actual Warning Strings contain different line endings foo

FAILURESTests 1 Assertions 1 Failures 1

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

PHPT IMPROVEMENTSBefore 37 diffs where really hard to read

Now the diff will be processed line by line

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

LISTS AND COLLECTIONS

Helper for checking Collection objects and arrays

Descriptive assertion and error message

public function testAssertContainsOnlyInstancesOf() $library = array( new Book() new Book() ) $this-gtassertContainsOnlyInstancesOf( Book $library )

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

FAILED EXPECTEDEXCEPTION ANNOTATIONSBefore

Now

Failed asserting that exception of type ErrorException matches expected exception MyException

Failed asserting that exception of type ErrorException matches expected exception MyException Message from ErrorException was undefined variable $htis

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

LESS REQUIRES LESS CRASHES

People seem to constantly run into issues with code coverage

When enabled uncovered whitelisted files are processed to properlycalculate the number of executable lines

If not we take a quite ok guess to get the number of ELOC

ltwhitelist addUncoveredFilesFromWhitelist=truegt

ltwhitelist processUncoveredFilesFromWhitelist=truegt

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

MORE USEFUL GROUPS

Now works as expected

$ phpunit --group FlakyTests

ltphpunitgt ltgroupsgt ltexcludegt ltgroupgtFlakyTestsltgroupgt ltexcludegt ltgroupsgt lttestsuites gtltphpunitgt

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

TEST SUITE ORGANIZATION

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

FOLDER LAYOUTproject phpunitxmldist src tests bootstrapphp unit integation functional (or system) helpers

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

TEST DISTRIBUTIONhttpelblinkininfo201203goldilocks-on-test-sizes

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

SMALL HINTSUse the xml configuration for pretty much everythingSeparate unit and integration testsYour unit test folders should mirror your applications folderstructureTo only execute specific tests use phpunit --filter or phpunittestsunitmodule1Use the strict mode from the get go and never turn it offImho Dont have a test namespace Nicer to read and showsproduction usage

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

DISCUSSIONIssues

Feature requests

Anything I missed

THANK YOU

THANK YOU

top related