Exemple #1
0
 /**
  *    Creates an empty test case. Should be subclassed
  *    with test methods for a functional test case.
  *    @param string $label     Name of test case. Will use
  *                             the class name if none specified.
  *    @access public
  */
 function __construct($label = false)
 {
     parent::__construct($label);
     $this->current_shell = $this->createShell();
     $this->last_status = false;
     $this->last_command = '';
 }
Exemple #2
0
 /**
  *    Creates an empty test case. Should be subclassed
  *    with test methods for a functional test case.
  *    @param string $label     Name of test case. Will use
  *                             the class name if none specified.
  *    @access public
  */
 function __construct($label = false)
 {
     if (!$label) {
         $label = get_class($this);
     }
     parent::__construct($label);
 }
 /**
  * @param SimpleTestCase $testCase
  * @return integer
  * @since Method available since Release 2.11.1
  */
 public function countTestsInTestCase(SimpleTestCase $testCase)
 {
     $tests = $testCase->getTests();
     $testCount = 0;
     if ($this->config->testsOnlySpecified()) {
         if ($this->config->testsOnlySpecifiedMethods) {
             foreach ($tests as $method) {
                 if ($this->config->inMethodsToBeTested(get_class($testCase), $method)) {
                     ++$testCount;
                 }
             }
         } elseif ($this->config->testsOnlySpecifiedClasses) {
             if ($this->config->inClassesToBeTested(get_class($testCase))) {
                 $testCount = count($tests);
             }
         }
     } else {
         $testCount = count($tests);
     }
     return $testCount;
 }
 /**
  *    Sends an error which we interpret as a fail
  *    with a different message for compatibility.
  *    @param $message        Message to display.
  *    @public
  */
 function error($message)
 {
     parent::fail("Error triggered [{$message}]");
 }
 public function doLog($message, $severity)
 {
     $this->test->dump(NULL, $message);
 }
Exemple #6
0
 /**
  *    Receives event from unit test that the current
  *    test method has finished. Totals up the call
  *    counts and triggers a test assertion if a test
  *    is present for expected call counts.
  *    @param string $test_method      Current method name.
  *    @param SimpleTestCase $test     Test to send message to.
  *    @access public
  */
 function atTestEnd($test_method, &$test)
 {
     foreach ($this->_expected_counts as $method => $expectation) {
         $test->assert($expectation, $this->getCallCount($method));
     }
     foreach ($this->_max_counts as $method => $expectation) {
         if ($expectation->test($this->getCallCount($method))) {
             $test->assert($expectation, $this->getCallCount($method));
         }
     }
 }
 /**
  *    Tests the type of a value.
  *    @param $value          Value to take type of.
  *    @param $type           Hoped for type.
  *    @param $message        Message to display.
  *    @public
  */
 function assertType($value, $type, $message = "%s")
 {
     parent::assertTrue(gettype($value) == strtolower($type), $message);
 }
 /**
  *    Compares the expected exception with any
  *    in the queue. Issues a pass or fail and
  *    returns the state of the test.
  *    @param SimpleTestCase $test    Test case to send messages to.
  *    @param Exception $exception    Exception to compare.
  *    @return boolean                False on no match.
  */
 function isExpected($test, $exception)
 {
     if ($this->expected) {
         return $test->assert($this->expected, $exception, $this->message);
     }
     return false;
 }
 public function runTestInvokesAfterClass()
 {
     SimpleTestCase::$dispose = 0;
     $this->suite->runTest(new SimpleTestCase('succeeds'));
     $this->assertEquals(1, SimpleTestCase::$dispose);
 }
 protected function tearDown()
 {
     parent::tearDown();
 }
 /**
  *    Sets the invoker to one that restarts the browser on
  *    each request.
  *    @return SimpleInvoker        Invoker for each method.
  *    @access public
  */
 function &createInvoker()
 {
     return new WebTestCaseInvoker(parent::createInvoker());
 }
Exemple #12
0
 /**
  *    Invokes a single test method on the test case.
  *    This call back allows the reporter to decide if
  *    it actually wants to run the test.
  *    @param SimpleTestCase $test_case    Test case to run test on.
  *    @param string $method               Name of test method.
  *    @access public
  */
 function invoke(&$test_case, $method)
 {
     if (!$this->_is_dry_run) {
         $test_case->invoke($method);
     }
 }
 /**
  * Run a test case (usually a group/suite) with the inferred reporter.
  *
  * @param SimpleTestCase $test_case
  * @return void    This method does not return a value.
  *                 Use hasFailures() to query status after running this.
  * @todo Stop creating an individual reporter for each run, in case a client
  * calls this method multiple times.
  */
 function runCase($test_case)
 {
     $reporter = $this->createReporter();
     $test_case->run($reporter);
     $all_tests_passed = $reporter->getStatus();
     if (!$all_tests_passed) {
         $this->_failed_runs++;
     }
 }
Exemple #14
0
 public function __construct()
 {
     parent::__construct();
     $this->_curl = curl_init();
     curl_setopt($this->_curl, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($this->_curl, CURLOPT_MAXREDIRS, 5);
     curl_setopt($this->_curl, CURLOPT_RETURNTRANSFER, true);
     $this->_jar = tempnam(sys_get_temp_dir(), 'COOKIEJAR');
     curl_setopt($this->_curl, CURLOPT_COOKIEJAR, $this->_jar);
 }
 /**
  *    Compares the expected exception with any
  *    in the queue. Issues a pass or fail and
  *    returns the state of the test.
  *    @param SimpleTestCase $test    Test case to send messages to.
  *    @param Exception $exception    Exception to compare.
  *    @return boolean                False on no match.
  */
 function isExpected($test, $exception)
 {
     if ($this->expected) {
         return $test->assert($this->expected, $exception, $this->message);
     }
     foreach ($this->ignored as $ignored) {
         if ($ignored->test($exception)) {
             return true;
         }
     }
     return false;
 }
 /**
  *    Sends an error which we interpret as a fail
  *    with a different message for compatibility.
  *    @param $message        Message to display.
  *    @public
  */
 function error($message)
 {
     parent::assertTrue(false, "Error triggered [{$message}]");
 }
Exemple #17
0
 public function __construct($path)
 {
     $this->_path = $path;
     parent::__construct($path);
 }
Exemple #18
0
 /**
  *    Sets up a browser for the start of each
  *    test method.
  *    @access public
  */
 function before()
 {
     $this->_browser =& $this->createBrowser();
     parent::before();
 }
Exemple #19
0
 /**
  * @param SimpleTestCase $testCase
  * @return integer
  * @since Method available since Release 2.14.0
  */
 protected function getTestsInTestCase(SimpleTestCase $testCase)
 {
     return $testCase->getTests();
 }
Exemple #20
0
 /**
  *    Sets up a browser for the start of each
  *    test method.
  *    @param string $method    Name of test method.
  *    @access protected
  */
 function invoke($method)
 {
     $this->_browser =& $this->createBrowser();
     parent::invoke($method);
 }
 /**
  *    Announces the end of the test. Includes private clean up.
  *    @param string $method    Test method just finished.
  *    @access public
  */
 function after($method)
 {
     $this->unsetBrowser();
     parent::after($method);
 }
 /**
  *    Triggers an assertion on the held test case.
  *    Should be overridden when using another test
  *    framework other than the SimpleTest one if the
  *    assertion method has a different name.
  *    @param boolean $assertion     True will pass.
  *    @param string $message        Message that will go with
  *                                  the test event.
  *    @param SimpleTestCase $test   Unit test case to send
  *                                  assertion to.
  *    @access protected
  */
 function _assertTrue($assertion, $message , &$test) {
     if ($test) {
         $test->assertTrue($assertion, $message);
     }
 }
Exemple #23
0
 /**
  *    Tests the type of a value.
  *    @param $value          Value to take type of.
  *    @param $type           Hoped for type.
  *    @param $message        Message to display.
  *    @public
  */
 function assertType($value, $type, $message = "%s")
 {
     parent::assert(new TrueExpectation(), gettype($value) == strtolower($type), $message);
 }
Exemple #24
0
 /**
  *    Calculates the incoming test cases. Skips abstract
  *    and ignored classes.
  *    @param array $candidates   Candidate classes.
  *    @return array              New classes which are test
  *                               cases that shouldn't be ignored.
  *    @access public
  */
 function selectRunnableTests($candidates)
 {
     $classes = array();
     foreach ($candidates as $class) {
         if (TestSuite::getBaseTestCase($class)) {
             $reflection = new SimpleReflection($class);
             if ($reflection->isAbstract()) {
                 SimpleTest::ignore($class);
             } else {
                 // only pick classes which do have test methods we can run:
                 $methods = $reflection->getMethods();
                 foreach ($methods as $method) {
                     if (SimpleTestCase::isTest($class, $method)) {
                         $classes[] = $class;
                         break;
                     }
                 }
             }
         }
     }
     return $classes;
 }