com phpruntests: new file external test - tests execution: tests/testcase/rtFileExternalExecutionTest.php
| From: | David Soria Parra | Date: | Tue, 09 Jun 2009 20:28:28 +0000 |
| Subject: | com phpruntests: new file external test - tests execution: tests/testcase/rtFileExternalExecutionTest.php | ||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-66421@lists.php.net to get a copy of this message | ||
Commit: 8de20dcfd7aaceff7f86d249ce76b925b7f3f1f7
Author: Zoe Slattery <zoe@php.net> Tue, 9 Jun 2009 20:28:28 +0000
Parents: 1c5019ba7482f1e5dc05c2267350a57e9f3d09cf
Branches: master
Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=8de20dcfd7aaceff7f86d249ce76b925b7f3f1f7
Log:
new file external test - tests execution
Changed paths:
A tests/testcase/rtFileExternalExecutionTest.php
Diff:
diff --git a/tests/testcase/rtFileExternalExecutionTest.php
b/tests/testcase/rtFileExternalExecutionTest.php
new file mode 100644
index 0000000..d1624db
--- /dev/null
+++ b/tests/testcase/rtFileExternalExecutionTest.php
@@ -0,0 +1,102 @@
+<?php
+
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '../../../src/rtAutoload.php';
+
+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_fileexternal.phpt';
+ $this->sample_fail1 = $this->path_to_tests . '/sample_fileexternal1.phpt';
+ $this->sample_fail2 = $this->path_to_tests . '/sample_fileexternal2.phpt';
+ }
+
+ public function tearDown()
+ {
+
+ }
+
+ 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
+ $status = new rtTestStatus($testFile->getTestName());
+ $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(),
$testFile->getSectionHeadings(), $config, $status);
+
+ //Setup and set the local environment for the test case
+ $testCase->executeTest($config);
+
+ //Check that the temp file has been removed
+ $this->assertTrue($testCase->getStatus()->getValue('pass'));
+
+ }
+
+ public function testFail1()
+ {
+ //Create a new test configuration
+ $config = rtRuntestsConfiguration::getInstance(array('run-tests.php',
'-p', $this->php, $this->sample_fail1));
+ $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
+ $status = new rtTestStatus($testFile->getTestName());
+ $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(),
$testFile->getSectionHeadings(), $config, $status);
+
+ //Setup and set the local environment for the test case
+ $testCase->executeTest($config);
+
+ $this->assertTrue($testCase->getStatus()->getValue('fail'));
+ $this->assertEquals('One file per testcase
permitted.',$testCase->getStatus()->getMessage('fail'));
+ }
+
+ public function testFail2()
+ {
+ //Create a new test configuration
+ $config = rtRuntestsConfiguration::getInstance(array('run-tests.php',
'-p', $this->php, $this->sample_fail2));
+ $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
+ $status = new rtTestStatus($testFile->getTestName());
+ $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(),
$testFile->getSectionHeadings(), $config, $status);
+
+ //Setup and set the local environment for the test case
+ $testCase->executeTest($config);
+
+ $this->assertTrue($testCase->getStatus()->getValue('fail'));
+ }
+}
+?>