} catch (Exception $e) { $t->fail($e->getMessage()); } // START: check bootstrap class $t->diag('testing bootstrap file generation'); $t->ok(file_exists($bootstrapFile), 'bootstrap file was created'); $t->ok(_syntax_check($bootstrapFile), 'php syntax check of bootstrap file is ok'); // END: check bootstrap class // START: check base class $t->ok(file_exists($baseTestClass), 'generated base test class exists'); $t->ok(_syntax_check($baseTestClass), 'php syntax check of base test class is ok'); // END: check base class $t->ok(file_exists($allTestsFile), 'AllTests file is generated when it does not exist, although the skip_alltests option is set'); // START: check test class $t->ok(file_exists($testClass), 'generated unit test file exists'); $t->ok(_syntax_check($testClass), 'php syntax check is ok'); if (!($content = file_get_contents($testClass))) { $t->fail('could not load test file'); } $t->ok(strstr($content, "\$this->o = new sfPhpunitPluginTestClass()"), 'first test content check is ok'); $t->ok(strstr($content, "\$this->markTestIncomplete("), 'method stub is ok'); // custom template content should not exist in the generated content now $t->ok(!strstr($content, "This is a custom template"), 'task uses plugin templates'); $t->ok(strstr($content, "realpath(dirname(__FILE__).'/..')"), 'relative path is ok'); // END: check test class // copy a custom template // the next task should use this file and not the one in the plugin dir copy($customTemplateSource, $customTemplate); // -------------------------------------------- // 2. unit test generation (custom template test) // --------------------------------------------
$t->ok(_syntax_check($baseTestFile2), 'php syntax check of base test class is ok'); if (!($content = file_get_contents($baseTestFile2))) { $t->fail('could not load test file'); } $declaration = sprintf('abstract class %s extends sfBasePhpunitFunctionalTestCase', $baseClass); $t->ok(strstr($content, $declaration), 'class declaration in base test class is ok'); // END: check base class // START: check test class $t->diag('testing test class file generation'); $t->ok(file_exists($testFile2), 'created functional test file exists'); if (!($content = file_get_contents($testFile2))) { $t->fail('could not load test file'); } $declaration = sprintf('class %sTest extends %s', $module2 . 'Actions', $baseClass); $t->ok(strstr($content, $declaration), 'class declaration is ok'); $t->ok(_syntax_check($testFile), 'php syntax check is ok'); // END: check test class // -------------------------------------------- // 3.1 functional test generation (option test for "overwrite_alltests" and "overwrite_base_test") // -------------------------------------------- $t->diag('3. functional test generation is running'); // should not be overwritten now file_put_contents($allTestsFile, 'hello world'); file_put_contents($baseTestFile, 'hello you'); try { // take another module for this test $arguments = array($application, $module2); $options = array('overwrite'); // create functional test file // with default base class $task = new sfPhpunitCreateFunctionalTestTask($dispatcher, $formatter);