Example #1
0
/**
 * @param string $file
 * @return Suite
 */
function loadSuiteFromFile(string $file)
{
    $suite = new Suite();
    $tests = (require_once $file);
    foreach ($tests as $testName => $test) {
        $suite->addTest($test, $testName);
    }
    return $suite;
}
 public function __invoke()
 {
     $suite = new Suite();
     $exception = new \Exception();
     $suite->addTest(function () {
     }, 'passing test 1');
     $suite->addTest(function () {
     }, 'passing test 2');
     $result = $suite(new Runner());
     $expected = Result::passed();
     Assert::like($result, $expected);
 }
 public function __invoke()
 {
     $test = function () {
     };
     $suite = new Suite();
     Assert::same($suite->getTestsCount(), 0);
     $suite = new Suite();
     $suite->addTest($test, 'test1');
     Assert::same($suite->getTestsCount(), 1);
     $suite = new Suite();
     $suite->addTest($test, 'test1');
     $suite->addTest($test, 'test2');
     Assert::same($suite->getTestsCount(), 2);
 }
Example #4
0
 public function __invoke()
 {
     $test = function () {
     };
     $testName = 'testName';
     $suite = new Suite();
     $runTestsCount = 0;
     $testsNames = [];
     $afterSuiteCallback = function ($testNumber, $testName) use(&$runTestsCount, &$testsNames) {
         $testsNames[] = $testName;
         $runTestsCount++;
     };
     $suite->setAfterTestCallback($afterSuiteCallback);
     $suite->addTest($test, $testName);
     $suite(new Runner());
     $expectedTests = [$testName];
     Assert::same($testsNames, $expectedTests);
     Assert::same($runTestsCount, 1);
 }
 public function __invoke()
 {
     $passingTest = function () {
     };
     $passingTestName = 'passing test';
     $afterTestCallback = function ($testNumber, $testName, $testResult) use(&$spy) {
         $spy = (object) ['testNumber' => $testNumber, 'testName' => $testName, 'testResult' => $testResult];
     };
     $runner = new Runner();
     $suite = new Suite();
     $suite->setAfterTestCallback($afterTestCallback);
     $suite->addTest($passingTest, $passingTestName);
     $suite($runner);
     $expected = new \stdClass();
     $expected->testNumber = 1;
     $expected->testName = $passingTestName;
     $expected->testResult = Result::passed($passingTestName);
     Assert::like($spy, $expected);
 }