zoe             Tue Jun  9 20:28:28 2009 UTC

  Added files:                 
    /phpruntests/tests/testcase rtFileExternalExecutionTest.php 
  Log:
  new file external test - tests execution
  

http://cvs.php.net/viewvc.cgi/phpruntests/tests/testcase/rtFileExternalExecutionTest.php?view=markup&rev=1.1
Index: phpruntests/tests/testcase/rtFileExternalExecutionTest.php
+++ phpruntests/tests/testcase/rtFileExternalExecutionTest.php
<?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'));
    }
}
?>



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to