com phpruntests: Reformatted to conform to PEAR coding standard.: tests/testcase/rtCleanExecutionTest.php tests/testcase/rtPhpRunnerTest.php
tests/testcase/rtPhpTestFileTest.php tests/testcase/rtPhpTestTest.php tests/testcase/rtSkipIfExecutionTest.php
tests/testcase/rtTestConfigurationTest.php tests/testcase/rtTestDifferenceTest.php tests/testcase/rtTestExecutionTest.php
tests/testcase/rtTestOutputWriterTest.php tests/testcase/rtTestResultsTest.p

From: Date: Wed, 22 Apr 2009 09:14:51 +0000
Subject: com phpruntests: Reformatted to conform to PEAR coding standard.: tests/testcase/rtCleanExecutionTest.php tests/testcase/rtPhpRunnerTest.php
tests/testcase/rtPhpTestFileTest.php tests/testcase/rtPhpTestTest.php tests/testcase/rtSkipIfExecutionTest.php
tests/testcase/rtTestConfigurationTest.php tests/testcase/rtTestDifferenceTest.php tests/testcase/rtTestExecutionTest.php
tests/testcase/rtTestOutputWriterTest.php tests/testcase/rtTestResultsTest.p
Groups: php.qa 
Request: Send a blank email to php-qa+get-66540@lists.php.net to get a copy of this message
Commit: 63ac7cf6d46f6697eb721ec15b15f751072dc093 Author: Stefan Priebsch <spriebsch@php.net> Wed, 22 Apr 2009 09:14:51 +0000 Parents: e552dcc9d8188cd6f4d36c60f0bbf054046f1f24 Branches: master Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=63ac7cf6d46f6697eb721ec15b15f751072dc093 Log: Reformatted to conform to PEAR coding standard. Changed paths: M tests/testcase/rtCleanExecutionTest.php M tests/testcase/rtPhpRunnerTest.php M tests/testcase/rtPhpTestFileTest.php M tests/testcase/rtPhpTestTest.php M tests/testcase/rtSkipIfExecutionTest.php M tests/testcase/rtTestConfigurationTest.php M tests/testcase/rtTestDifferenceTest.php M tests/testcase/rtTestExecutionTest.php M tests/testcase/rtTestOutputWriterTest.php M tests/testcase/rtTestResultsTest.php

diff --git a/tests/testcase/rtCleanExecutionTest.php b/tests/testcase/rtCleanExecutionTest.php index 1c435c5..5f20a5e 100644 --- a/tests/testcase/rtCleanExecutionTest.php +++ b/tests/testcase/rtCleanExecutionTest.php @@ -1,79 +1,81 @@ <?php require_once 'PHPUnit/Framework.php'; - require_once dirname(__FILE__) . '../../../src/rtAutoload.php'; +require_once dirname(__FILE__) . '../../../src/rtAutoload.php'; - - class rtCleanExecutionTest extends PHPUnit_Framework_TestCase - { +class rtCleanExecutionTest extends PHPUnit_Framework_TestCase +{ private $path_to_tests; private $sample_test; private $sample_fail; - - public function setUp() { - $this->php = trim(shell_exec("which php")); - - - $this->path_to_tests = realpath(dirname(__FILE__) . '/../../phpt-tests'); - $this->sample_test = $this->path_to_tests . '/sample_clean.phpt'; - $this->sample_fail = $this->path_to_tests . '/sample_clean_fail.phpt'; - - + + public function setUp() + { + $this->php = trim(shell_exec("which php")); + + $this->path_to_tests = realpath(dirname(__FILE__) . '/../../phpt-tests'); + $this->sample_test = $this->path_to_tests . '/sample_clean.phpt'; + $this->sample_fail = $this->path_to_tests . '/sample_clean_fail.phpt'; } - - public function tearDown() { - @unlink($this->path-to_tests. '/sample_clean.clean.php'); - @unlink($this->path-to_tests. '/phpt-tests/sample_clean_fail.clean.php'); - @unlink($this->path-to_tests. '/cleantest.tmp'); + + public function tearDown() + { + @unlink($this->path-to_tests . '/sample_clean.clean.php'); + @unlink($this->path-to_tests . '/phpt-tests/sample_clean_fail.clean.php'); + @unlink($this->path-to_tests . '/cleantest.tmp'); } - - public function testFileRun() { - //Create a new test configuration - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_test)); - $config->configure(); - - //Retrieve the array of test file names - $testFiles = $config->getSetting('TestFiles'); - - //Read the test file - $testFile =new rtPhpTestFile(); - $testFile->doRead($testFiles[0]); - $testFile->normaliseLineEndings(); - - //Create a new test case - $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config); - - //Setup and set the local environment for the test case - $testCase->executeTest($config); - - //Check that the temp file has been removed - $fileName = $this->path_to_tests. '/phpt-tests/cleantest.tmp'; - $this->assertFalse(file_exists($fileName)); + + public function testFileRun() + { + //Create a new test configuration + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_test)); + $config->configure(); + + //Retrieve the array of test file names + $testFiles = $config->getSetting('TestFiles'); + + //Read the test file + $testFile = new rtPhpTestFile(); + $testFile->doRead($testFiles[0]); + $testFile->normaliseLineEndings(); + + //Create a new test case + $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config); + + //Setup and set the local environment for the test case + $testCase->executeTest($config); + + //Check that the temp file has been removed + $fileName = $this->path_to_tests . '/phpt-tests/cleantest.tmp'; + + $this->assertFalse(file_exists($fileName)); } - - public function testFailedClean() { - //Create a new test configuration - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_fail)); - $config->configure(); - - //Retrieve the array of test file names - $testFiles = $config->getSetting('TestFiles'); - - //Read the test file - $testFile =new rtPhpTestFile(); - $testFile->doRead($testFiles[0]); - $testFile->normaliseLineEndings(); - - //Create a new test case - $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(),$testFile->getSectionHeadings(), $config); - - //Setup and set the local environment for the test case - $testCase->executeTest($config); - - //Check that the temp file has been removed - $fileName = $this->path_to_tests. '/cleantest.tmp'; - $this->assertTrue(file_exists($fileName)); + + public function testFailedClean() + { + //Create a new test configuration + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_fail)); + $config->configure(); + + //Retrieve the array of test file names + $testFiles = $config->getSetting('TestFiles'); + + //Read the test file + $testFile = new rtPhpTestFile(); + $testFile->doRead($testFiles[0]); + $testFile->normaliseLineEndings(); + + //Create a new test case + $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(),$testFile->getSectionHeadings(), $config); + + //Setup and set the local environment for the test case + $testCase->executeTest($config); + + //Check that the temp file has been removed + $fileName = $this->path_to_tests . '/cleantest.tmp'; + + $this->assertTrue(file_exists($fileName)); } - } +} -?> \ No newline at end of file +?> diff --git a/tests/testcase/rtPhpRunnerTest.php b/tests/testcase/rtPhpRunnerTest.php index 7936c97..6807fad 100644 --- a/tests/testcase/rtPhpRunnerTest.php +++ b/tests/testcase/rtPhpRunnerTest.php @@ -1,45 +1,42 @@ <?php - require_once 'PHPUnit/Framework.php'; - require_once dirname(__FILE__) . '../../../src/rtAutoload.php'; - -class rtPhpRunnerTest extends PHPUnit_Framework_TestCase { - - public function setUp() { - $this->php = trim(shell_exec("which php")); - $fh = fopen('/tmp/test.php', 'w'); - fwrite($fh, '<?php echo "hello world"; ?>'); - fclose($fh); - - $fh = fopen('/tmp/test2.php', 'w'); - fwrite($fh, '<?php echo stream_get_contents(STDIN); ?>'); - fclose($fh); - - } - - public function tearDown() { - unlink('/tmp/test.php'); - unlink('/tmp/test2.php'); - } - - public function testSimple() { - $PhpRunner = new rtPhpRunner($this->php.' -n /tmp/test.php 2>&1', - array(), - '/tmp'); - - - $this->assertEquals("hello world", $PhpRunner->runphp()); - } - - public function testStdin() { - $PhpRunner = new rtPhpRunner($this->php.' -n /tmp/test2.php 2>&1', - array(), - '/tmp', - 'hello'); - - $this->assertEquals("hello", $PhpRunner->runphp()); - - } +require_once 'PHPUnit/Framework.php'; +require_once dirname(__FILE__) . '../../../src/rtAutoload.php'; + +class rtPhpRunnerTest extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->php = trim(shell_exec("which php")); + + $fh = fopen('/tmp/test.php', 'w'); + fwrite($fh, '<?php echo "hello world"; ?>'); + fclose($fh); + + $fh = fopen('/tmp/test2.php', 'w'); + fwrite($fh, '<?php echo stream_get_contents(STDIN); ?>'); + fclose($fh); + } + + public function tearDown() + { + unlink('/tmp/test.php'); + unlink('/tmp/test2.php'); + } + + public function testSimple() + { + $PhpRunner = new rtPhpRunner($this->php . ' -n /tmp/test.php 2>&1', array(), '/tmp'); + + $this->assertEquals("hello world", $PhpRunner->runphp()); + } + + public function testStdin() + { + $PhpRunner = new rtPhpRunner($this->php .' -n /tmp/test2.php 2>&1', array(), '/tmp', 'hello'); + + $this->assertEquals("hello", $PhpRunner->runphp()); + } } -?> \ No newline at end of file +?> diff --git a/tests/testcase/rtPhpTestFileTest.php b/tests/testcase/rtPhpTestFileTest.php index c587a81..d21cc86 100644 --- a/tests/testcase/rtPhpTestFileTest.php +++ b/tests/testcase/rtPhpTestFileTest.php @@ -1,75 +1,77 @@ <?php + require_once 'PHPUnit/Framework.php'; require_once dirname(__FILE__) . '../../../src/rtAutoload.php'; +class rtPhpTestFileTest extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->path_to_tests = realpath(dirname(__FILE__) . '/../../phpt-tests'); + $this->sample_test = $this->path_to_tests . '/sample_test.phpt'; + $this->sample_extra_char = $this->path_to_tests. '/sample_extra_char.phpt'; + $this->sample_windows_test = $this->path_to_tests . '/sample_windows_test.phpt'; + } + + public function testCreateInstance() + { + $testFile = new rtPhpTestFile(); - class rtPhpTestFileTest extends PHPUnit_Framework_TestCase { - - public function setUp() { - $this->path_to_tests = realpath(dirname(__FILE__) . '/../../phpt-tests'); - $this->sample_test = $this->path_to_tests . '/sample_test.phpt'; - $this->sample_extra_char = $this->path_to_tests. '/sample_extra_char.phpt'; - $this->sample_windows_test = $this->path_to_tests . '/sample_windows_test.phpt'; + $this->assertTrue(is_object($testFile)); } - - - public function testCreateInstance() { - $testFile = new rtPhpTestFile(); - $this->assertTrue(is_object($testFile)); - } - - - public function testReadGoodFile() { - $testFile = new rtPhpTestFile(); - $testFile->doRead($this->sample_test); - $testFile->normaliseLineEndings(); - $fileArray = $testFile->getContents(); - $this->assertEquals('TEST', $fileArray[0]); - - $this->assertEquals($this->path_to_tests."/sample_test", $testFile->getTestName()); - } + public function testReadGoodFile() + { + $testFile = new rtPhpTestFile(); + $testFile->doRead($this->sample_test); + $testFile->normaliseLineEndings(); + $fileArray = $testFile->getContents(); + $this->assertEquals('TEST', $fileArray[0]); + + $this->assertEquals($this->path_to_tests."/sample_test", $testFile->getTestName()); + } - public function testWindowsLineEndings() { - $testFile = new rtPhpTestFile(); - $testFile->doRead($this->sample_windows_test); - $testFile->normaliseLineEndings(); - $fileArray = $testFile->getContents(); - $fileString = implode(' ', $fileArray); - - $unmodified = file_get_contents($this->sample_windows_test); - - //Check that there are windows line endings in the original - $this->assertEquals(preg_match('/\r\n/', $unmodified), 1); - - //..and that they have been successfully removed - $this->assertEquals(preg_match("/\r\n/", $fileString), 0); + public function testWindowsLineEndings() + { + $testFile = new rtPhpTestFile(); + $testFile->doRead($this->sample_windows_test); + $testFile->normaliseLineEndings(); + $fileArray = $testFile->getContents(); + $fileString = implode(' ', $fileArray); + + $unmodified = file_get_contents($this->sample_windows_test); + + //Check that there are windows line endings in the original + $this->assertEquals(preg_match('/\r\n/', $unmodified), 1); + + //..and that they have been successfully removed + $this->assertEquals(preg_match("/\r\n/", $fileString), 0); } - public function testLinuxLineEndings() { - $testFile = new rtPhpTestFile(); - $testFile->doRead($this->sample_test); - $testFile->normaliseLineEndings(); - $fileArray = $testFile->getContents(); - $fileString = implode(' ', $fileArray); - - $unmodified = file_get_contents($this->sample_test); - - //Check that there are windows line endings in the original - $this->assertEquals(preg_match('/\n/', $unmodified), 1); - - //..and that they have been successfully removed - $this->assertEquals(preg_match("/\n/", $fileString), 0); + public function testLinuxLineEndings() + { + $testFile = new rtPhpTestFile(); + $testFile->doRead($this->sample_test); + $testFile->normaliseLineEndings(); + $fileArray = $testFile->getContents(); + $fileString = implode(' ', $fileArray); + + $unmodified = file_get_contents($this->sample_test); + + //Check that there are windows line endings in the original + $this->assertEquals(preg_match('/\n/', $unmodified), 1); + + //..and that they have been successfully removed + $this->assertEquals(preg_match("/\n/", $fileString), 0); } - public function testPreconditionCall() { - $testFile = new rtPhpTestFile(); - $testFile->doRead($this->sample_test); - $testFile->normaliseLineEndings(); - $this->assertTrue($testFile->arePreConditionsMet()); - + public function testPreconditionCall() + { + $testFile = new rtPhpTestFile(); + $testFile->doRead($this->sample_test); + $testFile->normaliseLineEndings(); + + $this->assertTrue($testFile->arePreConditionsMet()); } - - } -?> \ No newline at end of file +?> diff --git a/tests/testcase/rtPhpTestTest.php b/tests/testcase/rtPhpTestTest.php index 20468b7..0dd36a4 100644 --- a/tests/testcase/rtPhpTestTest.php +++ b/tests/testcase/rtPhpTestTest.php @@ -1,41 +1,44 @@ <?php + require_once 'PHPUnit/Framework.php'; require_once dirname(__FILE__) . '../../../src/rtAutoload.php'; -class rtPhpTestTest extends PHPUnit_Framework_TestCase { - - public function setUp() { - $this->testCase = array ( - 'TEST', - 'This is a test', - 'FILE', - '<?php', - ' echo "hello world"; ', - '?>', - 'EXPECTF', - 'hello world', - ); - } - - public function testCreateInstance() { - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe', 'test.phpt')); - $config->configure(); - - $test = new rtPhpTest($this->testCase, 'nameOfTest', array('TEST', 'FILE', 'EXPECTF'), $config); - $this->assertEquals('rtPhpTest', get_class($test)); - - } - - public function testSections() { - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe', 'test.phpt')); - $config->configure(); - - $test = new rtPhpTest($this->testCase, 'nameOfTest', array('TEST', 'FILE', 'EXPECTF'), $config); - $this->assertEquals('rtTestHeaderSection', get_class($test->getSection('TEST'))); - $this->assertEquals('rtFileSection', get_class($test->getSection('FILE'))); - $this->assertEquals('rtExpectFSection', get_class($test->getSection('EXPECTF'))); - } - - +class rtPhpTestTest extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->testCase = array ( + 'TEST', + 'This is a test', + 'FILE', + '<?php', + ' echo "hello world"; ', + '?>', + 'EXPECTF', + 'hello world', + ); + } + + public function testCreateInstance() + { + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe', 'test.phpt')); + $config->configure(); + + $test = new rtPhpTest($this->testCase, 'nameOfTest', array('TEST', 'FILE', 'EXPECTF'), $config); + + $this->assertEquals('rtPhpTest', get_class($test)); + } + + public function testSections() + { + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe', 'test.phpt')); + $config->configure(); + + $test = new rtPhpTest($this->testCase, 'nameOfTest', array('TEST', 'FILE', 'EXPECTF'), $config); + + $this->assertEquals('rtTestHeaderSection', get_class($test->getSection('TEST'))); + $this->assertEquals('rtFileSection', get_class($test->getSection('FILE'))); + $this->assertEquals('rtExpectFSection', get_class($test->getSection('EXPECTF'))); + } } -?> \ No newline at end of file +?> diff --git a/tests/testcase/rtSkipIfExecutionTest.php b/tests/testcase/rtSkipIfExecutionTest.php index 71f5887..337e269 100644 --- a/tests/testcase/rtSkipIfExecutionTest.php +++ b/tests/testcase/rtSkipIfExecutionTest.php @@ -1,45 +1,46 @@ <?php require_once 'PHPUnit/Framework.php'; - require_once dirname(__FILE__) . '../../../src/rtAutoload.php'; +require_once dirname(__FILE__) . '../../../src/rtAutoload.php'; - - class rtSkipIfExecutionTest extends PHPUnit_Framework_TestCase - { +class rtSkipIfExecutionTest extends PHPUnit_Framework_TestCase +{ private $path_to_tests; - - public function setUp() { - $this->php = trim(shell_exec("which php")); - $path_to_tests = realpath(dirname(__FILE__) . '/../../phpt-tests'); - $this->sample_test = $path_to_tests . '/sample_skipif.phpt'; + + public function setUp() + { + $this->php = trim(shell_exec("which php")); + $path_to_tests = realpath(dirname(__FILE__) . '/../../phpt-tests'); + $this->sample_test = $path_to_tests . '/sample_skipif.phpt'; } - - public function tearDown() { - @unlink($this->path_to_tests. '/sample_skipif.skipif.php'); + + public function tearDown() + { + @unlink($this->path_to_tests. '/sample_skipif.skipif.php'); } - - public function testFileRun() { - //Create a new test configuration - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_test)); - $config->configure(); - - //Retrieve the array of test file names - $testFiles = $config->getSetting('TestFiles'); - - //Read the test file - $testFile =new rtPhpTestFile(); - $testFile->doRead($testFiles[0]); - $testFile->normaliseLineEndings(); - - //Create a new test case - $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config); - - //Setup and set the local environment for the test case - $testCase->executeTest($config); - - //Check that the test has been skipped - $this->assertTrue(array_key_exists('skip', $testCase->getStatus())); + + public function testFileRun() + { + //Create a new test configuration + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_test)); + $config->configure(); + + //Retrieve the array of test file names + $testFiles = $config->getSetting('TestFiles'); + + //Read the test file + $testFile =new rtPhpTestFile(); + $testFile->doRead($testFiles[0]); + $testFile->normaliseLineEndings(); + + //Create a new test case + $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config); + + //Setup and set the local environment for the test case + $testCase->executeTest($config); + + //Check that the test has been skipped + $this->assertTrue(array_key_exists('skip', $testCase->getStatus())); } - } - -?> \ No newline at end of file +} +?> diff --git a/tests/testcase/rtTestConfigurationTest.php b/tests/testcase/rtTestConfigurationTest.php index eb3f33f..a22f412 100644 --- a/tests/testcase/rtTestConfigurationTest.php +++ b/tests/testcase/rtTestConfigurationTest.php @@ -1,54 +1,63 @@ <?php + require_once 'PHPUnit/Framework.php'; require_once dirname(__FILE__) . '../../../src/rtAutoload.php'; -class rtTestConfigurationTest extends PHPUnit_Framework_TestCase { +class rtTestConfigurationTest extends PHPUnit_Framework_TestCase +{ + private $sections; + + public function setUp() + { + $this->sections['ARGS'] = new rtArgsSection('ARGS',array('-vvv -a value -1111 -2 -v')); + $this->sections['ENV'] = new rtEnvSection('ENV',array('env1 = ENV1', 'env2=ENV2')); + $this->sections['INI'] = new rtIniSection('INI',array('error_reporting=E_ALL | E_STRICT | E_DEPRECATED', 'assert.active = 1')); + } + + public function testCreateInstance() + { + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe', 'test.phpt')); + $config->configure(); - private $sections; + $testConfiguration = new rtTestConfiguration($config, $this->sections); - public function setUp() { - $this->sections['ARGS'] = new rtArgsSection('ARGS',array('-vvv -a value -1111 -2 -v')); - $this->sections['ENV'] = new rtEnvSection('ENV',array('env1 = ENV1', 'env2=ENV2')); - $this->sections['INI'] = new rtIniSection('INI',array('error_reporting=E_ALL | E_STRICT | E_DEPRECATED', 'assert.active = 1')); - } + $this->assertEquals('rtTestConfiguration', get_class($testConfiguration)); + } - public function testCreateInstance() { - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe', 'test.phpt')); - $config->configure(); + public function testEnv() + { + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe', 'test.phpt')); + $config->configure(); - $testConfiguration = new rtTestConfiguration($config, $this->sections); + $testConfiguration = new rtTestConfiguration($config, $this->sections); - $this->assertEquals('rtTestConfiguration', get_class($testConfiguration)); - } + $envVars = $testConfiguration->getEnvironmentVariables(); - public function testEnv() { - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe', 'test.phpt')); - $config->configure(); + $this->assertEquals('ENV1', $envVars['env1']); + } - $testConfiguration = new rtTestConfiguration($config, $this->sections); + public function testArgs() + { + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe', 'test.phpt')); + $config->configure(); - $envVars = $testConfiguration->getEnvironmentVariables(); - $this->assertEquals('ENV1', $envVars['env1']); - } + $testConfiguration = new rtTestConfiguration($config, $this->sections); - public function testArgs() { - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe', 'test.phpt')); - $config->configure(); + $args = $testConfiguration->getTestCommandLineArguments(); - $testConfiguration = new rtTestConfiguration($config, $this->sections); + $this->assertEquals('-- -vvv -a value -1111 -2 -v', $args); + } - $args = $testConfiguration->getTestCommandLineArguments(); - $this->assertEquals('-- -vvv -a value -1111 -2 -v', $args); - } + public function testIni() + { + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe', 'test.phpt')); + $config->configure(); - public function testIni() { - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe', 'test.phpt')); - $config->configure(); + $testConfiguration = new rtTestConfiguration($config, $this->sections); + $phpargs = $testConfiguration->getPhpCommandLineArguments(); + $match = preg_match("/-d \"error_reporting=E_ALL | E_STRICT | E_DEPRECATED\" -d \"assert.active=1\"/",$phpargs); - $testConfiguration = new rtTestConfiguration($config, $this->sections); - $phpargs = $testConfiguration->getPhpCommandLineArguments(); - $match = preg_match("/-d \"error_reporting=E_ALL | E_STRICT | E_DEPRECATED\" -d \"assert.active=1\"/",$phpargs); - $this->assertEquals(1, $match); - } + $this->assertEquals(1, $match); + } } -?> \ No newline at end of file +?> diff --git a/tests/testcase/rtTestDifferenceTest.php b/tests/testcase/rtTestDifferenceTest.php index f8e6463..68d9212 100644 --- a/tests/testcase/rtTestDifferenceTest.php +++ b/tests/testcase/rtTestDifferenceTest.php @@ -1,20 +1,18 @@ <?php - require_once 'PHPUnit/Framework.php'; - require_once dirname(__FILE__) . '../../../src/rtAutoload.php'; - +require_once dirname(__FILE__) . '../../../src/rtAutoload.php'; - class rtTestDifferenceTest extends PHPUnit_Framework_TestCase { - - public function testTestDifference() { - - $expectSection = new rtExpectSection('EXPECT',array('Hello World')); - $testDifference = new rtTestDifference($expectSection, 'Hello Dolly'); - - $difference = $testDifference->getDifference(); - $this->assertEquals('001+ Hello Dolly', $difference[0]); - $this->assertEquals('001- Hello World', $difference[1]); +class rtTestDifferenceTest extends PHPUnit_Framework_TestCase +{ + public function testTestDifference() + { + $expectSection = new rtExpectSection('EXPECT',array('Hello World')); + $testDifference = new rtTestDifference($expectSection, 'Hello Dolly'); + + $difference = $testDifference->getDifference(); + $this->assertEquals('001+ Hello Dolly', $difference[0]); + $this->assertEquals('001- Hello World', $difference[1]); } - } -?> \ No newline at end of file +} +?> diff --git a/tests/testcase/rtTestExecutionTest.php b/tests/testcase/rtTestExecutionTest.php index c49da5b..db001a5 100644 --- a/tests/testcase/rtTestExecutionTest.php +++ b/tests/testcase/rtTestExecutionTest.php @@ -1,141 +1,135 @@ <?php - require_once 'PHPUnit/Framework.php'; - require_once dirname(__FILE__) . '../../../src/rtAutoload.php'; +require_once 'PHPUnit/Framework.php'; +require_once dirname(__FILE__) . '../../../src/rtAutoload.php'; - - class rtTestExecutionTest extends PHPUnit_Framework_TestCase - { +class rtTestExecutionTest extends PHPUnit_Framework_TestCase +{ private $path_to_tests; private $sample_test; private $sample_expectf; private $sample_expecregex; private $php; - - public function setUp() { - $this->php = trim(shell_exec("which php")); - $this->path_to_tests = realpath(dirname(__FILE__) . '/../../phpt-tests'); - $this->sample_test = $this->path_to_tests . '/sample_test.phpt'; - $this->sample_expectf = $this->path_to_tests . '/sample_expectf.phpt'; - $this->sample_expectregex = $this->path_to_tests . '/sample_expectregex.phpt'; - + + public function setUp() + { + $this->php = trim(shell_exec("which php")); + $this->path_to_tests = realpath(dirname(__FILE__) . '/../../phpt-tests'); + $this->sample_test = $this->path_to_tests . '/sample_test.phpt'; + $this->sample_expectf = $this->path_to_tests . '/sample_expectf.phpt'; + $this->sample_expectregex = $this->path_to_tests . '/sample_expectregex.phpt'; } - - public function tearDown() { - @unlink($this->path_to_tests . '/sample_test.php'); - @unlink($this->path_to_tests. '/sample_expectf.php'); - @unlink($this->path_to_tests. '/sample_expectregex.php'); + + public function tearDown() + { + @unlink($this->path_to_tests . '/sample_test.php'); + @unlink($this->path_to_tests . '/sample_expectf.php'); + @unlink($this->path_to_tests . '/sample_expectregex.php'); } - - public function testFileRun() { - - //Create a new test configuration - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_test)); - $config->configure(); - - //Retrieve the array of test file names - $testFiles = $config->getSetting('TestFiles'); - - //Read the test file - $testFile =new rtPhpTestFile(); - $testFile->doRead($testFiles[0]); - $testFile->normaliseLineEndings(); - - //Create a new test case - $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(),$config); - - //Setup and set the local environment for the test case - $testCase->executeTest($config); - - //Grab the output - $this->assertEquals('Hello world', trim($testCase->getOutput())); - + + public function testFileRun() + { + //Create a new test configuration + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_test)); + $config->configure(); + + //Retrieve the array of test file names + $testFiles = $config->getSetting('TestFiles'); + + //Read the test file + $testFile =new rtPhpTestFile(); + $testFile->doRead($testFiles[0]); + $testFile->normaliseLineEndings(); + + //Create a new test case + $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(),$config); + + //Setup and set the local environment for the test case + $testCase->executeTest($config); + + //Grab the output + $this->assertEquals('Hello world', trim($testCase->getOutput())); } - - public function testFileRunAndCompare() { - - //Create a new test configuration - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_test)); - $config->configure(); - - //Retrieve the array of test file names - $testFiles = $config->getSetting('TestFiles'); - - //Read the test file - $testFile =new rtPhpTestFile(); - $testFile->doRead($testFiles[0]); - $testFile->normaliseLineEndings(); - - //Create a new test case - $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(),$config); - - //Setup and set the local environment for the test case - $testCase->executeTest($config); - - //check the output - $testCase->compareOutput(); - - //Check the exit status - $this->assertTrue(array_key_exists('pass', $testCase->getStatus())); - + + public function testFileRunAndCompare() + { + //Create a new test configuration + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_test)); + $config->configure(); + + //Retrieve the array of test file names + $testFiles = $config->getSetting('TestFiles'); + + //Read the test file + $testFile =new rtPhpTestFile(); + $testFile->doRead($testFiles[0]); + $testFile->normaliseLineEndings(); + + //Create a new test case + $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(),$config); + + //Setup and set the local environment for the test case + $testCase->executeTest($config); + + //check the output + $testCase->compareOutput(); + + //Check the exit status + $this->assertTrue(array_key_exists('pass', $testCase->getStatus())); } - - - public function testExpectFFileRunAndCompare() { - //Create a new test configuration - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_expectf)); - $config->configure(); - - //Retrieve the array of test file names - $testFiles = $config->getSetting('TestFiles'); - - //Read the test file - $testFile =new rtPhpTestFile(); - $testFile->doRead($testFiles[0]); - $testFile->normaliseLineEndings(); - - //Create a new test case - $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(),$testFile->getSectionHeadings(), $config); - - //Setup and set the local environment for the test case - $testCase->executeTest($config); - - //check the output - $testCase->compareOutput(); - - //Check the exit status - $this->assertTrue(array_key_exists('pass', $testCase->getStatus())); - + + public function testExpectFFileRunAndCompare() + { + //Create a new test configuration + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_expectf)); + $config->configure(); + + //Retrieve the array of test file names + $testFiles = $config->getSetting('TestFiles'); + + //Read the test file + $testFile =new rtPhpTestFile(); + $testFile->doRead($testFiles[0]); + $testFile->normaliseLineEndings(); + + //Create a new test case + $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(),$testFile->getSectionHeadings(), $config); + + //Setup and set the local environment for the test case + $testCase->executeTest($config); + + //check the output + $testCase->compareOutput(); + + //Check the exit status + $this->assertTrue(array_key_exists('pass', $testCase->getStatus())); } - - public function testExpectRegexFileRunAndCompare() { - //Create a new test configuration - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_expectregex)); - $config->configure(); - - //Retrieve the array of test file names - $testFiles = $config->getSetting('TestFiles'); - - //Read the test file - $testFile =new rtPhpTestFile(); - $testFile->doRead($testFiles[0]); - $testFile->normaliseLineEndings(); - - //Create a new test case - $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(),$testFile->getSectionHeadings(), $config); - - //Setup and set the local environment for the test case - $testCase->executeTest($config); - - //check the output - $testCase->compareOutput(); - - //Check the exit status - $this->assertTrue(array_key_exists('pass', $testCase->getStatus())); - + + public function testExpectRegexFileRunAndCompare() + { + //Create a new test configuration + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_expectregex)); + $config->configure(); + + //Retrieve the array of test file names + $testFiles = $config->getSetting('TestFiles'); + + //Read the test file + $testFile =new rtPhpTestFile(); + $testFile->doRead($testFiles[0]); + $testFile->normaliseLineEndings(); + + //Create a new test case + $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(),$testFile->getSectionHeadings(), $config); + + //Setup and set the local environment for the test case + $testCase->executeTest($config); + + //check the output + $testCase->compareOutput(); + + //Check the exit status + $this->assertTrue(array_key_exists('pass', $testCase->getStatus())); } - } - - - -?> \ No newline at end of file +} +?> diff --git a/tests/testcase/rtTestOutputWriterTest.php b/tests/testcase/rtTestOutputWriterTest.php index 6c1cb8c..04220d0 100644 --- a/tests/testcase/rtTestOutputWriterTest.php +++ b/tests/testcase/rtTestOutputWriterTest.php @@ -3,60 +3,56 @@ require_once 'PHPUnit/Framework.php'; require_once dirname(__FILE__) . '../../../src/rtAutoload.php'; - -class rtTestOutputWriterTest extends PHPUnit_Framework_TestCase { - - public function setUp() { - $this->php = trim(shell_exec("which php")); - $this->path_to_tests = realpath(dirname(__FILE__) . '/../../phpt-tests'); - $this->sample_test = $this->path_to_tests. '/sample_test.phpt'; - $this->sample_test_fail = $this->path_to_tests. '/sample_test_fail.phpt'; - $this->sample_skipif = $this->path_to_tests. '/sample_skipif.phpt'; - } - - public function tearDown() { - @unlink($this->sample_test = $this->path_to_tests. '/sample_test.php'); - @unlink($this->sample_test = $this->path_to_tests. '/sample_test.out'); - @unlink($this->sample_test = $this->path_to_tests. '/sample_test.exp'); - @unlink($this->sample_test = $this->path_to_tests. '/sample_test_fail.diff'); - @unlink($this->sample_test = $this->path_to_tests. '/sample_test_fail.exp'); - @unlink($this->sample_test = $this->path_to_tests. '/sample_test_fail.out'); - @unlink($this->sample_test = $this->path_to_tests. '/sample_test_fail.php'); - @unlink($this->sample_test = $this->path_to_tests. '/sample_skipif.skipif.php'); - @unlink($this->sample_test = $this->path_to_tests. '/sample_skipif.php'); - } - - public function testFailedTest() { - - //Create a new test configuration - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_test_fail)); - $config->configure(); - - //Retrieve the array of test file names - $testFiles = $config->getSetting('TestFiles'); - - //Read the test file - $testFile =new rtPhpTestFile(); - $testFile->doRead($testFiles[0]); - $testFile->normaliseLineEndings(); - - //Create a new test case - $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(),$config); - - //Setup and set the local environment for the test case - $testCase->executeTest($config); - - - - $results = new rtTestResults($testCase); - $results->processResults($testCase, $config); - - - $testOutputWriter = rtTestOutputWriter::getInstance(array($results), 'list'); - $this->assertEquals('rtTestOutputWriterList', get_class($testOutputWriter)); - - - } - +class rtTestOutputWriterTest extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->php = trim(shell_exec("which php")); + $this->path_to_tests = realpath(dirname(__FILE__) . '/../../phpt-tests'); + $this->sample_test = $this->path_to_tests . '/sample_test.phpt'; + $this->sample_test_fail = $this->path_to_tests . '/sample_test_fail.phpt'; + $this->sample_skipif = $this->path_to_tests . '/sample_skipif.phpt'; + } + + public function tearDown() + { + @unlink($this->sample_test = $this->path_to_tests . '/sample_test.php'); + @unlink($this->sample_test = $this->path_to_tests . '/sample_test.out'); + @unlink($this->sample_test = $this->path_to_tests . '/sample_test.exp'); + @unlink($this->sample_test = $this->path_to_tests . '/sample_test_fail.diff'); + @unlink($this->sample_test = $this->path_to_tests . '/sample_test_fail.exp'); + @unlink($this->sample_test = $this->path_to_tests . '/sample_test_fail.out'); + @unlink($this->sample_test = $this->path_to_tests . '/sample_test_fail.php'); + @unlink($this->sample_test = $this->path_to_tests . '/sample_skipif.skipif.php'); + @unlink($this->sample_test = $this->path_to_tests . '/sample_skipif.php'); + } + + public function testFailedTest() + { + //Create a new test configuration + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_test_fail)); + $config->configure(); + + //Retrieve the array of test file names + $testFiles = $config->getSetting('TestFiles'); + + //Read the test file + $testFile = new rtPhpTestFile(); + $testFile->doRead($testFiles[0]); + $testFile->normaliseLineEndings(); + + //Create a new test case + $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(),$config); + + //Setup and set the local environment for the test case + $testCase->executeTest($config); + + $results = new rtTestResults($testCase); + $results->processResults($testCase, $config); + + $testOutputWriter = rtTestOutputWriter::getInstance(array($results), 'list'); + + $this->assertEquals('rtTestOutputWriterList', get_class($testOutputWriter)); + } } -?> \ No newline at end of file +?> diff --git a/tests/testcase/rtTestResultsTest.php b/tests/testcase/rtTestResultsTest.php index 9c3c86b..160a5b9 100644 --- a/tests/testcase/rtTestResultsTest.php +++ b/tests/testcase/rtTestResultsTest.php @@ -1,268 +1,255 @@ <?php - require_once 'PHPUnit/Framework.php'; require_once dirname(__FILE__) . '../../../src/rtAutoload.php'; +class rtTestResultsTest extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->php = trim(shell_exec("which php")); + $this->path_to_tests = realpath(dirname(__FILE__) . '/../../phpt-tests'); + $this->sample_test = $this->path_to_tests. '/sample_test.phpt'; + $this->sample_test_fail = $this->path_to_tests. '/sample_test_fail.phpt'; + $this->sample_skipif = $this->path_to_tests. '/sample_skipif.phpt'; + $this->sample_clean = $this->path_to_tests. '/sample_clean.phpt'; + $this->sample_bork = $this->path_to_tests. '/sample_bork.phpt'; + } + + public function tearDown() + { + @unlink($this->sample_test = $this->path_to_tests. '/sample_test.php'); + @unlink($this->sample_test = $this->path_to_tests. '/sample_test.out'); + @unlink($this->sample_test = $this->path_to_tests. '/sample_test.exp'); + @unlink($this->sample_test = $this->path_to_tests. '/sample_test_fail.diff'); + @unlink($this->sample_test = $this->path_to_tests. '/sample_test_fail.exp'); + @unlink($this->sample_test = $this->path_to_tests. '/sample_test_fail.out'); + @unlink($this->sample_test = $this->path_to_tests. '/sample_test_fail.php'); + @unlink($this->sample_test = $this->path_to_tests. '/sample_skipif.skipif.php'); + @unlink($this->sample_test = $this->path_to_tests. '/sample_skipif.php'); + @unlink($this->sample_test = $this->path_to_tests. '/sample_clean.php'); + } + + public function testFileDelete() + { + //Create a new test configuration + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_test)); + $config->configure(); + + //Retrieve the array of test file names + $testFiles = $config->getSetting('TestFiles'); + + //Read the test file + $testFile =new rtPhpTestFile(); + $testFile->doRead($testFiles[0]); + $testFile->normaliseLineEndings(); + + //Create a new test case + $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(),$testFile->getSectionHeadings(), $config); + + //Setup and set the local environment for the test case + $testCase->executeTest($config); + + $fileName = $testFile->getTestName(). ".php"; + + $results = new rtTestResults($testCase); + $results->processResults($testCase, $config); + + $this->assertFalse(file_exists($fileName)); + } + + public function testFileSaveAll() + { + //Create a new test configuration + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_test, '--keep-all')); + $config->configure(); + + //Retrieve the array of test file names + $testFiles = $config->getSetting('TestFiles'); + + //Read the test file + $testFile =new rtPhpTestFile(); + $testFile->doRead($testFiles[0]); + $testFile->normaliseLineEndings(); + + //Create a new test case + $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(),$testFile->getSectionHeadings(), $config); + + //Setup and set the local environment for the test case + $testCase->executeTest($config); -class rtTestResultsTest extends PHPUnit_Framework_TestCase { - - public function setUp() { - $this->php = trim(shell_exec("which php")); - $this->path_to_tests = realpath(dirname(__FILE__) . '/../../phpt-tests'); - $this->sample_test = $this->path_to_tests. '/sample_test.phpt'; - $this->sample_test_fail = $this->path_to_tests. '/sample_test_fail.phpt'; - $this->sample_skipif = $this->path_to_tests. '/sample_skipif.phpt'; - $this->sample_clean = $this->path_to_tests. '/sample_clean.phpt'; - $this->sample_bork = $this->path_to_tests. '/sample_bork.phpt'; - } - - public function tearDown() { - @unlink($this->sample_test = $this->path_to_tests. '/sample_test.php'); - @unlink($this->sample_test = $this->path_to_tests. '/sample_test.out'); - @unlink($this->sample_test = $this->path_to_tests. '/sample_test.exp'); - @unlink($this->sample_test = $this->path_to_tests. '/sample_test_fail.diff'); - @unlink($this->sample_test = $this->path_to_tests. '/sample_test_fail.exp'); - @unlink($this->sample_test = $this->path_to_tests. '/sample_test_fail.out'); - @unlink($this->sample_test = $this->path_to_tests. '/sample_test_fail.php'); - @unlink($this->sample_test = $this->path_to_tests. '/sample_skipif.skipif.php'); - @unlink($this->sample_test = $this->path_to_tests. '/sample_skipif.php'); - @unlink($this->sample_test = $this->path_to_tests. '/sample_clean.php'); - } - - public function testFileDelete() { - - //Create a new test configuration - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_test)); - $config->configure(); - - //Retrieve the array of test file names - $testFiles = $config->getSetting('TestFiles'); - - //Read the test file - $testFile =new rtPhpTestFile(); - $testFile->doRead($testFiles[0]); - $testFile->normaliseLineEndings(); - - //Create a new test case - $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(),$testFile->getSectionHeadings(), $config); - - //Setup and set the local environment for the test case - $testCase->executeTest($config); - - - $fileName = $testFile->getTestName(). ".php"; - - $results = new rtTestResults($testCase); - $results->processResults($testCase, $config); - - - $this->assertFalse(file_exists($fileName)); - - } - - public function testFileSaveAll() { - - //Create a new test configuration - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_test, '--keep-all')); - $config->configure(); - - //Retrieve the array of test file names - $testFiles = $config->getSetting('TestFiles'); - - //Read the test file - $testFile =new rtPhpTestFile(); - $testFile->doRead($testFiles[0]); - $testFile->normaliseLineEndings(); - - //Create a new test case - $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(),$testFile->getSectionHeadings(), $config); - - //Setup and set the local environment for the test case - $testCase->executeTest($config); - - $fileName = $testFile->getTestName(). ".php"; - - $results = new rtTestResults($testCase); - $results->processResults($testCase, $config); - - $this->assertTrue(file_exists($fileName)); - - } - - public function testFileSavePHP() { - - //Create a new test configuration - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_test, '--keep-php')); - $config->configure(); - - //Retrieve the array of test file names - $testFiles = $config->getSetting('TestFiles'); - - //Read the test file - $testFile =new rtPhpTestFile(); - $testFile->doRead($testFiles[0]); - $testFile->normaliseLineEndings(); - - //Create a new test case - $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(),$testFile->getSectionHeadings(), $config); - - //Setup and set the local environment for the test case - $testCase->executeTest($config); - - - $fileName = $testFile->getTestName(). ".php"; - - $results = new rtTestResults($testCase); - $results->processResults($testCase, $config); - - $this->assertTrue(file_exists($fileName)); - - - } - - public function testFailedTest() { - - //Create a new test configuration - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_test_fail)); - $config->configure(); - - //Retrieve the array of test file names - $testFiles = $config->getSetting('TestFiles'); - - //Read the test file - $testFile =new rtPhpTestFile(); - $testFile->doRead($testFiles[0]); - $testFile->normaliseLineEndings(); - - //Create a new test case - $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(),$config); - - //Setup and set the local environment for the test case - $testCase->executeTest($config); - - - $testName = $testFile->getTestName(); - - $results = new rtTestResults($testCase); - $results->processResults($testCase, $config); - - $this->assertTrue(file_exists($testName.'.diff')); - $this->assertTrue(file_exists($testName.'.out')); - $this->assertTrue(file_exists($testName.'.exp')); - $this->assertTrue(file_exists($testName.'.php')); - - - } - - public function testSkippedTest() { - - //Create a new test configuration - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_skipif)); - $config->configure(); - - //Retrieve the array of test file names - $testFiles = $config->getSetting('TestFiles'); - - //Read the test file - $testFile =new rtPhpTestFile(); - $testFile->doRead($testFiles[0]); - $testFile->normaliseLineEndings(); - - //Create a new test case - $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(),$config); - - //Setup and set the local environment for the test case - $testCase->executeTest($config); - - $testName = $testFile->getTestName(); - - $results = new rtTestResults($testCase); - $results->processResults($testCase, $config); - - $this->assertFalse(file_exists($testName.'.skipif.php')); - $this->assertFalse(file_exists($testName.'.php')); - - - } - - public function testSkippedTestKeep() { - //Create a new test configuration - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_skipif, '--keep-all')); - $config->configure(); - - //Retrieve the array of test file names - $testFiles = $config->getSetting('TestFiles'); - - //Read the test file - $testFile =new rtPhpTestFile(); - $testFile->doRead($testFiles[0]); - $testFile->normaliseLineEndings(); - - //Create a new test case - $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(),$config); - - //Setup and set the local environment for the test case - $testCase->executeTest($config); - - - $testName = $testFile->getTestName(); - - $results = new rtTestResults($testCase); - $results->processResults($testCase, $config); - - - $this->assertTrue(file_exists($testName.'.skipif.php')); - } - - public function testCleanPass() { - //Create a new test configuration - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_clean)); - $config->configure(); - - //Retrieve the array of test file names - $testFiles = $config->getSetting('TestFiles'); - - //Read the test file - $testFile =new rtPhpTestFile(); - $testFile->doRead($testFiles[0]); - $testFile->normaliseLineEndings(); - - //Create a new test case - $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(),$config); - - //Setup and set the local environment for the test case - $testCase->executeTest($config); - - - $testName = $testFile->getTestName(); - - $results = new rtTestResults($testCase); - $results->processResults($testCase, $config); - $this->assertTrue(array_key_exists('pass', $results->getStatus())); - - } - - public function testBork() { - //Create a new test configuration - $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_bork)); - $config->configure(); - - //Retrieve the array of test file names - $testFiles = $config->getSetting('TestFiles'); - - //Read the test file - $testFile =new rtPhpTestFile(); - $testFile->doRead($testFiles[0]); - $testFile->normaliseLineEndings(); - - if(!$testFile->arePreConditionsMet()) { - - $results = new rtTestResults(null, "borked", $testFiles[0]); - $this->assertTrue(array_key_exists('bork', $results->getStatus())); - + $fileName = $testFile->getTestName(). ".php"; + + $results = new rtTestResults($testCase); + $results->processResults($testCase, $config); + + $this->assertTrue(file_exists($fileName)); + } + + public function testFileSavePHP() + { + //Create a new test configuration + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_test, '--keep-php')); + $config->configure(); + + //Retrieve the array of test file names + $testFiles = $config->getSetting('TestFiles'); + + //Read the test file + $testFile =new rtPhpTestFile(); + $testFile->doRead($testFiles[0]); + $testFile->normaliseLineEndings(); + + //Create a new test case + $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(),$testFile->getSectionHeadings(), $config); + + //Setup and set the local environment for the test case + $testCase->executeTest($config); + + $fileName = $testFile->getTestName(). ".php"; + + $results = new rtTestResults($testCase); + $results->processResults($testCase, $config); + + $this->assertTrue(file_exists($fileName)); } - } + public function testFailedTest() + { + //Create a new test configuration + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_test_fail)); + $config->configure(); + + //Retrieve the array of test file names + $testFiles = $config->getSetting('TestFiles'); + + //Read the test file + $testFile =new rtPhpTestFile(); + $testFile->doRead($testFiles[0]); + $testFile->normaliseLineEndings(); + + //Create a new test case + $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(),$config); + + //Setup and set the local environment for the test case + $testCase->executeTest($config); + + $testName = $testFile->getTestName(); + + $results = new rtTestResults($testCase); + $results->processResults($testCase, $config); + + $this->assertTrue(file_exists($testName.'.diff')); + $this->assertTrue(file_exists($testName.'.out')); + $this->assertTrue(file_exists($testName.'.exp')); + $this->assertTrue(file_exists($testName.'.php')); + } + + public function testSkippedTest() + { + //Create a new test configuration + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_skipif)); + $config->configure(); + + //Retrieve the array of test file names + $testFiles = $config->getSetting('TestFiles'); + + //Read the test file + $testFile =new rtPhpTestFile(); + $testFile->doRead($testFiles[0]); + $testFile->normaliseLineEndings(); + + //Create a new test case + $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(),$config); + + //Setup and set the local environment for the test case + $testCase->executeTest($config); + + $testName = $testFile->getTestName(); + + $results = new rtTestResults($testCase); + $results->processResults($testCase, $config); + + $this->assertFalse(file_exists($testName.'.skipif.php')); + $this->assertFalse(file_exists($testName.'.php')); + } + + public function testSkippedTestKeep() + { + //Create a new test configuration + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_skipif, '--keep-all')); + $config->configure(); + + //Retrieve the array of test file names + $testFiles = $config->getSetting('TestFiles'); + + //Read the test file + $testFile =new rtPhpTestFile(); + $testFile->doRead($testFiles[0]); + $testFile->normaliseLineEndings(); + + //Create a new test case + $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(),$config); + + //Setup and set the local environment for the test case + $testCase->executeTest($config); + + $testName = $testFile->getTestName(); + + $results = new rtTestResults($testCase); + $results->processResults($testCase, $config); + + $this->assertTrue(file_exists($testName.'.skipif.php')); + } + + public function testCleanPass() + { + //Create a new test configuration + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_clean)); + $config->configure(); + + //Retrieve the array of test file names + $testFiles = $config->getSetting('TestFiles'); + + //Read the test file + $testFile =new rtPhpTestFile(); + $testFile->doRead($testFiles[0]); + $testFile->normaliseLineEndings(); + + //Create a new test case + $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(),$config); + + //Setup and set the local environment for the test case + $testCase->executeTest($config); + + $testName = $testFile->getTestName(); + + $results = new rtTestResults($testCase); + $results->processResults($testCase, $config); + + $this->assertTrue(array_key_exists('pass', $results->getStatus())); + } + + public function testBork() + { + //Create a new test configuration + $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, $this->sample_bork)); + $config->configure(); + + //Retrieve the array of test file names + $testFiles = $config->getSetting('TestFiles'); + + //Read the test file + $testFile =new rtPhpTestFile(); + $testFile->doRead($testFiles[0]); + $testFile->normaliseLineEndings(); + + if(!$testFile->arePreConditionsMet()) { + + $results = new rtTestResults(null, "borked", $testFiles[0]); + + $this->assertTrue(array_key_exists('bork', $results->getStatus())); + } + } } -?> \ No newline at end of file +?>
« previous php.qa (#66540) next »