Changeset 916
- Timestamp:
- 07/22/08 14:54:49 (1 month ago)
- Files:
-
- branches/kaste/PHPUnit_TestSuite/README (modified) (1 diff)
- branches/kaste/PHPUnit_TestSuite/VERSION (added)
- branches/kaste/PHPUnit_TestSuite/examples/ModelTest.php (modified) (4 diffs)
- branches/kaste/PHPUnit_TestSuite/installer (added)
- branches/kaste/PHPUnit_TestSuite/installer/PHPUnit_TestSuite_installer.php (added)
- branches/kaste/PHPUnit_TestSuite/installer/phpunit_test.php (added)
- branches/kaste/PHPUnit_TestSuite/lib/PHPUnit_Controller_TestCase.php (modified) (3 diffs)
- branches/kaste/PHPUnit_TestSuite/lib/PHPUnit_Model_TestCase.php (modified) (2 diffs)
- branches/kaste/PHPUnit_TestSuite/tests/AkRouterSpecs.php (deleted)
- branches/kaste/PHPUnit_TestSuite/tests/RouterRegexesInvestigation.php (deleted)
- branches/kaste/PHPUnit_TestSuite/tests/fixtures/person_controller.php (added)
- branches/kaste/PHPUnit_TestSuite/tests/lib (added)
- branches/kaste/PHPUnit_TestSuite/tests/lib/AutoloaderTest.php (moved) (moved from branches/kaste/PHPUnit_TestSuite/tests/AutoloaderTest.php)
- branches/kaste/PHPUnit_TestSuite/tests/lib/ExamplesTestSuite.php (moved) (moved from branches/kaste/PHPUnit_TestSuite/tests/ExamplesTestSuite.php) (1 diff)
- branches/kaste/PHPUnit_TestSuite/tests/lib/PersonControllerTest.php (added)
- branches/kaste/PHPUnit_TestSuite/tests/lib/RoutingTest.php (moved) (moved from branches/kaste/PHPUnit_TestSuite/tests/RoutingTest.php)
- branches/kaste/PHPUnit_TestSuite/tests/lib/SimpleFixturesForModelsTest.php (moved) (moved from branches/kaste/PHPUnit_TestSuite/tests/SimpleFixturesForModelsTest.php)
- branches/kaste/PHPUnit_TestSuite/tests/lib/TestControllerTest.php (moved) (moved from branches/kaste/PHPUnit_TestSuite/tests/TestControllerTest.php)
- branches/kaste/PHPUnit_TestSuite/tests/lib/TestModelTest.php (moved) (moved from branches/kaste/PHPUnit_TestSuite/tests/TestModelTest.php) (1 diff)
- branches/kaste/PHPUnit_TestSuite/tests/lib/TestRequestTest.php (moved) (moved from branches/kaste/PHPUnit_TestSuite/tests/TestRequestTest.php)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/kaste/PHPUnit_TestSuite/README
r615 r916 19 19 ---------- 20 20 21 This TestSuite has its own script (script /test_runner.php) to run your tests. Basically it includes lib/PHPUnit_Akelos which registers the autoloader and includes the config-file (test/fixtures/config/).21 This TestSuite has its own script (scripts/test_runner.php) to run your tests. Basically it includes lib/PHPUnit_Akelos which registers the autoloader and includes the config-file (test/fixtures/config/). 22 22 Addionally it creates TestSuites from directories or files on-the-fly. 23 23 24 script /test_runner.php24 scripts/test_runner.php 25 25 26 will print a help message. 26 will print a help message. 27 27 28 28 Try 29 29 30 script /test_runner.php -v examples/30 scripts/test_runner.php -v examples/ 31 31 32 from the root-folder of *this* package. Study these examples, hopefully they're quite self-explanatory. Some of the examples rely on fixtures (an installer f.i.) you can find in tests/fixtures/. 32 from the root-folder of *this* package. The installer should place a shortcut 33 34 script/phpunit_testsuite.php ... 35 36 in your app-base dir. 37 38 Study these examples, hopefully they're quite self-explanatory. Some of the examples rely on fixtures (an installer f.i.) you can find in tests/fixtures/. 33 39 34 40 branches/kaste/PHPUnit_TestSuite/examples/ModelTest.php
r620 r916 1 1 <?php 2 # we add a nfolder to the search-path of the autoloader, because this plugin has its own fixtures-folder.2 # we add a folder to the search-path of the autoloader, because this plugin has its own fixtures-folder. 3 3 # usually you don't need this, as long as you use the standard-folders; i.e. test/fixtures/app/* and app/* 4 4 PHPUnit_Akelos_autoload::addFolder(AK_PHPUNIT_TESTSUITE_FIXTURES); … … 7 7 { 8 8 9 function test UseModel()9 function testBasicUsageToIncludeAModel() 10 10 { 11 11 list($Person,$People) = $this->useModel('Person'); … … 23 23 } 24 24 25 function testGenerateTheModelAndTheTableOnTheFly ()25 function testGenerateTheModelAndTheTableOnTheFlyAndGenerateSomeRecords() 26 26 { 27 27 # if we hadn't neither an Artist-Model nor an Artist-installer … … 33 33 $Super = $this->createArtist('name: Supertramp, tag: super-goofy'); 34 34 $this->assertEquals('Supertramp', $Super->name); 35 # since this is a comma-sep erated list, escape a <,> with <\,> in your strings35 # since this is a comma-separated list, escape a <,> with <\,> in your strings 36 36 37 # the given data will be merged with the array returned by <defaultArtist()>37 # the given data will be merged with the array returned by the method <defaultArtist()> below 38 38 $Duran = $this->createArtist('name: Duran Duran'); 39 39 $this->assertEquals('so-so',$Duran->tag); branches/kaste/PHPUnit_TestSuite/lib/PHPUnit_Controller_TestCase.php
r618 r916 1 1 <?php 2 2 3 abstract class PHPUnit_Controller_TestCase extends PHPUnit_ Framework_TestCase3 abstract class PHPUnit_Controller_TestCase extends PHPUnit_Model_TestCase 4 4 { 5 5 var $controller_name; … … 22 22 } 23 23 24 function get($action,$options=array())24 function process($request_type,$action,$options) 25 25 { 26 26 $this->action_name = $action; 27 27 $this->addExpectationsDependendOnActionName($action); 28 28 29 $Request = $this->createRequest( 'get',$action,$options);29 $Request = $this->createRequest($request_type,$action,$options); 30 30 $Response = $this->createResponse(); 31 31 $Controller = $this->createController($this->controller_name); … … 36 36 } 37 37 38 function get($action,$options=array()) 39 { 40 $this->process('get',$action,$options); 41 } 42 38 43 function post($action,$options=array()) 39 44 { 40 return $this->createRequest('post',$action,$options);45 $this->process('post',$action,$options); 41 46 } 42 47 branches/kaste/PHPUnit_TestSuite/lib/PHPUnit_Model_TestCase.php
r617 r916 9 9 * ->useModel('Person') 10 10 * will look for an installer-file <person_installer.php> and use it for creating the table. 11 * It will include the Person-model or gener tae an empty/default model if none is found in the include path.12 * An instance of the model can found at $this->Person. After all it will look for a fixture named11 * It will include the Person-model or generate an empty/default model if none is found in the include path. 12 * An instance of the model can be found at $this->Person. After all it will look for a fixture named 13 13 * <people.yaml> in the path and create the records/rows in the database. A copy of this data can be found 14 14 * at $this->People as an associative array. 15 * Additionally it returns the instance and the fixture-data, so you can do15 * It returns the instance and the fixture-data, so you can do 16 16 * list($Person,$People) = $this->useModel('Person'); 17 17 * and use these local variables. … … 20 20 * will instead of using an installer-file simply use the columns provided. I.e. it will drop and then create 21 21 * the table <people> with the columns 'id' and 'name'. In fact the table-definition can be the same as in any 22 * installer, so you can really quickly prototype your st aff.22 * installer, so you can really quickly prototype your stuff. 23 23 * 24 24 * branches/kaste/PHPUnit_TestSuite/tests/lib/ExamplesTestSuite.php
r619 r916 10 10 11 11 $suite = new ExamplesTestSuite(AkInflector::titleize($class_name)); 12 $path = dirname(dirname( __FILE__)).DIRECTORY_SEPARATOR.$test_folder;12 $path = dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.$test_folder; 13 13 14 14 $directory = new PHPUnit_Runner_IncludePathTestCollector(array($path)); branches/kaste/PHPUnit_TestSuite/tests/lib/TestModelTest.php
r620 r916 21 21 $this->assertTrue(class_exists('UnusualName',false)); 22 22 23 #we need a table before we can instantiate a ActiveRecord23 #we need a table before we can instantiate an ActiveRecord 24 24 $this->createTable('UnusualName','id,title'); 25 25 $this->assertType('ActiveRecord',new UnusualName());
