20. The phpunit extension
has it all
phpunit (TYPO3 extension)
PHPUnit (PEAR package)
Testrunner
(back-end-
module)
21. The phpunit extension
has it all
phpunit (TYPO3 extension)
PHPUnit (PEAR package)
Testrunner Testrunner
(back-end-
module) (CLI module)
22. The phpunit extension
has it all
phpunit (TYPO3 extension)
PHPUnit (PEAR package)
Testing framework for FE & DB
Testrunner Testrunner
(back-end-
module) (CLI module)
52. Use meaningful
unit test names
Name the
behavior. classCanBeInstantiated
53. Use meaningful
unit test names
Name the
behavior. classCanBeInstantiated
Mention the
method. setTitleSetsTitle
54. Use meaningful
unit test names
Name the
behavior. classCanBeInstantiated
Mention the
method. setTitleSetsTitle
Name the setSizeWithZeroThrowsException
preconditions. hasTitleForEmptyTitleReturnsFalse
55. Use meaningful
unit test names
Name the
behavior. classCanBeInstantiated
Mention the
method. setTitleSetsTitle
Name the setSizeWithZeroThrowsException
preconditions. hasTitleForEmptyTitleReturnsFalse
Dont‘t use
"works" or
"correctly".
56. Use meaningful
unit test names
Name the
behavior. classCanBeInstantiated
Mention the
method. setTitleSetsTitle
Name the setSizeWithZeroThrowsException
preconditions. hasTitleForEmptyTitleReturnsFalse
Dont‘t use
"works" or measureFrubbleWorksCorrectly
"correctly".
57. Use meaningful
unit test names
Name the
behavior. classCanBeInstantiated
Mention the
method. setTitleSetsTitle
Name the setSizeWithZeroThrowsException
preconditions. hasTitleForEmptyTitleReturnsFalse
Dont‘t use
"works" or measureFrubbleWorksCorrectly
"correctly".
58. The testing framework
is created quickly
/**
* @var Tx_Phpunit_Framework
*/
protected $testingFramework = NULL;
public function setUp() {
$this->testingFramework = new Tx_Phpunit_Framework('tx_news2');
}
public function tearDown() {
$this->testingFramework->cleanUp();
unset($this->testingFramework);
}
59. The testing framework
is created quickly
/**
* @var Tx_Phpunit_Framework
*/
protected $testingFramework = NULL;
public function setUp() {
$this->testingFramework = new Tx_Phpunit_Framework('tx_news2');
}
discard the FE,
public function tearDown() {
delete DB records,
$this->testingFramework->cleanUp();
unset($this->testingFramework);
delete files
}
60. The testing framework
is created quickly
/**
* @var Tx_Phpunit_Framework
*/
protected $testingFramework = NULL;
public function setUp() {
$this->testingFramework = new Tx_Phpunit_Framework('tx_news2');
}
discard the FE,
public function tearDown() {
delete DB records,
$this->testingFramework->cleanUp();
unset($this->testingFramework);
delete files
}
CREATE TABLE tx_news2_domain_model_news (
…
is_dummy_record tinyint(1) unsigned DEFAULT '0' NOT NULL,
…
61. The testing framework
can fake almost everything
62. The testing framework
can fake almost everything
$recordUid = $tf->createRecord($tableName, array $recordData = array());
63. The testing framework
can fake almost everything
$recordUid = $tf->createRecord($tableName, array $recordData = array());
$tf->changeRecord($tableName, $uid, array $recordData);
64. The testing framework
can fake almost everything
$recordUid = $tf->createRecord($tableName, array $recordData = array());
$tf->changeRecord($tableName, $uid, array $recordData);
$tf->deleteRecord($tableName, $uid);
65. The testing framework
can fake almost everything
$recordUid = $tf->createRecord($tableName, array $recordData = array());
$tf->changeRecord($tableName, $uid, array $recordData);
$tf->deleteRecord($tableName, $uid);
$tf->createRelation($tableName, $uidLocal, $uidForeign, $sorting = 0);
85. The testing framework
can fake almost everything
86. The testing framework
can fake almost everything
$recordUid = $tf->createBackEndUser(array $recordData = array());
87. The testing framework
can fake almost everything
$recordUid = $tf->createBackEndUser(array $recordData = array());
$recordUid = $tf->createBackEndUserGroup(array $recordData = array());
88. The testing framework
can fake almost everything
89. The testing framework
can fake almost everything
$path = $tf->createDummyFile($fileName = 'test.txt', $content = '');
90. The testing framework
can fake almost everything
$path = $tf->createDummyFile($fileName = 'test.txt', $content = '');
$path = $tf->createDummyZipArchive($fileName = 'test.zip', array $filesToAdd = array());
91. The testing framework
can fake almost everything
$path = $tf->createDummyFile($fileName = 'test.txt', $content = '');
$path = $tf->createDummyZipArchive($fileName = 'test.zip', array $filesToAdd = array());
$tf->deleteDummyFile($fileName);
92. The testing framework
can fake almost everything
$path = $tf->createDummyFile($fileName = 'test.txt', $content = '');
$path = $tf->createDummyZipArchive($fileName = 'test.zip', array $filesToAdd = array());
$tf->deleteDummyFile($fileName);
$path = $tf->createDummyFolder($folderName);
93. The testing framework
can fake almost everything
$path = $tf->createDummyFile($fileName = 'test.txt', $content = '');
$path = $tf->createDummyZipArchive($fileName = 'test.zip', array $filesToAdd = array());
$tf->deleteDummyFile($fileName);
$path = $tf->createDummyFolder($folderName);
$tf->deleteDummyFolder($folderName);
94. Use vfsStream for creating
fake files and folders
public function setUp {
$root = vfsStream::setUp('Stuff');
$this->moreStuff = vfsStream::newDirectory('moreStuff')->at($root);
}
95. Use vfsStream for creating
fake files and folders
public function setUp {
$root = vfsStream::setUp('Stuff');
$this->moreStuff = vfsStream::newDirectory('moreStuff')->at($root);
}
/**
* @test
*/
public function checkFileWithPathOfExistingNonEmptyFileReturnsTrue() {
$file = vfsStream::createFile('test.txt')->at($this->moreStuff);
$file->withContent('Hello world!');
$this->assertTrue(
$this->fixture->checkFile(vfsStream::url('Stuff/moreStuff/test.txt'))
);
}