Weitere ähnliche Inhalte Ähnlich wie Test-Driven Development for TYPO3 Ähnlich wie Test-Driven Development for TYPO3 (20) Mehr von Oliver Klee (12) Kürzlich hochgeladen (20) Test-Driven Development for TYPO310. Keep
other coders
from breaking your code
19. The phpunit extension
has it all
phpunit (TYPO3 extension)
PHPUnit (PEAR package)
Testrunner
(back-end-
module)
20. The phpunit extension
has it all
phpunit (TYPO3 extension)
PHPUnit (PEAR package)
Testrunner Testrunner
(back-end-
module) (CLI module)
21. The phpunit extension
has it all
phpunit (TYPO3 extension)
PHPUnit (PEAR package)
Testing framework for FE & DB
Testrunner Testrunner
(back-end-
module) (CLI module)
25. Two tests
Test meet in a
Assertion bar ...
26. Two tests
Test meet in a
Assertion bar ...
Test
Test
27. Two tests
Test meet in a
Assertion bar ...
Test
Test
Test case
28. Two tests
Test meet in a
Assertion bar ...
Test
Test
Test case
Test case
29. Two tests
Test meet in a
Assertion bar ...
Test
Test
Test case
Test case
Test suite
30. The life cycle unit test
of a
31. The life cycle unit test
of a
32. The life cycle unit test
of a
new FooTest();
33. The life cycle unit test
of a
new FooTest();
34. The life cycle unit test
of a
new FooTest();
setUp();
35. The life cycle unit test
of a
new FooTest();
setUp();
/** @test */
lifeIsGood();
36. The life cycle unit test
of a
new FooTest();
setUp();
/** @test */
lifeIsGood();
37. The life cycle unit test
of a
new FooTest();
setUp();
/** @test */
lifeIsGood();
tearDown();
38. The life cycle unit test
of a
new FooTest();
setUp();
/** @test */
lifeIsGood();
tearDown();
39. The life cycle unit test
of a
new FooTest();
setUp();
/** @test */
lifeIsGood();
tearDown();
40. Use meaningful
unit test names
41. Use meaningful
unit test names
Name the
behavior. classCanBeInstantiated
42. Use meaningful
unit test names
Name the
behavior. classCanBeInstantiated
Mention the
method. setTitleSetsTitle
43. Use meaningful
unit test names
Name the
behavior. classCanBeInstantiated
Mention the
method. setTitleSetsTitle
Name the setSizeWithZeroThrowsException
preconditions. hasTitleForEmptyTitleReturnsFalse
44. Use meaningful
unit test names
Name the
behavior. classCanBeInstantiated
Mention the
method. setTitleSetsTitle
Name the setSizeWithZeroThrowsException
preconditions. hasTitleForEmptyTitleReturnsFalse
Dont‘t use
"works" or
"correctly".
45. 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".
46. 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".
49. Code test-first
write
test
50. Code test-first
write
test
51. Code test-first
write write
test code
52. Code test-first
write write
test code
53. Code test-first
write write
test code
54. Code test-first
write write
test code
refactor
55. Code test-first
write write
test code
refactor
64. 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);
}
65. 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
}
66. 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,
…
67. The testing framework
can fake almost everything
68. The testing framework
can fake almost everything
$recordUid = $tf->createRecord($tableName, array $recordData = array());
69. The testing framework
can fake almost everything
$recordUid = $tf->createRecord($tableName, array $recordData = array());
$tf->changeRecord($tableName, $uid, array $recordData);
70. The testing framework
can fake almost everything
$recordUid = $tf->createRecord($tableName, array $recordData = array());
$tf->changeRecord($tableName, $uid, array $recordData);
$tf->deleteRecord($tableName, $uid);
71. 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);
72. 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);
$tf->createRelationAndUpdateCounter($tableName, $uidLocal, $uidForeign, $columnName);
73. 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);
$tf->createRelationAndUpdateCounter($tableName, $uidLocal, $uidForeign, $columnName);
$tf->removeRelation($tableName, $uidLocal, $uidForeign);
74. 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);
$tf->createRelationAndUpdateCounter($tableName, $uidLocal, $uidForeign, $columnName);
$tf->removeRelation($tableName, $uidLocal, $uidForeign);
$numberOfRecords = $tf->countRecords($tableName, $whereClause = '');
75. 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);
$tf->createRelationAndUpdateCounter($tableName, $uidLocal, $uidForeign, $columnName);
$tf->removeRelation($tableName, $uidLocal, $uidForeign);
$numberOfRecords = $tf->countRecords($tableName, $whereClause = '');
$success = $tf->existsRecord($tableName, $whereClause = '');
76. 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);
$tf->createRelationAndUpdateCounter($tableName, $uidLocal, $uidForeign, $columnName);
$tf->removeRelation($tableName, $uidLocal, $uidForeign);
$numberOfRecords = $tf->countRecords($tableName, $whereClause = '');
$success = $tf->existsRecord($tableName, $whereClause = '');
$success = $tf->existsExactlyOneRecord($tableName, $whereClause = '');
77. 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);
$tf->createRelationAndUpdateCounter($tableName, $uidLocal, $uidForeign, $columnName);
$tf->removeRelation($tableName, $uidLocal, $uidForeign);
$numberOfRecords = $tf->countRecords($tableName, $whereClause = '');
$success = $tf->existsRecord($tableName, $whereClause = '');
$success = $tf->existsExactlyOneRecord($tableName, $whereClause = '');
$success = $tf->existsRecordWithUid($tableName, $uid);
78. The testing framework
can fake almost everything
79. The testing framework
can fake almost everything
$pageUid = $tf->createFrontEndPage($parentId = 0, array $recordData = array());
80. The testing framework
can fake almost everything
$pageUid = $tf->createFrontEndPage($parentId = 0, array $recordData = array());
$pageUid = $tf->createSystemFolder($parentId = 0, array $recordData = array());
81. The testing framework
can fake almost everything
$pageUid = $tf->createFrontEndPage($parentId = 0, array $recordData = array());
$pageUid = $tf->createSystemFolder($parentId = 0, array $recordData = array());
$elementUid = $tf->createContentElement($pageId = 0, array $recordData = array());
82. The testing framework
can fake almost everything
$pageUid = $tf->createFrontEndPage($parentId = 0, array $recordData = array());
$pageUid = $tf->createSystemFolder($parentId = 0, array $recordData = array());
$elementUid = $tf->createContentElement($pageId = 0, array $recordData = array());
$tf->createTemplate($pageId, array $recordData = array());
83. The testing framework
can fake almost everything
$pageUid = $tf->createFrontEndPage($parentId = 0, array $recordData = array());
$pageUid = $tf->createSystemFolder($parentId = 0, array $recordData = array());
$elementUid = $tf->createContentElement($pageId = 0, array $recordData = array());
$tf->createTemplate($pageId, array $recordData = array());
$pageUid = $tf->createFakeFrontEnd($pageUid = 0);
84. The testing framework
can fake almost everything
$pageUid = $tf->createFrontEndPage($parentId = 0, array $recordData = array());
$pageUid = $tf->createSystemFolder($parentId = 0, array $recordData = array());
$elementUid = $tf->createContentElement($pageId = 0, array $recordData = array());
$tf->createTemplate($pageId, array $recordData = array());
$pageUid = $tf->createFakeFrontEnd($pageUid = 0);
$tf->discardFakeFrontEnd();
85. The testing framework
can fake almost everything
$pageUid = $tf->createFrontEndPage($parentId = 0, array $recordData = array());
$pageUid = $tf->createSystemFolder($parentId = 0, array $recordData = array());
$elementUid = $tf->createContentElement($pageId = 0, array $recordData = array());
$tf->createTemplate($pageId, array $recordData = array());
$pageUid = $tf->createFakeFrontEnd($pageUid = 0);
$tf->discardFakeFrontEnd();
$groupUid = $tf->createFrontEndUserGroup(array $recordData = array());
86. The testing framework
can fake almost everything
$pageUid = $tf->createFrontEndPage($parentId = 0, array $recordData = array());
$pageUid = $tf->createSystemFolder($parentId = 0, array $recordData = array());
$elementUid = $tf->createContentElement($pageId = 0, array $recordData = array());
$tf->createTemplate($pageId, array $recordData = array());
$pageUid = $tf->createFakeFrontEnd($pageUid = 0);
$tf->discardFakeFrontEnd();
$groupUid = $tf->createFrontEndUserGroup(array $recordData = array());
$userUid = $tf->createFrontEndUser($groups = '', array $recordData = array());
87. The testing framework
can fake almost everything
$pageUid = $tf->createFrontEndPage($parentId = 0, array $recordData = array());
$pageUid = $tf->createSystemFolder($parentId = 0, array $recordData = array());
$elementUid = $tf->createContentElement($pageId = 0, array $recordData = array());
$tf->createTemplate($pageId, array $recordData = array());
$pageUid = $tf->createFakeFrontEnd($pageUid = 0);
$tf->discardFakeFrontEnd();
$groupUid = $tf->createFrontEndUserGroup(array $recordData = array());
$userUid = $tf->createFrontEndUser($groups = '', array $recordData = array());
$tf->loginFrontEndUser($userId);
88. The testing framework
can fake almost everything
$pageUid = $tf->createFrontEndPage($parentId = 0, array $recordData = array());
$pageUid = $tf->createSystemFolder($parentId = 0, array $recordData = array());
$elementUid = $tf->createContentElement($pageId = 0, array $recordData = array());
$tf->createTemplate($pageId, array $recordData = array());
$pageUid = $tf->createFakeFrontEnd($pageUid = 0);
$tf->discardFakeFrontEnd();
$groupUid = $tf->createFrontEndUserGroup(array $recordData = array());
$userUid = $tf->createFrontEndUser($groups = '', array $recordData = array());
$tf->logoutFrontEndUser(); $tf->loginFrontEndUser($userId);
89. The testing framework
can fake almost everything
$pageUid = $tf->createFrontEndPage($parentId = 0, array $recordData = array());
$pageUid = $tf->createSystemFolder($parentId = 0, array $recordData = array());
$elementUid = $tf->createContentElement($pageId = 0, array $recordData = array());
$tf->createTemplate($pageId, array $recordData = array());
$pageUid = $tf->createFakeFrontEnd($pageUid = 0);
$tf->discardFakeFrontEnd();
$groupUid = $tf->createFrontEndUserGroup(array $recordData = array());
$userUid = $tf->createFrontEndUser($groups = '', array $recordData = array());
$tf->logoutFrontEndUser(); $tf->loginFrontEndUser($userId);
$userUid = $tf->createAndLoginFrontEndUser($groups = '', array $recordData = array());
90. The testing framework
can fake almost everything
$pageUid = $tf->createFrontEndPage($parentId = 0, array $recordData = array());
$pageUid = $tf->createSystemFolder($parentId = 0, array $recordData = array());
$elementUid = $tf->createContentElement($pageId = 0, array $recordData = array());
$tf->createTemplate($pageId, array $recordData = array());
$pageUid = $tf->createFakeFrontEnd($pageUid = 0);
$tf->discardFakeFrontEnd();
$groupUid = $tf->createFrontEndUserGroup(array $recordData = array());
$userUid = $tf->createFrontEndUser($groups = '', array $recordData = array());
$tf->logoutFrontEndUser(); $tf->loginFrontEndUser($userId);
$userUid = $tf->createAndLoginFrontEndUser($groups = '', array $recordData = array());
$isLoggedIn = $tf->isLoggedIn();
91. The testing framework
can fake almost everything
92. The testing framework
can fake almost everything
$recordUid = $tf->createBackEndUser(array $recordData = array());
93. The testing framework
can fake almost everything
$recordUid = $tf->createBackEndUser(array $recordData = array());
$recordUid = $tf->createBackEndUserGroup(array $recordData = array());
94. The testing framework
can fake almost everything
95. The testing framework
can fake almost everything
$path = $tf->createDummyFile($fileName = 'test.txt', $content = '');
96. The testing framework
can fake almost everything
$path = $tf->createDummyFile($fileName = 'test.txt', $content = '');
$path = $tf->createDummyZipArchive($fileName = 'test.zip', array $filesToAdd = array());
97. 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);
98. 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);
99. 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);
Hinweis der Redaktion \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n