SlideShare uma empresa Scribd logo
1 de 95
Test-Driven
Development
 for TYPO3



   Oliver Klee, 2012-14-08
     typo3-coding@oliverklee.de
Unit
tests?
Manual testing is cumbersome
Automated
testing is
fast
Unit tests for the
 Realty Manager
   extension
more than
1600 tests
in less than 60
    seconds
Verify that your code
does what you expect
Make sure that your
changes won‘t break
           anything
Keep
        other coders
from breaking your code
Don‘t break anything
even in complex projects
Create asafety net
   for refactoring
Green feels good!
Green feels good!
Know
   your
  tools
The phpunit extension
             has it all
The phpunit extension
               has it all
phpunit (TYPO3 extension)
The phpunit extension
               has it all
phpunit (TYPO3 extension)
 PHPUnit (PEAR package)
The phpunit extension
               has it all
phpunit (TYPO3 extension)
 PHPUnit (PEAR package)

 Testrunner
 (back-end-
  module)
The phpunit extension
               has it all
phpunit (TYPO3 extension)
 PHPUnit (PEAR package)

 Testrunner    Testrunner
 (back-end-
  module)     (CLI module)
The phpunit extension
               has it all
phpunit (TYPO3 extension)
 PHPUnit (PEAR package)
  Testing framework for FE & DB
 Testrunner         Testrunner
 (back-end-
  module)          (CLI module)
Let‘s get
some terms
  straight
Two tests
meet in a
  bar ...
Two tests
Test   meet in a
         bar ...
Two tests
  Test      meet in a
Assertion     bar ...
Two tests
  Test      meet in a
Assertion     bar ...
  Test
  Test
Two tests
  Test      meet in a
Assertion     bar ...
  Test
  Test
Test case
Two tests
  Test      meet in a
Assertion     bar ...
  Test
  Test
Test case
Test case
Two tests
  Test       meet in a
Assertion      bar ...
  Test
  Test
Test case
Test case
Test suite
The   life cycle unit test
               of a
The   life cycle unit test
               of a
The   life cycle unit test
               of a
                      new FooTest();
The   life cycle unit test
               of a
                      new FooTest();
The   life cycle unit test
               of a
                      new FooTest();

                           setUp();
The   life cycle unit test
               of a
                      new FooTest();

                           setUp();

                      /** @test */
                      lifeIsGood();
The   life cycle unit test
               of a
                      new FooTest();

                           setUp();

                      /** @test */
                      lifeIsGood();
The   life cycle unit test
               of a
                      new FooTest();

                           setUp();

                      /** @test */
                      lifeIsGood();

                        tearDown();
The   life cycle unit test
               of a
                      new FooTest();

                           setUp();

                      /** @test */
                      lifeIsGood();

                        tearDown();
The   life cycle unit test
               of a
                      new FooTest();

                           setUp();

                      /** @test */
                      lifeIsGood();

                        tearDown();
Code   test-first
Code   test-first
Code   test-first

write
test
Code   test-first

write
test
Code    test-first

write          write
test           code
Code    test-first

write          write
test           code
Code    test-first

write          write
test           code
Code    test-first

write          write
test           code



                       refactor
Code    test-first

write          write
test           code



                       refactor
Use   meaningful
           unit test   names
Use   meaningful
                          unit test   names
Name the
behavior.            classCanBeInstantiated
Use   meaningful
                            unit test   names
 Name the
 behavior.             classCanBeInstantiated


Mention the
 method.                   setTitleSetsTitle
Use   meaningful
                                 unit test   names
  Name the
  behavior.                 classCanBeInstantiated


Mention the
 method.                         setTitleSetsTitle


  Name the          setSizeWithZeroThrowsException
preconditions.   hasTitleForEmptyTitleReturnsFalse
Use   meaningful
                                 unit test   names
  Name the
  behavior.                 classCanBeInstantiated


Mention the
 method.                         setTitleSetsTitle


  Name the          setSizeWithZeroThrowsException
preconditions.   hasTitleForEmptyTitleReturnsFalse


  Dont‘t use
 "works" or
 "correctly".
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".
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".
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);
	   }
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
	   }
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,
	 …
The   testing framework
              can fake almost everything
The   testing framework
              can fake almost everything
         $recordUid = $tf->createRecord($tableName, array $recordData = array());
The   testing framework
              can fake almost everything
         $recordUid = $tf->createRecord($tableName, array $recordData = array());

                          $tf->changeRecord($tableName, $uid, array $recordData);
The   testing framework
              can fake almost everything
         $recordUid = $tf->createRecord($tableName, array $recordData = array());

                          $tf->changeRecord($tableName, $uid, array $recordData);


                                             $tf->deleteRecord($tableName, $uid);
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);
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);
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);
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 = '');
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 = '');
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 = '');
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);
The   testing framework
              can fake almost everything
The   testing framework
              can fake almost everything
      $pageUid = $tf->createFrontEndPage($parentId = 0, array $recordData = array());
The   testing framework
              can fake almost everything
      $pageUid = $tf->createFrontEndPage($parentId = 0, array $recordData = array());


      $pageUid = $tf->createSystemFolder($parentId = 0, array $recordData = array());
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());
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());
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);
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();
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());
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());
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);
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);
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());
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();
The   testing framework
              can fake almost everything
The   testing framework
              can fake almost everything
            $recordUid = $tf->createBackEndUser(array $recordData = array());
The   testing framework
              can fake almost everything
              $recordUid = $tf->createBackEndUser(array $recordData = array());

         $recordUid = $tf->createBackEndUserGroup(array $recordData = array());
The   testing framework
              can fake almost everything
The   testing framework
              can fake almost everything
          $path = $tf->createDummyFile($fileName = 'test.txt', $content = '');
The   testing framework
                can fake almost everything
                    $path = $tf->createDummyFile($fileName = 'test.txt', $content = '');


$path = $tf->createDummyZipArchive($fileName = 'test.zip', array $filesToAdd = array());
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);
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);
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);
Use vfsStream for creating
                           fake files and folders
public function setUp {
    $root = vfsStream::setUp('Stuff');
    $this->moreStuff = vfsStream::newDirectory('moreStuff')->at($root);
}
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'))
    );
}

Mais conteúdo relacionado

Mais procurados

JUnit Kung Fu: Getting More Out of Your Unit Tests
JUnit Kung Fu: Getting More Out of Your Unit TestsJUnit Kung Fu: Getting More Out of Your Unit Tests
JUnit Kung Fu: Getting More Out of Your Unit TestsJohn Ferguson Smart Limited
 
Py.test
Py.testPy.test
Py.testsoasme
 
Unit Testing using PHPUnit
Unit Testing using  PHPUnitUnit Testing using  PHPUnit
Unit Testing using PHPUnitvaruntaliyan
 
Unit Testing Presentation
Unit Testing PresentationUnit Testing Presentation
Unit Testing Presentationnicobn
 
Introduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnitIntroduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnitMichelangelo van Dam
 
Unit testing with PHPUnit - there's life outside of TDD
Unit testing with PHPUnit - there's life outside of TDDUnit testing with PHPUnit - there's life outside of TDD
Unit testing with PHPUnit - there's life outside of TDDPaweł Michalik
 
Python testing using mock and pytest
Python testing using mock and pytestPython testing using mock and pytest
Python testing using mock and pytestSuraj Deshmukh
 
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策kwatch
 
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalksSelenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalksLohika_Odessa_TechTalks
 
Test Driven Development With Python
Test Driven Development With PythonTest Driven Development With Python
Test Driven Development With PythonSiddhi
 
Advanced PHPUnit Testing
Advanced PHPUnit TestingAdvanced PHPUnit Testing
Advanced PHPUnit TestingMike Lively
 
Unit testing PHP apps with PHPUnit
Unit testing PHP apps with PHPUnitUnit testing PHP apps with PHPUnit
Unit testing PHP apps with PHPUnitMichelangelo van Dam
 

Mais procurados (20)

UPC Testing talk 2
UPC Testing talk 2UPC Testing talk 2
UPC Testing talk 2
 
Java custom annotations example
Java custom annotations exampleJava custom annotations example
Java custom annotations example
 
JUnit Kung Fu: Getting More Out of Your Unit Tests
JUnit Kung Fu: Getting More Out of Your Unit TestsJUnit Kung Fu: Getting More Out of Your Unit Tests
JUnit Kung Fu: Getting More Out of Your Unit Tests
 
Python unittest
Python unittestPython unittest
Python unittest
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Py.test
Py.testPy.test
Py.test
 
Unit Testing using PHPUnit
Unit Testing using  PHPUnitUnit Testing using  PHPUnit
Unit Testing using PHPUnit
 
Unit Testing Presentation
Unit Testing PresentationUnit Testing Presentation
Unit Testing Presentation
 
JUnit 5
JUnit 5JUnit 5
JUnit 5
 
Introduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnitIntroduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnit
 
3 j unit
3 j unit3 j unit
3 j unit
 
Core java
Core javaCore java
Core java
 
Tdd
TddTdd
Tdd
 
Unit testing with PHPUnit - there's life outside of TDD
Unit testing with PHPUnit - there's life outside of TDDUnit testing with PHPUnit - there's life outside of TDD
Unit testing with PHPUnit - there's life outside of TDD
 
Python testing using mock and pytest
Python testing using mock and pytestPython testing using mock and pytest
Python testing using mock and pytest
 
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
 
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalksSelenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
 
Test Driven Development With Python
Test Driven Development With PythonTest Driven Development With Python
Test Driven Development With Python
 
Advanced PHPUnit Testing
Advanced PHPUnit TestingAdvanced PHPUnit Testing
Advanced PHPUnit Testing
 
Unit testing PHP apps with PHPUnit
Unit testing PHP apps with PHPUnitUnit testing PHP apps with PHPUnit
Unit testing PHP apps with PHPUnit
 

Semelhante a Test-driven Development for TYPO3

Test in action week 2
Test in action   week 2Test in action   week 2
Test in action week 2Yi-Huan Chan
 
Unit testing with PHPUnit
Unit testing with PHPUnitUnit testing with PHPUnit
Unit testing with PHPUnitferca_sl
 
Pragmatic unittestingwithj unit
Pragmatic unittestingwithj unitPragmatic unittestingwithj unit
Pragmatic unittestingwithj unitliminescence
 
Fighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitFighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitJames Fuller
 
Refactoring In Tdd The Missing Part
Refactoring In Tdd The Missing PartRefactoring In Tdd The Missing Part
Refactoring In Tdd The Missing PartGabriele Lana
 
Commencer avec le TDD
Commencer avec le TDDCommencer avec le TDD
Commencer avec le TDDEric Hogue
 
(Unit )-Testing for Joomla
(Unit )-Testing for Joomla(Unit )-Testing for Joomla
(Unit )-Testing for JoomlaDavid Jardin
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownpartsBastian Feder
 
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnitinternational PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnitsmueller_sandsmedia
 
Test in action week 4
Test in action   week 4Test in action   week 4
Test in action week 4Yi-Huan Chan
 
Php Unit With Zend Framework Zendcon09
Php Unit With Zend Framework   Zendcon09Php Unit With Zend Framework   Zendcon09
Php Unit With Zend Framework Zendcon09Michelangelo van Dam
 
PHPUnit best practices presentation
PHPUnit best practices presentationPHPUnit best practices presentation
PHPUnit best practices presentationThanh Robi
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11Michelangelo van Dam
 
PHPunit and you
PHPunit and youPHPunit and you
PHPunit and youmarkstory
 
Unit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon GaliciaUnit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon GaliciaRobot Media
 
Understanding JavaScript Testing
Understanding JavaScript TestingUnderstanding JavaScript Testing
Understanding JavaScript Testingjeresig
 

Semelhante a Test-driven Development for TYPO3 (20)

Test in action week 2
Test in action   week 2Test in action   week 2
Test in action week 2
 
Unit testing with PHPUnit
Unit testing with PHPUnitUnit testing with PHPUnit
Unit testing with PHPUnit
 
Pragmatic unittestingwithj unit
Pragmatic unittestingwithj unitPragmatic unittestingwithj unit
Pragmatic unittestingwithj unit
 
Fighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitFighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnit
 
Refactoring In Tdd The Missing Part
Refactoring In Tdd The Missing PartRefactoring In Tdd The Missing Part
Refactoring In Tdd The Missing Part
 
Commencer avec le TDD
Commencer avec le TDDCommencer avec le TDD
Commencer avec le TDD
 
(Unit )-Testing for Joomla
(Unit )-Testing for Joomla(Unit )-Testing for Joomla
(Unit )-Testing for Joomla
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
 
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnitinternational PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
 
Test in action week 4
Test in action   week 4Test in action   week 4
Test in action week 4
 
Google guava
Google guavaGoogle guava
Google guava
 
Tdd & unit test
Tdd & unit testTdd & unit test
Tdd & unit test
 
Php Unit With Zend Framework Zendcon09
Php Unit With Zend Framework   Zendcon09Php Unit With Zend Framework   Zendcon09
Php Unit With Zend Framework Zendcon09
 
JUnit Pioneer
JUnit PioneerJUnit Pioneer
JUnit Pioneer
 
PHPUnit testing to Zend_Test
PHPUnit testing to Zend_TestPHPUnit testing to Zend_Test
PHPUnit testing to Zend_Test
 
PHPUnit best practices presentation
PHPUnit best practices presentationPHPUnit best practices presentation
PHPUnit best practices presentation
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11
 
PHPunit and you
PHPunit and youPHPunit and you
PHPunit and you
 
Unit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon GaliciaUnit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon Galicia
 
Understanding JavaScript Testing
Understanding JavaScript TestingUnderstanding JavaScript Testing
Understanding JavaScript Testing
 

Mais de Oliver Klee

Stand das im Handbuch?
Stand das im Handbuch?Stand das im Handbuch?
Stand das im Handbuch?Oliver Klee
 
Objektorientierte Programmierung mit extbase und fluid
Objektorientierte Programmierung mit extbase und fluidObjektorientierte Programmierung mit extbase und fluid
Objektorientierte Programmierung mit extbase und fluidOliver Klee
 
Stand das im Handbuch?
Stand das im Handbuch?Stand das im Handbuch?
Stand das im Handbuch?Oliver Klee
 
Test-Driven Development ... und mehr
Test-Driven Development ... und mehrTest-Driven Development ... und mehr
Test-Driven Development ... und mehrOliver Klee
 
Test-driven Development mit TYPO3
Test-driven Development mit TYPO3Test-driven Development mit TYPO3
Test-driven Development mit TYPO3Oliver Klee
 
Test-driven development with TYPO3 (T3CON10)
Test-driven development with TYPO3 (T3CON10)Test-driven development with TYPO3 (T3CON10)
Test-driven development with TYPO3 (T3CON10)Oliver Klee
 
Persönliches Zeitmanagement mit Getting Things Done (GTD)
Persönliches Zeitmanagement mit Getting Things Done (GTD)Persönliches Zeitmanagement mit Getting Things Done (GTD)
Persönliches Zeitmanagement mit Getting Things Done (GTD)Oliver Klee
 
Everything you need to know about the TYPO3 Security Team (T3DD10)
Everything you need to know about the TYPO3 Security Team (T3DD10)Everything you need to know about the TYPO3 Security Team (T3DD10)
Everything you need to know about the TYPO3 Security Team (T3DD10)Oliver Klee
 
TDD & Best Practices mit TYPO3
TDD & Best Practices mit TYPO3TDD & Best Practices mit TYPO3
TDD & Best Practices mit TYPO3Oliver Klee
 
Unit testing for the TYPO3 4.x core
Unit testing for the TYPO3 4.x coreUnit testing for the TYPO3 4.x core
Unit testing for the TYPO3 4.x coreOliver Klee
 

Mais de Oliver Klee (11)

Stand das im Handbuch?
Stand das im Handbuch?Stand das im Handbuch?
Stand das im Handbuch?
 
Objektorientierte Programmierung mit extbase und fluid
Objektorientierte Programmierung mit extbase und fluidObjektorientierte Programmierung mit extbase und fluid
Objektorientierte Programmierung mit extbase und fluid
 
Stand das im Handbuch?
Stand das im Handbuch?Stand das im Handbuch?
Stand das im Handbuch?
 
Test-Driven Development ... und mehr
Test-Driven Development ... und mehrTest-Driven Development ... und mehr
Test-Driven Development ... und mehr
 
Test-driven Development mit TYPO3
Test-driven Development mit TYPO3Test-driven Development mit TYPO3
Test-driven Development mit TYPO3
 
Test-driven development with TYPO3 (T3CON10)
Test-driven development with TYPO3 (T3CON10)Test-driven development with TYPO3 (T3CON10)
Test-driven development with TYPO3 (T3CON10)
 
Persönliches Zeitmanagement mit Getting Things Done (GTD)
Persönliches Zeitmanagement mit Getting Things Done (GTD)Persönliches Zeitmanagement mit Getting Things Done (GTD)
Persönliches Zeitmanagement mit Getting Things Done (GTD)
 
Everything you need to know about the TYPO3 Security Team (T3DD10)
Everything you need to know about the TYPO3 Security Team (T3DD10)Everything you need to know about the TYPO3 Security Team (T3DD10)
Everything you need to know about the TYPO3 Security Team (T3DD10)
 
TDD & Best Practices mit TYPO3
TDD & Best Practices mit TYPO3TDD & Best Practices mit TYPO3
TDD & Best Practices mit TYPO3
 
GPG Workshop
GPG WorkshopGPG Workshop
GPG Workshop
 
Unit testing for the TYPO3 4.x core
Unit testing for the TYPO3 4.x coreUnit testing for the TYPO3 4.x core
Unit testing for the TYPO3 4.x core
 

Último

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 

Último (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

Test-driven Development for TYPO3

  • 1. Test-Driven Development for TYPO3 Oliver Klee, 2012-14-08 typo3-coding@oliverklee.de
  • 3. Manual testing is cumbersome
  • 5. Unit tests for the Realty Manager extension
  • 7. in less than 60 seconds
  • 8. Verify that your code does what you expect
  • 9. Make sure that your changes won‘t break anything
  • 10. Keep other coders from breaking your code
  • 11. Don‘t break anything even in complex projects
  • 12. Create asafety net for refactoring
  • 15.
  • 16. Know your tools
  • 17. The phpunit extension has it all
  • 18. The phpunit extension has it all phpunit (TYPO3 extension)
  • 19. The phpunit extension has it all phpunit (TYPO3 extension) PHPUnit (PEAR package)
  • 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)
  • 24. Two tests meet in a bar ...
  • 25. Two tests Test meet in a bar ...
  • 26. Two tests Test meet in a Assertion bar ...
  • 27. Two tests Test meet in a Assertion bar ... Test Test
  • 28. Two tests Test meet in a Assertion bar ... Test Test Test case
  • 29. Two tests Test meet in a Assertion bar ... Test Test Test case Test case
  • 30. Two tests Test meet in a Assertion bar ... Test Test Test case Test case Test suite
  • 31. The life cycle unit test of a
  • 32. The life cycle unit test of a
  • 33. The life cycle unit test of a new FooTest();
  • 34. The life cycle unit test of a new FooTest();
  • 35. The life cycle unit test of a new FooTest(); setUp();
  • 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();
  • 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. The life cycle unit test of a new FooTest(); setUp(); /** @test */ lifeIsGood(); tearDown();
  • 41. Code test-first
  • 42. Code test-first
  • 43. Code test-first write test
  • 44. Code test-first write test
  • 45. Code test-first write write test code
  • 46. Code test-first write write test code
  • 47. Code test-first write write test code
  • 48. Code test-first write write test code refactor
  • 49. Code test-first write write test code refactor
  • 50.
  • 51. Use meaningful unit test names
  • 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);
  • 66. 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);
  • 67. 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);
  • 68. 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 = '');
  • 69. 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 = '');
  • 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); $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 = '');
  • 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); $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);
  • 72. The testing framework can fake almost everything
  • 73. The testing framework can fake almost everything $pageUid = $tf->createFrontEndPage($parentId = 0, array $recordData = array());
  • 74. The testing framework can fake almost everything $pageUid = $tf->createFrontEndPage($parentId = 0, array $recordData = array()); $pageUid = $tf->createSystemFolder($parentId = 0, array $recordData = array());
  • 75. 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());
  • 76. 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());
  • 77. 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);
  • 78. 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();
  • 79. 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());
  • 80. 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());
  • 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()); $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);
  • 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()); $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);
  • 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); $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());
  • 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(); $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();
  • 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')) ); }

Notas do Editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n