package updates
This commit is contained in:
+1
-1
@@ -18,7 +18,7 @@ final class CountConstraint extends Constraint
|
||||
|
||||
public static function fromCount(int $count): self
|
||||
{
|
||||
$instance = new self();
|
||||
$instance = new self;
|
||||
|
||||
$instance->count = $count;
|
||||
|
||||
|
||||
@@ -13,12 +13,12 @@ class DataProviderDebugTest extends TestCase
|
||||
{
|
||||
public static function provider()
|
||||
{
|
||||
$obj2 = new \stdClass();
|
||||
$obj2 = new \stdClass;
|
||||
$obj2->foo = 'bar';
|
||||
|
||||
$obj3 = (object) [1, 2, "Test\r\n", 4, 5, 6, 7, 8];
|
||||
|
||||
$obj = new \stdClass();
|
||||
$obj = new \stdClass;
|
||||
//@codingStandardsIgnoreStart
|
||||
$obj->null = null;
|
||||
//@codingStandardsIgnoreEnd
|
||||
@@ -32,7 +32,7 @@ class DataProviderDebugTest extends TestCase
|
||||
$obj->array = ['foo' => 'bar'];
|
||||
$obj->self = $obj;
|
||||
|
||||
$storage = new \SplObjectStorage();
|
||||
$storage = new \SplObjectStorage;
|
||||
$storage->attach($obj2);
|
||||
$storage->foo = $obj;
|
||||
|
||||
@@ -42,7 +42,7 @@ class DataProviderDebugTest extends TestCase
|
||||
[[[1, 2, 3], [3, 4, 5]]],
|
||||
// \n\r and \r is converted to \n
|
||||
["this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext"],
|
||||
[new \stdClass(), $obj, [], $storage, $obj3],
|
||||
[new \stdClass, $obj, [], $storage, $obj3],
|
||||
[\chr(0) . \chr(1) . \chr(2) . \chr(3) . \chr(4) . \chr(5), \implode('', \array_map('chr', \range(0x0e, 0x1f)))],
|
||||
[\chr(0x00) . \chr(0x09)],
|
||||
];
|
||||
|
||||
@@ -13,7 +13,7 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SecondTest extends TestCase
|
||||
{
|
||||
const DUMMY = 'dummy';
|
||||
public const DUMMY = 'dummy';
|
||||
|
||||
public function testSecond(): void
|
||||
{
|
||||
|
||||
@@ -26,6 +26,6 @@ class FirstTest extends TestCase
|
||||
|
||||
public function provide(): void
|
||||
{
|
||||
throw new \Exception();
|
||||
throw new \Exception;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class DataProviderTestDoxTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provider
|
||||
* @testdox Does something with
|
||||
* @testdox Does something
|
||||
*/
|
||||
public function testOne(): void
|
||||
{
|
||||
@@ -23,7 +23,15 @@ class DataProviderTestDoxTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provider
|
||||
*/
|
||||
public function testDoesSomethingElseWith(): void
|
||||
public function testDoesSomethingElse(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerWithIndexedArray
|
||||
*/
|
||||
public function testWithProviderWithIndexedArray($value): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
@@ -45,6 +53,14 @@ class DataProviderTestDoxTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function providerWithIndexedArray()
|
||||
{
|
||||
return [
|
||||
['first'],
|
||||
['second'],
|
||||
];
|
||||
}
|
||||
|
||||
public function placeHolderprovider(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DataproviderExecutionOrderTest extends TestCase
|
||||
{
|
||||
public function testFirstTestThatAlwaysWorks()
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataproviderAdditions
|
||||
*/
|
||||
public function testAddNumbersWithADataprovider(int $a, int $b, int $sum)
|
||||
{
|
||||
$this->assertSame($sum, $a + $b);
|
||||
}
|
||||
|
||||
public function testTestInTheMiddleThatAlwaysWorks()
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataproviderAdditions
|
||||
*/
|
||||
public function testAddMoreNumbersWithADataprovider(int $a, int $b, int $sum)
|
||||
{
|
||||
$this->assertSame($sum, $a + $b);
|
||||
}
|
||||
|
||||
public function dataproviderAdditions()
|
||||
{
|
||||
return [
|
||||
'1+2=3' => [1, 2, 3],
|
||||
'2+1=3' => [2, 1, 3],
|
||||
'1+1=3' => [1, 1, 3],
|
||||
];
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
C:30:"PHPUnit\Runner\TestResultCache":2119:{a:2:{s:7:"defects";a:5:{s:60:"tests/end-to-end/regression/GitHub/3396/issue-3396-test.phpt";i:3;s:88:"MultiDependencyExecutionOrderTest::testAddNumbersWithADataprovider with data set "1+1=3"";i:3;s:92:"MultiDependencyExecutionOrderTest::testAddMoreNumbersWithADataprovider with data set "1+1=3"";i:3;s:85:"DataproviderExecutionOrderTest::testAddNumbersWithADataprovider with data set "1+1=3"";i:3;s:89:"DataproviderExecutionOrderTest::testAddMoreNumbersWithADataprovider with data set "1+1=3"";i:3;}s:5:"times";a:17:{s:60:"tests/end-to-end/regression/GitHub/3396/issue-3396-test.phpt";d:0.115;s:63:"MultiDependencyExecutionOrderTest::testFirstTestThatAlwaysWorks";d:0;s:88:"MultiDependencyExecutionOrderTest::testAddNumbersWithADataprovider with data set "1+2=3"";d:0;s:88:"MultiDependencyExecutionOrderTest::testAddNumbersWithADataprovider with data set "2+1=3"";d:0;s:88:"MultiDependencyExecutionOrderTest::testAddNumbersWithADataprovider with data set "1+1=3"";d:0.003;s:69:"MultiDependencyExecutionOrderTest::testTestInTheMiddleThatAlwaysWorks";d:0;s:92:"MultiDependencyExecutionOrderTest::testAddMoreNumbersWithADataprovider with data set "1+2=3"";d:0;s:92:"MultiDependencyExecutionOrderTest::testAddMoreNumbersWithADataprovider with data set "2+1=3"";d:0;s:92:"MultiDependencyExecutionOrderTest::testAddMoreNumbersWithADataprovider with data set "1+1=3"";d:0;s:60:"DataproviderExecutionOrderTest::testFirstTestThatAlwaysWorks";d:0.002;s:85:"DataproviderExecutionOrderTest::testAddNumbersWithADataprovider with data set "1+2=3"";d:0;s:85:"DataproviderExecutionOrderTest::testAddNumbersWithADataprovider with data set "2+1=3"";d:0;s:85:"DataproviderExecutionOrderTest::testAddNumbersWithADataprovider with data set "1+1=3"";d:0.001;s:66:"DataproviderExecutionOrderTest::testTestInTheMiddleThatAlwaysWorks";d:0;s:89:"DataproviderExecutionOrderTest::testAddMoreNumbersWithADataprovider with data set "1+2=3"";d:0;s:89:"DataproviderExecutionOrderTest::testAddMoreNumbersWithADataprovider with data set "2+1=3"";d:0;s:89:"DataproviderExecutionOrderTest::testAddMoreNumbersWithADataprovider with data set "1+1=3"";d:0;}}}
|
||||
@@ -16,14 +16,14 @@ class ExceptionNamespaceTest extends \PHPUnit\Framework\TestCase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const ERROR_MESSAGE = 'Exception namespace message';
|
||||
public const ERROR_MESSAGE = 'Exception namespace message';
|
||||
|
||||
/**
|
||||
* Exception code
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const ERROR_CODE = 200;
|
||||
public const ERROR_CODE = 200;
|
||||
|
||||
/**
|
||||
* @expectedException Class
|
||||
|
||||
+3
-3
@@ -16,21 +16,21 @@ class ExceptionTest extends TestCase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const ERROR_MESSAGE = 'Exception message';
|
||||
public const ERROR_MESSAGE = 'Exception message';
|
||||
|
||||
/**
|
||||
* Exception message
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const ERROR_MESSAGE_REGEX = '#regex#';
|
||||
public const ERROR_MESSAGE_REGEX = '#regex#';
|
||||
|
||||
/**
|
||||
* Exception code
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const ERROR_CODE = 500;
|
||||
public const ERROR_CODE = 500;
|
||||
|
||||
/**
|
||||
* @expectedException FooBarBaz
|
||||
|
||||
@@ -13,13 +13,13 @@ class IgnoreCodeCoverageClassTest extends TestCase
|
||||
{
|
||||
public function testReturnTrue(): void
|
||||
{
|
||||
$sut = new IgnoreCodeCoverageClass();
|
||||
$sut = new IgnoreCodeCoverageClass;
|
||||
$this->assertTrue($sut->returnTrue());
|
||||
}
|
||||
|
||||
public function testReturnFalse(): void
|
||||
{
|
||||
$sut = new IgnoreCodeCoverageClass();
|
||||
$sut = new IgnoreCodeCoverageClass;
|
||||
$this->assertFalse($sut->returnFalse());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
C:30:"PHPUnit\Runner\TestResultCache":157:{a:2:{s:7:"defects";a:1:{s:8:"testFive";i:1;}s:5:"times";a:5:{s:7:"testOne";d:0;s:7:"testTwo";d:0;s:9:"testThree";d:0;s:8:"testFour";d:0;s:8:"testFive";d:0;}}}
|
||||
C:30:"PHPUnit\Runner\TestResultCache":289:{a:2:{s:7:"defects";a:1:{s:29:"MultiDependencyTest::testFive";i:1;}s:5:"times";a:5:{s:28:"MultiDependencyTest::testOne";d:0;s:28:"MultiDependencyTest::testTwo";d:0;s:30:"MultiDependencyTest::testThree";d:0;s:29:"MultiDependencyTest::testFour";d:0;s:29:"MultiDependencyTest::testFive";d:0;}}}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\AssertionFailedError;
|
||||
use PHPUnit\Framework\Test;
|
||||
use PHPUnit\Framework\TestListener;
|
||||
use PHPUnit\Framework\TestSuite;
|
||||
use PHPUnit\Framework\Warning;
|
||||
|
||||
final class MyTestListener implements TestListener
|
||||
{
|
||||
private $endCount = 0;
|
||||
|
||||
private $errorCount = 0;
|
||||
|
||||
private $failureCount = 0;
|
||||
|
||||
private $warningCount = 0;
|
||||
|
||||
private $notImplementedCount = 0;
|
||||
|
||||
private $riskyCount = 0;
|
||||
|
||||
private $skippedCount = 0;
|
||||
|
||||
private $startCount = 0;
|
||||
|
||||
public function addError(Test $test, \Throwable $t, float $time): void
|
||||
{
|
||||
$this->errorCount++;
|
||||
}
|
||||
|
||||
public function addWarning(Test $test, Warning $e, float $time): void
|
||||
{
|
||||
$this->warningCount++;
|
||||
}
|
||||
|
||||
public function addFailure(Test $test, AssertionFailedError $e, float $time): void
|
||||
{
|
||||
$this->failureCount++;
|
||||
}
|
||||
|
||||
public function addIncompleteTest(Test $test, \Throwable $t, float $time): void
|
||||
{
|
||||
$this->notImplementedCount++;
|
||||
}
|
||||
|
||||
public function addRiskyTest(Test $test, \Throwable $t, float $time): void
|
||||
{
|
||||
$this->riskyCount++;
|
||||
}
|
||||
|
||||
public function addSkippedTest(Test $test, \Throwable $t, float $time): void
|
||||
{
|
||||
$this->skippedCount++;
|
||||
}
|
||||
|
||||
public function startTestSuite(TestSuite $suite): void
|
||||
{
|
||||
}
|
||||
|
||||
public function endTestSuite(TestSuite $suite): void
|
||||
{
|
||||
}
|
||||
|
||||
public function startTest(Test $test): void
|
||||
{
|
||||
$this->startCount++;
|
||||
}
|
||||
|
||||
public function endTest(Test $test, float $time): void
|
||||
{
|
||||
$this->endCount++;
|
||||
}
|
||||
|
||||
public function endCount(): int
|
||||
{
|
||||
return $this->endCount;
|
||||
}
|
||||
|
||||
public function errorCount(): int
|
||||
{
|
||||
return $this->errorCount;
|
||||
}
|
||||
|
||||
public function failureCount(): int
|
||||
{
|
||||
return $this->failureCount;
|
||||
}
|
||||
|
||||
public function warningCount(): int
|
||||
{
|
||||
return $this->warningCount;
|
||||
}
|
||||
|
||||
public function notImplementedCount(): int
|
||||
{
|
||||
return $this->notImplementedCount;
|
||||
}
|
||||
|
||||
public function riskyCount(): int
|
||||
{
|
||||
return $this->riskyCount;
|
||||
}
|
||||
|
||||
public function skippedCount(): int
|
||||
{
|
||||
return $this->skippedCount;
|
||||
}
|
||||
|
||||
public function startCount(): int
|
||||
{
|
||||
return $this->startCount;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -18,7 +18,7 @@ final class NamedConstraint extends Constraint
|
||||
|
||||
public static function fromName(string $name): self
|
||||
{
|
||||
$instance = new self();
|
||||
$instance = new self;
|
||||
|
||||
$instance->name = $name;
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\Test;
|
||||
use PHPUnit\Framework\TestResult;
|
||||
|
||||
class NotSelfDescribingTest implements Test
|
||||
{
|
||||
public function log($msg): void
|
||||
{
|
||||
print $msg;
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run(TestResult $result = null): TestResult
|
||||
{
|
||||
return new TestResult();
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -8,11 +8,12 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Warning;
|
||||
|
||||
class TestWarning extends TestCase
|
||||
{
|
||||
protected function runTest(): void
|
||||
{
|
||||
throw new \PHPUnit\Framework\Warning();
|
||||
throw new Warning;
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -39,6 +39,8 @@ require_once TEST_FILES_PATH . 'NoTestCases.php';
|
||||
|
||||
require_once TEST_FILES_PATH . 'NotPublicTestCase.php';
|
||||
|
||||
require_once TEST_FILES_PATH . 'NotSelfDescribingTest.php';
|
||||
|
||||
require_once TEST_FILES_PATH . 'NotVoidTestCase.php';
|
||||
|
||||
require_once TEST_FILES_PATH . 'OverrideTestCase.php';
|
||||
|
||||
@@ -16,11 +16,12 @@ use PHPUnit\Runner\AfterSkippedTestHook;
|
||||
use PHPUnit\Runner\AfterSuccessfulTestHook;
|
||||
use PHPUnit\Runner\AfterTestErrorHook;
|
||||
use PHPUnit\Runner\AfterTestFailureHook;
|
||||
use PHPUnit\Runner\AfterTestHook;
|
||||
use PHPUnit\Runner\AfterTestWarningHook;
|
||||
use PHPUnit\Runner\BeforeFirstTestHook;
|
||||
use PHPUnit\Runner\BeforeTestHook;
|
||||
|
||||
final class Extension implements BeforeFirstTestHook, BeforeTestHook, AfterSuccessfulTestHook, AfterSkippedTestHook, AfterRiskyTestHook, AfterIncompleteTestHook, AfterTestErrorHook, AfterTestWarningHook, AfterTestFailureHook, AfterLastTestHook
|
||||
final class Extension implements BeforeFirstTestHook, BeforeTestHook, AfterTestHook, AfterSuccessfulTestHook, AfterSkippedTestHook, AfterRiskyTestHook, AfterIncompleteTestHook, AfterTestErrorHook, AfterTestWarningHook, AfterTestFailureHook, AfterLastTestHook
|
||||
{
|
||||
private $amountOfInjectedArguments = 0;
|
||||
|
||||
@@ -45,6 +46,11 @@ final class Extension implements BeforeFirstTestHook, BeforeTestHook, AfterSucce
|
||||
print __METHOD__ . ': ' . $test . \PHP_EOL;
|
||||
}
|
||||
|
||||
public function executeAfterTest(string $test, float $time): void
|
||||
{
|
||||
print __METHOD__ . ': ' . $test . \PHP_EOL;
|
||||
}
|
||||
|
||||
public function executeAfterSuccessfulTest(string $test, float $time): void
|
||||
{
|
||||
print __METHOD__ . ': ' . $test . \PHP_EOL;
|
||||
|
||||
@@ -26,4 +26,4 @@ Time: %s, Memory: %s
|
||||
|
||||
OK, but incomplete, skipped, or risky tests!
|
||||
Tests: 5, Assertions: 3, Skipped: 2.
|
||||
C:30:"PHPUnit\Runner\TestResultCache":%d:{a:2:{s:7:"defects";a:2:{s:8:"testFour";i:1;s:9:"testThree";i:1;}s:5:"times";a:5:{s:8:"testFive";d:%f;s:8:"testFour";d:%f;s:9:"testThree";d:%f;s:7:"testTwo";d:%f;s:7:"testOne";d:%f;}}}
|
||||
C:30:"PHPUnit\Runner\TestResultCache":%d:{a:2:{s:7:"defects";a:2:{s:29:"MultiDependencyTest::testFour";i:1;s:30:"MultiDependencyTest::testThree";i:1;}s:5:"times";a:5:{s:29:"MultiDependencyTest::testFive";d:%f;s:29:"MultiDependencyTest::testFour";d:%f;s:30:"MultiDependencyTest::testThree";d:%f;s:28:"MultiDependencyTest::testTwo";d:%f;s:28:"MultiDependencyTest::testOne";d:%f;}}}
|
||||
|
||||
@@ -17,6 +17,8 @@ DataProviderTestDox
|
||||
✔ Does something with data set "two"
|
||||
✔ Does something else with data set "one"
|
||||
✔ Does something else with data set "two"
|
||||
✔ With provider with indexed array with data set #0
|
||||
✔ With provider with indexed array with data set #1
|
||||
✔ ... true ...
|
||||
✔ ... 1 ...
|
||||
✔ ... 1.0 ...
|
||||
@@ -29,4 +31,4 @@ DataProviderTestDox
|
||||
|
||||
Time: %s, Memory: %s
|
||||
|
||||
OK (13 tests, 13 assertions)
|
||||
OK (15 tests, 15 assertions)
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ Configuration Options:
|
||||
--include-path <path(s)> Prepend PHP's include_path with given path(s)
|
||||
-d key[=value] Sets a php.ini value
|
||||
--generate-configuration Generate configuration file with suggested settings
|
||||
--cache-result-file==<FILE> Specify result cache path and filename
|
||||
--cache-result-file=<file> Specify result cache path and filename
|
||||
|
||||
Miscellaneous Options:
|
||||
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ Configuration Options:
|
||||
--include-path <path(s)> Prepend PHP's include_path with given path(s)
|
||||
-d key[=value] Sets a php.ini value
|
||||
--generate-configuration Generate configuration file with suggested settings
|
||||
--cache-result-file==<FILE> Specify result cache path and filename
|
||||
--cache-result-file=<file> Specify result cache path and filename
|
||||
|
||||
Miscellaneous Options:
|
||||
|
||||
|
||||
@@ -16,16 +16,23 @@ PHPUnit\Test\Extension::tellAmountOfInjectedArguments: %d
|
||||
PHPUnit\Test\Extension::executeBeforeFirstTest
|
||||
PHPUnit\Test\Extension::executeBeforeTest: PHPUnit\Test\HookTest::testSuccess
|
||||
PHPUnit\Test\Extension::executeAfterSuccessfulTest: PHPUnit\Test\HookTest::testSuccess
|
||||
PHPUnit\Test\Extension::executeAfterTest: PHPUnit\Test\HookTest::testSuccess
|
||||
PHPUnit\Test\Extension::executeBeforeTest: PHPUnit\Test\HookTest::testFailure
|
||||
PHPUnit\Test\Extension::executeAfterTestFailure: PHPUnit\Test\HookTest::testFailure: Failed asserting that false is true.
|
||||
PHPUnit\Test\Extension::executeAfterTest: PHPUnit\Test\HookTest::testFailure
|
||||
PHPUnit\Test\Extension::executeBeforeTest: PHPUnit\Test\HookTest::testError
|
||||
PHPUnit\Test\Extension::executeAfterTestError: PHPUnit\Test\HookTest::testError: message
|
||||
PHPUnit\Test\Extension::executeAfterTest: PHPUnit\Test\HookTest::testError
|
||||
PHPUnit\Test\Extension::executeBeforeTest: PHPUnit\Test\HookTest::testIncomplete
|
||||
PHPUnit\Test\Extension::executeAfterIncompleteTest: PHPUnit\Test\HookTest::testIncomplete: message
|
||||
PHPUnit\Test\Extension::executeAfterTest: PHPUnit\Test\HookTest::testIncomplete
|
||||
PHPUnit\Test\Extension::executeBeforeTest: PHPUnit\Test\HookTest::testRisky
|
||||
PHPUnit\Test\Extension::executeAfterRiskyTest: PHPUnit\Test\HookTest::testRisky: message
|
||||
PHPUnit\Test\Extension::executeAfterTest: PHPUnit\Test\HookTest::testRisky
|
||||
PHPUnit\Test\Extension::executeBeforeTest: PHPUnit\Test\HookTest::testSkipped
|
||||
PHPUnit\Test\Extension::executeAfterSkippedTest: PHPUnit\Test\HookTest::testSkipped: message
|
||||
PHPUnit\Test\Extension::executeAfterTest: PHPUnit\Test\HookTest::testSkipped
|
||||
PHPUnit\Test\Extension::executeBeforeTest: PHPUnit\Test\HookTest::testWarning
|
||||
PHPUnit\Test\Extension::executeAfterTestWarning: PHPUnit\Test\HookTest::testWarning: message
|
||||
PHPUnit\Test\Extension::executeAfterTest: PHPUnit\Test\HookTest::testWarning
|
||||
PHPUnit\Test\Extension::executeAfterLastTest
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
phpunit --log-junit php://stdout ../end-to-end/phpt-stderr.phpt
|
||||
--FILE--
|
||||
<?php
|
||||
$_SERVER['argv'][1] = '--no-configuration';
|
||||
$_SERVER['argv'][2] = '--log-junit';
|
||||
$_SERVER['argv'][3] = 'php://stdout';
|
||||
$_SERVER['argv'][4] = \realpath(__DIR__ . '/../end-to-end/phpt-stderr.phpt');
|
||||
|
||||
require __DIR__ . '/../bootstrap.php';
|
||||
PHPUnit\TextUI\Command::main();
|
||||
?>
|
||||
--EXPECTF--
|
||||
PHPUnit %s by Sebastian Bergmann and contributors.
|
||||
|
||||
. 1 / 1 (100%)<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testsuites>
|
||||
<testsuite name="" tests="1" assertions="1" errors="0" failures="0" skipped="0" time="%s">
|
||||
<testcase name="%send-to-end%ephpt-stderr.phpt" assertions="1" time="%s">
|
||||
<system-out>PHPUnit must look at STDERR when running PHPT tests.</system-out>
|
||||
</testcase>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
|
||||
Time: %s, Memory: %s
|
||||
|
||||
OK (1 test, 1 assertion)
|
||||
@@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
phpunit --log-teamcity php://stdout ../end-to-end/phpt-stderr.phpt
|
||||
--FILE--
|
||||
<?php
|
||||
$_SERVER['argv'][1] = '--no-configuration';
|
||||
$_SERVER['argv'][2] = '--log-teamcity';
|
||||
$_SERVER['argv'][3] = 'php://stdout';
|
||||
$_SERVER['argv'][4] = \realpath(__DIR__ . '/../end-to-end/phpt-stderr.phpt');
|
||||
|
||||
require __DIR__ . '/../bootstrap.php';
|
||||
PHPUnit\TextUI\Command::main();
|
||||
--EXPECTF--
|
||||
PHPUnit %s by Sebastian Bergmann and contributors.
|
||||
|
||||
|
||||
##teamcity[testCount count='1' flowId='%d']
|
||||
|
||||
##teamcity[testStarted name='%send-to-end%ephpt-stderr.phpt' flowId='%d']
|
||||
. 1 / 1 (100%)
|
||||
##teamcity[testFinished name='%send-to-end%ephpt-stderr.phpt' duration='%d' flowId='%d']
|
||||
|
||||
|
||||
Time: %s, Memory: %s
|
||||
|
||||
OK (1 test, 1 assertion)
|
||||
+2
-2
@@ -18,7 +18,7 @@ class Issue1351Test extends TestCase
|
||||
*/
|
||||
public function testFailurePre(): void
|
||||
{
|
||||
$this->instance = new ChildProcessClass1351();
|
||||
$this->instance = new ChildProcessClass1351;
|
||||
$this->assertFalse(true, 'Expected failure.');
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class Issue1351Test extends TestCase
|
||||
*/
|
||||
public function testExceptionPre(): void
|
||||
{
|
||||
$this->instance = new ChildProcessClass1351();
|
||||
$this->instance = new ChildProcessClass1351;
|
||||
|
||||
try {
|
||||
throw new LogicException('Expected exception.');
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ class Issue2137Test extends PHPUnit\Framework\TestCase
|
||||
{
|
||||
return [
|
||||
//[true, true]
|
||||
new stdClass(), // not valid
|
||||
new stdClass, // not valid
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ Time: %s, Memory: %s
|
||||
|
||||
There was 1 error:
|
||||
|
||||
1) Issue2145Test
|
||||
1) Issue2145Test::testOne
|
||||
Exception in %s%eIssue2145Test.php:%d
|
||||
%A
|
||||
ERRORS!
|
||||
Tests: 2, Assertions: 0, Errors: 1.
|
||||
Tests: 1, Assertions: 0, Errors: 1.
|
||||
|
||||
+2
@@ -5,6 +5,8 @@ Expected result is to have an error, because of no classes loaded.
|
||||
<?php
|
||||
if (!extension_loaded('xdebug')) {
|
||||
print 'skip: xdebug not loaded';
|
||||
} elseif (version_compare(PHP_VERSION, '7.3.0-dev', '>=')) {
|
||||
print 'skip: PHP < 7.3 required';
|
||||
}
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
+3
-3
@@ -13,11 +13,11 @@
|
||||
*/
|
||||
class SeparateClassRunMethodInNewProcessTest extends PHPUnit\Framework\TestCase
|
||||
{
|
||||
const PROCESS_ID_FILE_PATH = __DIR__ . '/parent_process_id.txt';
|
||||
public const PROCESS_ID_FILE_PATH = __DIR__ . '/parent_process_id.txt';
|
||||
|
||||
const INITIAL_MASTER_PID = 0;
|
||||
public const INITIAL_MASTER_PID = 0;
|
||||
|
||||
const INITIAL_PID1 = 1;
|
||||
public const INITIAL_PID1 = 1;
|
||||
|
||||
public static $masterPid = self::INITIAL_MASTER_PID;
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ use PHPUnit\Framework\TestCase;
|
||||
*/
|
||||
class BeforeAfterClassPidTest extends TestCase
|
||||
{
|
||||
const PID_VARIABLE = 'current_pid';
|
||||
public const PID_VARIABLE = 'current_pid';
|
||||
|
||||
/**
|
||||
* @beforeClass
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ PHPUnit\TextUI\Command::main();
|
||||
--EXPECTF--
|
||||
PHPUnit %s by Sebastian Bergmann and contributors.
|
||||
|
||||
Issue3107\Issue3107Test
|
||||
✘ Error bootstapping suite (most likely in Issue3107\Issue3107Test::setUpBeforeClass)
|
||||
Issue3107\Issue3107
|
||||
✘ One
|
||||
│
|
||||
│ Error: Call to undefined function %Sdoes_not_exist()
|
||||
│
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ class Issue3156Test extends TestCase
|
||||
{
|
||||
$this->assertStringEndsWith('/', '/');
|
||||
|
||||
return new stdClass();
|
||||
return new stdClass;
|
||||
}
|
||||
|
||||
public function dataSelectOperatorsProvider(): array
|
||||
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
--TEST--
|
||||
https://github.com/sebastianbergmann/phpunit/issues/3364
|
||||
--FILE--
|
||||
<?php
|
||||
$_SERVER['argv'][1] = '--no-configuration';
|
||||
$_SERVER['argv'][2] = '--teamcity';
|
||||
$_SERVER['argv'][3] = __DIR__ . DIRECTORY_SEPARATOR . 'tests';
|
||||
|
||||
require __DIR__ . '/../../../../bootstrap.php';
|
||||
PHPUnit\TextUI\Command::main();
|
||||
--EXPECTF--
|
||||
PHPUnit %s by Sebastian Bergmann and contributors.
|
||||
|
||||
|
||||
##teamcity[testCount count='4' flowId='%d']
|
||||
|
||||
##teamcity[testSuiteStarted name='%stests%eend-to-end%eregression%eGitHub%e3364%etests' flowId='%d']
|
||||
|
||||
##teamcity[testSuiteStarted name='Issue3364SetupBeforeClassTest' locationHint='php_qn://%s%etests%eend-to-end%eregression%eGitHub%e3364%etests%eIssue3364SetupBeforeClassTest.php::\Issue3364SetupBeforeClassTest' flowId='%d']
|
||||
|
||||
##teamcity[testStarted name='testOneWithClassSetupException' locationHint='php_qn://%s%etests%eend-to-end%eregression%eGitHub%e3364%etests%eIssue3364SetupBeforeClassTest.php::\Issue3364SetupBeforeClassTest::testOneWithClassSetupException' flowId='%d']
|
||||
|
||||
##teamcity[testFailed name='testOneWithClassSetupException' message='throw exception in setUpBeforeClass' details=' %s%etests%eend-to-end%eregression%eGitHub%e3364%etests%eIssue3364SetupBeforeClassTest.php:18|n ' duration='%d' flowId='%d']
|
||||
|
||||
##teamcity[testFinished name='testOneWithClassSetupException' duration='%d' flowId='%d']
|
||||
|
||||
##teamcity[testStarted name='testTwoWithClassSetupException' locationHint='php_qn://%s%etests%eend-to-end%eregression%eGitHub%e3364%etests%eIssue3364SetupBeforeClassTest.php::\Issue3364SetupBeforeClassTest::testTwoWithClassSetupException' flowId='%d']
|
||||
|
||||
##teamcity[testFailed name='testTwoWithClassSetupException' message='throw exception in setUpBeforeClass' details=' %s%etests%eend-to-end%eregression%eGitHub%e3364%etests%eIssue3364SetupBeforeClassTest.php:18|n ' duration='%d' flowId='%d']
|
||||
|
||||
##teamcity[testFinished name='testTwoWithClassSetupException' duration='%d' flowId='%d']
|
||||
|
||||
##teamcity[testSuiteFinished name='Issue3364SetupBeforeClassTest' flowId='%d']
|
||||
|
||||
##teamcity[testSuiteStarted name='Issue3364SetupTest' locationHint='php_qn://%s%etests%eend-to-end%eregression%eGitHub%e3364%etests%eIssue3364SetupTest.php::\Issue3364SetupTest' flowId='%d']
|
||||
|
||||
##teamcity[testStarted name='testOneWithSetupException' locationHint='php_qn://%s%etests%eend-to-end%eregression%eGitHub%e3364%etests%eIssue3364SetupTest.php::\Issue3364SetupTest::testOneWithSetupException' flowId='%d']
|
||||
|
||||
##teamcity[testFailed name='testOneWithSetupException' message='RuntimeException : throw exception in setUp' details=' %s%etests%eend-to-end%eregression%eGitHub%e3364%etests%eIssue3364SetupTest.php:18|n ' duration='%d' flowId='%d']
|
||||
|
||||
##teamcity[testFinished name='testOneWithSetupException' duration='%d' flowId='%d']
|
||||
|
||||
##teamcity[testStarted name='testTwoWithSetupException' locationHint='php_qn://%s%etests%eend-to-end%eregression%eGitHub%e3364%etests%eIssue3364SetupTest.php::\Issue3364SetupTest::testTwoWithSetupException' flowId='%d']
|
||||
|
||||
##teamcity[testFailed name='testTwoWithSetupException' message='RuntimeException : throw exception in setUp' details=' %s%etests%eend-to-end%eregression%eGitHub%e3364%etests%eIssue3364SetupTest.php:18|n ' duration='%d' flowId='%d']
|
||||
|
||||
##teamcity[testFinished name='testTwoWithSetupException' duration='%d' flowId='%d']
|
||||
|
||||
##teamcity[testSuiteFinished name='Issue3364SetupTest' flowId='%d']
|
||||
|
||||
##teamcity[testSuiteFinished name='%stests%eend-to-end%eregression%eGitHub%e3364%etests' flowId='%d']
|
||||
|
||||
|
||||
Time: %s, Memory: %s
|
||||
|
||||
|
||||
ERRORS!
|
||||
Tests: 4, Assertions: 0, Errors: 4.
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class Issue3364SetupBeforeClassTest extends TestCase
|
||||
{
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
throw new \RuntimeException('throw exception in setUpBeforeClass');
|
||||
}
|
||||
|
||||
public function testOneWithClassSetupException(): void
|
||||
{
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testTwoWithClassSetupException(): void
|
||||
{
|
||||
$this->fail();
|
||||
}
|
||||
}
|
||||
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class Issue3364SetupTest extends TestCase
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
throw new \RuntimeException('throw exception in setUp');
|
||||
}
|
||||
|
||||
public function testOneWithSetupException(): void
|
||||
{
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testTwoWithSetupException(): void
|
||||
{
|
||||
$this->fail();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
GH-3379: Dependent test of skipped test has status -1
|
||||
--FILE--
|
||||
<?php
|
||||
$_SERVER['argv'][1] = '--configuration';
|
||||
$_SERVER['argv'][2] = __DIR__ . '/3379/';
|
||||
|
||||
require __DIR__ . '/../../../bootstrap.php';
|
||||
PHPUnit\TextUI\Command::main();
|
||||
--EXPECTF--
|
||||
PHPUnit %s by Sebastian Bergmann and contributors.
|
||||
|
||||
Skipped test testOne, status: 1
|
||||
SSkipped test testTwo, status: 1
|
||||
S 2 / 2 (100%)
|
||||
|
||||
Time: %s, Memory: %s
|
||||
|
||||
OK, but incomplete, skipped, or risky tests!
|
||||
Tests: 2, Assertions: 0, Skipped: 2.
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Test;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class Issue3379Test extends TestCase
|
||||
{
|
||||
public function testOne(): void
|
||||
{
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testOne
|
||||
*/
|
||||
public function testTwo(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\TestListener;
|
||||
use PHPUnit\Framework\TestListenerDefaultImplementation;
|
||||
|
||||
class Issue3379TestListener implements TestListener
|
||||
{
|
||||
use TestListenerDefaultImplementation;
|
||||
|
||||
public function addSkippedTest(Test $test, \Throwable $t, float $time): void
|
||||
{
|
||||
if ($test instanceof TestCase) {
|
||||
print 'Skipped test ' . $test->getName() . ', status: ' . $test->getStatus() . \PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.4/phpunit.xsd">
|
||||
<testsuites>
|
||||
<testsuite name="default">
|
||||
<directory suffix="Test.php">.</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<listeners>
|
||||
<listener class="Issue3379TestListener" file="./Issue3379TestListener.php"/>
|
||||
</listeners>
|
||||
</phpunit>
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
--TEST--
|
||||
https://github.com/sebastianbergmann/phpunit/issues/3380
|
||||
--FILE--
|
||||
<?php
|
||||
$tmpResultCache = tempnam(sys_get_temp_dir(), __FILE__);
|
||||
file_put_contents($tmpResultCache, file_get_contents(__DIR__ . '/../../../../_files/DataproviderExecutionOrderTest_result_cache.txt'));
|
||||
|
||||
$_SERVER['argv'][1] = '--no-configuration';
|
||||
$_SERVER['argv'][2] = '--order-by=defects';
|
||||
$_SERVER['argv'][3] = '--testdox';
|
||||
$_SERVER['argv'][4] = '--cache-result';
|
||||
$_SERVER['argv'][5] = '--cache-result-file=' . $tmpResultCache;
|
||||
$_SERVER['argv'][6] = \dirname(\dirname(\dirname(__DIR__))) . '/../_files/DataproviderExecutionOrderTest.php';
|
||||
|
||||
require __DIR__ . '/../../../../bootstrap.php';
|
||||
PHPUnit\TextUI\Command::main();
|
||||
|
||||
unlink($tmpResultCache);
|
||||
--EXPECTF--
|
||||
PHPUnit %s by Sebastian Bergmann and contributors.
|
||||
|
||||
DataproviderExecutionOrder
|
||||
✔ First test that always works
|
||||
✔ Add numbers with a dataprovider with data set "1+2=3"
|
||||
✔ Add numbers with a dataprovider with data set "2+1=3"
|
||||
✘ Add numbers with a dataprovider with data set "1+1=3"
|
||||
│
|
||||
│ Failed asserting that 2 is identical to 3.
|
||||
│%w
|
||||
│ %s%etests%e_files%eDataproviderExecutionOrderTest.php:%d
|
||||
│%w
|
||||
|
||||
✔ Test in the middle that always works
|
||||
✔ Add more numbers with a dataprovider with data set "1+2=3"
|
||||
✔ Add more numbers with a dataprovider with data set "2+1=3"
|
||||
✘ Add more numbers with a dataprovider with data set "1+1=3"
|
||||
│
|
||||
│ Failed asserting that 2 is identical to 3.
|
||||
│%w
|
||||
│ %s%etests%e_files%eDataproviderExecutionOrderTest.php:%d
|
||||
│%w
|
||||
|
||||
Time: %s, Memory: %s
|
||||
|
||||
Summary of non-successful tests:
|
||||
|
||||
DataproviderExecutionOrder
|
||||
✘ Add numbers with a dataprovider with data set "1+1=3"
|
||||
│
|
||||
│ Failed asserting that 2 is identical to 3.
|
||||
│%w
|
||||
│ %s%etests%e_files%eDataproviderExecutionOrderTest.php:%d
|
||||
│%w
|
||||
|
||||
✘ Add more numbers with a dataprovider with data set "1+1=3"
|
||||
│
|
||||
│ Failed asserting that 2 is identical to 3.
|
||||
│%w
|
||||
│ %s%etests%e_files%eDataproviderExecutionOrderTest.php:%d
|
||||
│%w
|
||||
|
||||
FAILURES!
|
||||
Tests: 8, Assertions: 8, Failures: 2.
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
--TEST--
|
||||
https://github.com/sebastianbergmann/phpunit/issues/3396
|
||||
--FILE--
|
||||
<?php
|
||||
$tmpResultCache = tempnam(sys_get_temp_dir(), __FILE__);
|
||||
file_put_contents($tmpResultCache, file_get_contents(__DIR__ . '/../../../../_files/DataproviderExecutionOrderTest_result_cache.txt'));
|
||||
|
||||
$_SERVER['argv'][1] = '--no-configuration';
|
||||
$_SERVER['argv'][2] = '--order-by=defects';
|
||||
$_SERVER['argv'][3] = '--debug';
|
||||
$_SERVER['argv'][4] = '--cache-result';
|
||||
$_SERVER['argv'][5] = '--cache-result-file=' . $tmpResultCache;
|
||||
$_SERVER['argv'][6] = \dirname(\dirname(\dirname(__DIR__))) . '/../_files/DataproviderExecutionOrderTest.php';
|
||||
|
||||
require __DIR__ . '/../../../../bootstrap.php';
|
||||
PHPUnit\TextUI\Command::main();
|
||||
|
||||
unlink($tmpResultCache);
|
||||
--EXPECTF--
|
||||
PHPUnit %s by Sebastian Bergmann and contributors.
|
||||
|
||||
Test 'DataproviderExecutionOrderTest::testAddNumbersWithADataprovider with data set "1+1=3" (1, 1, 3)' started
|
||||
Test 'DataproviderExecutionOrderTest::testAddNumbersWithADataprovider with data set "1+1=3" (1, 1, 3)' ended
|
||||
Test 'DataproviderExecutionOrderTest::testAddNumbersWithADataprovider with data set "1+2=3" (1, 2, 3)' started
|
||||
Test 'DataproviderExecutionOrderTest::testAddNumbersWithADataprovider with data set "1+2=3" (1, 2, 3)' ended
|
||||
Test 'DataproviderExecutionOrderTest::testAddNumbersWithADataprovider with data set "2+1=3" (2, 1, 3)' started
|
||||
Test 'DataproviderExecutionOrderTest::testAddNumbersWithADataprovider with data set "2+1=3" (2, 1, 3)' ended
|
||||
Test 'DataproviderExecutionOrderTest::testAddMoreNumbersWithADataprovider with data set "1+1=3" (1, 1, 3)' started
|
||||
Test 'DataproviderExecutionOrderTest::testAddMoreNumbersWithADataprovider with data set "1+1=3" (1, 1, 3)' ended
|
||||
Test 'DataproviderExecutionOrderTest::testAddMoreNumbersWithADataprovider with data set "1+2=3" (1, 2, 3)' started
|
||||
Test 'DataproviderExecutionOrderTest::testAddMoreNumbersWithADataprovider with data set "1+2=3" (1, 2, 3)' ended
|
||||
Test 'DataproviderExecutionOrderTest::testAddMoreNumbersWithADataprovider with data set "2+1=3" (2, 1, 3)' started
|
||||
Test 'DataproviderExecutionOrderTest::testAddMoreNumbersWithADataprovider with data set "2+1=3" (2, 1, 3)' ended
|
||||
Test 'DataproviderExecutionOrderTest::testFirstTestThatAlwaysWorks' started
|
||||
Test 'DataproviderExecutionOrderTest::testFirstTestThatAlwaysWorks' ended
|
||||
Test 'DataproviderExecutionOrderTest::testTestInTheMiddleThatAlwaysWorks' started
|
||||
Test 'DataproviderExecutionOrderTest::testTestInTheMiddleThatAlwaysWorks' ended
|
||||
|
||||
|
||||
Time: %s, Memory: %s
|
||||
|
||||
There were 2 failures:
|
||||
|
||||
1) DataproviderExecutionOrderTest::testAddNumbersWithADataprovider with data set "1+1=3" (1, 1, 3)
|
||||
Failed asserting that 2 is identical to 3.
|
||||
|
||||
%s%etests%e_files%eDataproviderExecutionOrderTest.php:%d
|
||||
|
||||
2) DataproviderExecutionOrderTest::testAddMoreNumbersWithADataprovider with data set "1+1=3" (1, 1, 3)
|
||||
Failed asserting that 2 is identical to 3.
|
||||
|
||||
%s%etests%e_files%eDataproviderExecutionOrderTest.php:%d
|
||||
|
||||
FAILURES!
|
||||
Tests: 8, Assertions: 8, Failures: 2.
|
||||
+1
-1
@@ -13,7 +13,7 @@ class Issue523Test extends TestCase
|
||||
{
|
||||
public function testAttributeEquals(): void
|
||||
{
|
||||
$this->assertAttributeEquals('foo', 'field', new Issue523());
|
||||
$this->assertAttributeEquals('foo', 'field', new Issue523);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+499
-1
@@ -81,7 +81,7 @@ class AssertTest extends TestCase
|
||||
$test = [new \Book, new \Book];
|
||||
|
||||
$this->assertContainsOnlyInstancesOf(\Book::class, $test);
|
||||
$this->assertContainsOnlyInstancesOf(\stdClass::class, [new \stdClass()]);
|
||||
$this->assertContainsOnlyInstancesOf(\stdClass::class, [new \stdClass]);
|
||||
|
||||
$test2 = [new \Author('Test')];
|
||||
|
||||
@@ -113,6 +113,20 @@ class AssertTest extends TestCase
|
||||
$this->assertContains('', 'test');
|
||||
}
|
||||
|
||||
public function testAssertStringContainsNonString(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
|
||||
$this->assertContains(null, '');
|
||||
}
|
||||
|
||||
public function testAssertStringNotContainsNonString(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
|
||||
$this->assertNotContains(null, '');
|
||||
}
|
||||
|
||||
public function testAssertArrayHasKeyThrowsExceptionForInvalidFirstArgument(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
@@ -844,6 +858,8 @@ XML;
|
||||
|
||||
public function testAssertNotIsReadable(): void
|
||||
{
|
||||
$this->assertNotIsReadable(__DIR__ . \DIRECTORY_SEPARATOR . 'NotExisting');
|
||||
|
||||
$this->expectException(AssertionFailedError::class);
|
||||
|
||||
$this->assertNotIsReadable(__FILE__);
|
||||
@@ -860,6 +876,8 @@ XML;
|
||||
|
||||
public function testAssertNotIsWritable(): void
|
||||
{
|
||||
$this->assertNotIsWritable(__DIR__ . \DIRECTORY_SEPARATOR . 'NotExisting');
|
||||
|
||||
$this->expectException(AssertionFailedError::class);
|
||||
|
||||
$this->assertNotIsWritable(__FILE__);
|
||||
@@ -1582,6 +1600,13 @@ XML;
|
||||
$this->assertClassHasAttribute('1', \ClassWithNonPublicAttributes::class);
|
||||
}
|
||||
|
||||
public function testAssertClassHasAttributeThrowsExceptionIfClassDoesNotExist(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
|
||||
$this->assertClassHasAttribute('attribute', 'ClassThatDoesNotExist');
|
||||
}
|
||||
|
||||
public function testAssertClassNotHasAttributeThrowsExceptionIfAttributeNameIsNotValid(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
@@ -1589,6 +1614,13 @@ XML;
|
||||
$this->assertClassNotHasAttribute('1', \ClassWithNonPublicAttributes::class);
|
||||
}
|
||||
|
||||
public function testAssertClassNotHasAttributeThrowsExceptionIfClassDoesNotExist(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
|
||||
$this->assertClassNotHasAttribute('attribute', 'ClassThatDoesNotExist');
|
||||
}
|
||||
|
||||
public function testAssertClassHasStaticAttributeThrowsExceptionIfAttributeNameIsNotValid(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
@@ -1596,6 +1628,13 @@ XML;
|
||||
$this->assertClassHasStaticAttribute('1', \ClassWithNonPublicAttributes::class);
|
||||
}
|
||||
|
||||
public function testAssertClassHasStaticAttributeThrowsExceptionIfClassDoesNotExist(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
|
||||
$this->assertClassHasStaticAttribute('attribute', 'ClassThatDoesNotExist');
|
||||
}
|
||||
|
||||
public function testAssertClassNotHasStaticAttributeThrowsExceptionIfAttributeNameIsNotValid(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
@@ -1603,6 +1642,13 @@ XML;
|
||||
$this->assertClassNotHasStaticAttribute('1', \ClassWithNonPublicAttributes::class);
|
||||
}
|
||||
|
||||
public function testAssertClassNotHasStaticAttributeThrowsExceptionIfClassDoesNotExist(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
|
||||
$this->assertClassNotHasStaticAttribute('attribute', 'ClassThatDoesNotExist');
|
||||
}
|
||||
|
||||
public function testAssertObjectHasAttributeThrowsException2(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
@@ -2397,6 +2443,13 @@ XML;
|
||||
$this->assertJsonFileEqualsJsonFile($file, $file, $message);
|
||||
}
|
||||
|
||||
public function testAssertInstanceOfThrowsExceptionIfTypeDoesNotExist(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
|
||||
$this->assertInstanceOf('ClassThatDoesNotExist', new \stdClass);
|
||||
}
|
||||
|
||||
public function testAssertInstanceOf(): void
|
||||
{
|
||||
$this->assertInstanceOf(\stdClass::class, new \stdClass);
|
||||
@@ -2414,6 +2467,13 @@ XML;
|
||||
$this->assertAttributeInstanceOf(\stdClass::class, 'a', $o);
|
||||
}
|
||||
|
||||
public function testAssertNotInstanceOfThrowsExceptionIfTypeDoesNotExist(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
|
||||
$this->assertNotInstanceOf('ClassThatDoesNotExist', new \stdClass);
|
||||
}
|
||||
|
||||
public function testAssertNotInstanceOf(): void
|
||||
{
|
||||
$this->assertNotInstanceOf(\Exception::class, new \stdClass);
|
||||
@@ -2506,6 +2566,444 @@ XML;
|
||||
$this->assertStringNotMatchesFormatFile(TEST_FILES_PATH . 'expectedFileFormat.txt', "FOO\n");
|
||||
}
|
||||
|
||||
public function testStringsCanBeComparedForEqualityIgnoringCase(): void
|
||||
{
|
||||
$this->assertEqualsIgnoringCase('a', 'A');
|
||||
|
||||
$this->assertNotEqualsIgnoringCase('a', 'B');
|
||||
}
|
||||
|
||||
public function testArraysOfStringsCanBeComparedForEqualityIgnoringCase(): void
|
||||
{
|
||||
$this->assertEqualsIgnoringCase(['a'], ['A']);
|
||||
|
||||
$this->assertNotEqualsIgnoringCase(['a'], ['B']);
|
||||
}
|
||||
|
||||
public function testStringsCanBeComparedForEqualityWithDelta(): void
|
||||
{
|
||||
$this->assertEqualsWithDelta(2.3, 2.5, 0.5);
|
||||
|
||||
$this->assertNotEqualsWithDelta(2.3, 3.5, 0.5);
|
||||
}
|
||||
|
||||
public function testArraysOfStringsCanBeComparedForEqualityWithDelta(): void
|
||||
{
|
||||
$this->assertEqualsWithDelta([2.3], [2.5], 0.5);
|
||||
|
||||
$this->assertNotEqualsWithDelta([2.3], [3.5], 0.5);
|
||||
}
|
||||
|
||||
public function testArraysCanBeComparedForEqualityWithCanonicalization(): void
|
||||
{
|
||||
$this->assertEqualsCanonicalizing([3, 2, 1], [2, 3, 1]);
|
||||
|
||||
$this->assertNotEqualsCanonicalizing([3, 2, 1], [2, 3, 4]);
|
||||
}
|
||||
|
||||
public function testArrayTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsArray([]);
|
||||
|
||||
try {
|
||||
$this->assertIsArray(null);
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testBoolTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsBool(true);
|
||||
|
||||
try {
|
||||
$this->assertIsBool(null);
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testFloatTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsFloat(0.0);
|
||||
|
||||
try {
|
||||
$this->assertIsFloat(null);
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testIntTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsInt(1);
|
||||
|
||||
try {
|
||||
$this->assertIsInt(null);
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testNumericTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsNumeric('1.0');
|
||||
|
||||
try {
|
||||
$this->assertIsNumeric('abc');
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testObjectTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsObject(new \stdClass);
|
||||
|
||||
try {
|
||||
$this->assertIsObject(null);
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testResourceTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsResource(\fopen(__FILE__, 'r'));
|
||||
|
||||
try {
|
||||
$this->assertIsResource(null);
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testStringTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsString('');
|
||||
|
||||
try {
|
||||
$this->assertIsString(null);
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testScalarTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsScalar(true);
|
||||
|
||||
try {
|
||||
$this->assertIsScalar(new \stdClass);
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testCallableTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsCallable(function () {
|
||||
});
|
||||
|
||||
try {
|
||||
$this->assertIsCallable(null);
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testIterableTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsIterable([]);
|
||||
|
||||
try {
|
||||
$this->assertIsIterable(null);
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testNotArrayTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsNotArray(null);
|
||||
|
||||
try {
|
||||
$this->assertIsNotArray([]);
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testNotBoolTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsNotBool(null);
|
||||
|
||||
try {
|
||||
$this->assertIsNotBool(true);
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testNotFloatTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsNotFloat(null);
|
||||
|
||||
try {
|
||||
$this->assertIsNotFloat(0.0);
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testNotIntTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsNotInt(null);
|
||||
|
||||
try {
|
||||
$this->assertIsNotInt(1);
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testNotNumericTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsNotNumeric('abc');
|
||||
|
||||
try {
|
||||
$this->assertIsNotNumeric('1.0');
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testNotObjectTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsNotObject(null);
|
||||
|
||||
try {
|
||||
$this->assertIsNotObject(new \stdClass);
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testNotResourceTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsNotResource(null);
|
||||
|
||||
try {
|
||||
$this->assertIsNotResource(\fopen(__FILE__, 'r'));
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testNotScalarTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsNotScalar(new \stdClass);
|
||||
|
||||
try {
|
||||
$this->assertIsNotScalar(true);
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testNotStringTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsNotString(null);
|
||||
|
||||
try {
|
||||
$this->assertIsNotString('');
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testNotCallableTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsNotCallable(null);
|
||||
|
||||
try {
|
||||
$this->assertIsNotCallable(function () {
|
||||
});
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testNotIterableTypeCanBeAsserted(): void
|
||||
{
|
||||
$this->assertIsNotIterable(null);
|
||||
|
||||
try {
|
||||
$this->assertIsNotIterable([]);
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testLogicalAnd(): void
|
||||
{
|
||||
$this->assertThat(
|
||||
true,
|
||||
$this->logicalAnd(
|
||||
$this->isTrue(),
|
||||
$this->isTrue()
|
||||
)
|
||||
);
|
||||
|
||||
$this->expectException(AssertionFailedError::class);
|
||||
|
||||
$this->assertThat(
|
||||
true,
|
||||
$this->logicalAnd(
|
||||
$this->isTrue(),
|
||||
$this->isFalse()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testLogicalOr(): void
|
||||
{
|
||||
$this->assertThat(
|
||||
true,
|
||||
$this->logicalOr(
|
||||
$this->isTrue(),
|
||||
$this->isFalse()
|
||||
)
|
||||
);
|
||||
|
||||
$this->expectException(AssertionFailedError::class);
|
||||
|
||||
$this->assertThat(
|
||||
true,
|
||||
$this->logicalOr(
|
||||
$this->isFalse(),
|
||||
$this->isFalse()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testLogicalXor(): void
|
||||
{
|
||||
$this->assertThat(
|
||||
true,
|
||||
$this->logicalXor(
|
||||
$this->isTrue(),
|
||||
$this->isFalse()
|
||||
)
|
||||
);
|
||||
|
||||
$this->expectException(AssertionFailedError::class);
|
||||
|
||||
$this->assertThat(
|
||||
true,
|
||||
$this->logicalXor(
|
||||
$this->isTrue(),
|
||||
$this->isTrue()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testStringContainsStringCanBeAsserted(): void
|
||||
{
|
||||
$this->assertStringContainsString('bar', 'foobarbaz');
|
||||
|
||||
try {
|
||||
$this->assertStringContainsString('barbara', 'foobarbaz');
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testStringNotContainsStringCanBeAsserted(): void
|
||||
{
|
||||
$this->assertStringNotContainsString('barbara', 'foobarbaz');
|
||||
|
||||
try {
|
||||
$this->assertStringNotContainsString('bar', 'foobarbaz');
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testStringContainsStringCanBeAssertedIgnoringCase(): void
|
||||
{
|
||||
$this->assertStringContainsStringIgnoringCase('BAR', 'foobarbaz');
|
||||
|
||||
try {
|
||||
$this->assertStringContainsStringIgnoringCase('BARBARA', 'foobarbaz');
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
public function testStringNotContainsStringCanBeAssertedIgnoringCase(): void
|
||||
{
|
||||
$this->assertStringNotContainsStringIgnoringCase('BARBARA', 'foobarbaz');
|
||||
|
||||
try {
|
||||
$this->assertStringNotContainsStringIgnoringCase('BAR', 'foobarbaz');
|
||||
} catch (AssertionFailedError $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail();
|
||||
}
|
||||
|
||||
protected function sameValues(): array
|
||||
{
|
||||
$object = new \SampleClass(4, 8, 15);
|
||||
|
||||
+4
-4
@@ -16,7 +16,7 @@ class DirectoryExistsTest extends ConstraintTestCase
|
||||
{
|
||||
public function testDefaults(): void
|
||||
{
|
||||
$constraint = new DirectoryExists();
|
||||
$constraint = new DirectoryExists;
|
||||
|
||||
$this->assertCount(1, $constraint);
|
||||
$this->assertSame('directory exists', $constraint->toString());
|
||||
@@ -26,7 +26,7 @@ class DirectoryExistsTest extends ConstraintTestCase
|
||||
{
|
||||
$directory = __DIR__ . '/NonExistentDirectory';
|
||||
|
||||
$constraint = new DirectoryExists();
|
||||
$constraint = new DirectoryExists;
|
||||
|
||||
$this->assertFalse($constraint->evaluate($directory, '', true));
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class DirectoryExistsTest extends ConstraintTestCase
|
||||
{
|
||||
$directory = __DIR__;
|
||||
|
||||
$constraint = new DirectoryExists();
|
||||
$constraint = new DirectoryExists;
|
||||
|
||||
$this->assertTrue($constraint->evaluate($directory, '', true));
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class DirectoryExistsTest extends ConstraintTestCase
|
||||
{
|
||||
$directory = __DIR__ . '/NonExistentDirectory';
|
||||
|
||||
$constraint = new DirectoryExists();
|
||||
$constraint = new DirectoryExists;
|
||||
|
||||
try {
|
||||
$constraint->evaluate($directory);
|
||||
|
||||
@@ -16,7 +16,7 @@ class FileExistsTest extends ConstraintTestCase
|
||||
{
|
||||
public function testConstraintFileExists(): void
|
||||
{
|
||||
$constraint = new FileExists();
|
||||
$constraint = new FileExists;
|
||||
|
||||
$this->assertFalse($constraint->evaluate('foo', '', true));
|
||||
$this->assertEquals('file exists', $constraint->toString());
|
||||
@@ -42,7 +42,7 @@ EOF
|
||||
|
||||
public function testConstraintFileExists2(): void
|
||||
{
|
||||
$constraint = new FileExists();
|
||||
$constraint = new FileExists;
|
||||
|
||||
try {
|
||||
$constraint->evaluate('foo', 'custom message');
|
||||
|
||||
@@ -16,7 +16,7 @@ class IsEmptyTest extends ConstraintTestCase
|
||||
{
|
||||
public function testConstraintIsEmpty(): void
|
||||
{
|
||||
$constraint = new IsEmpty();
|
||||
$constraint = new IsEmpty;
|
||||
|
||||
$this->assertFalse($constraint->evaluate(['foo'], '', true));
|
||||
$this->assertTrue($constraint->evaluate([], '', true));
|
||||
@@ -45,7 +45,7 @@ EOF
|
||||
|
||||
public function testConstraintIsEmpty2(): void
|
||||
{
|
||||
$constraint = new IsEmpty();
|
||||
$constraint = new IsEmpty;
|
||||
|
||||
try {
|
||||
$constraint->evaluate(['foo'], 'custom message');
|
||||
|
||||
@@ -16,7 +16,7 @@ class IsNullTest extends ConstraintTestCase
|
||||
{
|
||||
public function testConstraintIsNull(): void
|
||||
{
|
||||
$constraint = new IsNull();
|
||||
$constraint = new IsNull;
|
||||
|
||||
$this->assertFalse($constraint->evaluate(0, '', true));
|
||||
$this->assertTrue($constraint->evaluate(null, '', true));
|
||||
@@ -43,7 +43,7 @@ EOF
|
||||
|
||||
public function testConstraintIsNull2(): void
|
||||
{
|
||||
$constraint = new IsNull();
|
||||
$constraint = new IsNull;
|
||||
|
||||
try {
|
||||
$constraint->evaluate(0, 'custom message');
|
||||
|
||||
@@ -16,7 +16,7 @@ class IsReadableTest extends ConstraintTestCase
|
||||
{
|
||||
public function testConstraintIsReadable(): void
|
||||
{
|
||||
$constraint = new IsReadable();
|
||||
$constraint = new IsReadable;
|
||||
|
||||
$this->assertFalse($constraint->evaluate('foo', '', true));
|
||||
$this->assertEquals('is readable', $constraint->toString());
|
||||
|
||||
@@ -16,7 +16,7 @@ class IsWritableTest extends ConstraintTestCase
|
||||
{
|
||||
public function testConstraintIsWritable(): void
|
||||
{
|
||||
$constraint = new IsWritable();
|
||||
$constraint = new IsWritable;
|
||||
|
||||
$this->assertFalse($constraint->evaluate('foo', '', true));
|
||||
$this->assertEquals('is writable', $constraint->toString());
|
||||
|
||||
+19
-19
@@ -18,12 +18,12 @@ final class LogicalAndTest extends ConstraintTestCase
|
||||
public function testSetConstraintsRejectsInvalidConstraint(): void
|
||||
{
|
||||
$constraints = [
|
||||
new \TruthyConstraint(),
|
||||
new \FalsyConstraint(),
|
||||
new \stdClass(),
|
||||
new \TruthyConstraint,
|
||||
new \FalsyConstraint,
|
||||
new \stdClass,
|
||||
];
|
||||
|
||||
$constraint = new LogicalAnd();
|
||||
$constraint = new LogicalAnd;
|
||||
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionMessage(\sprintf(
|
||||
@@ -46,7 +46,7 @@ final class LogicalAndTest extends ConstraintTestCase
|
||||
return \CountConstraint::fromCount($count);
|
||||
}, $counts);
|
||||
|
||||
$constraint = new LogicalAnd();
|
||||
$constraint = new LogicalAnd;
|
||||
|
||||
$constraint->setConstraints($constraints);
|
||||
|
||||
@@ -67,7 +67,7 @@ final class LogicalAndTest extends ConstraintTestCase
|
||||
return \NamedConstraint::fromName($name);
|
||||
}, $names);
|
||||
|
||||
$constraint = new LogicalAnd();
|
||||
$constraint = new LogicalAnd;
|
||||
|
||||
$constraint->setConstraints($constraints);
|
||||
|
||||
@@ -83,7 +83,7 @@ final class LogicalAndTest extends ConstraintTestCase
|
||||
*/
|
||||
public function testEvaluateReturnsFalseIfAnyOfTheComposedConstraintsEvaluateToFalse(array $constraints): void
|
||||
{
|
||||
$constraint = new LogicalAnd();
|
||||
$constraint = new LogicalAnd;
|
||||
|
||||
$constraint->setConstraints($constraints);
|
||||
|
||||
@@ -97,7 +97,7 @@ final class LogicalAndTest extends ConstraintTestCase
|
||||
*/
|
||||
public function testEvaluateReturnsTrueIfAllOfTheComposedConstraintsEvaluateToTrue(array $constraints): void
|
||||
{
|
||||
$constraint = new LogicalAnd();
|
||||
$constraint = new LogicalAnd;
|
||||
|
||||
$constraint->setConstraints($constraints);
|
||||
|
||||
@@ -113,7 +113,7 @@ final class LogicalAndTest extends ConstraintTestCase
|
||||
{
|
||||
$other = 'whatever';
|
||||
|
||||
$constraint = new LogicalAnd();
|
||||
$constraint = new LogicalAnd;
|
||||
|
||||
$constraint->setConstraints($constraints);
|
||||
|
||||
@@ -145,7 +145,7 @@ EOF;
|
||||
$other = 'whatever';
|
||||
$customDescription = 'Not very happy about the results at this point in time, I have to admit!';
|
||||
|
||||
$constraint = new LogicalAnd();
|
||||
$constraint = new LogicalAnd;
|
||||
|
||||
$constraint->setConstraints($constraints);
|
||||
|
||||
@@ -178,7 +178,7 @@ EOF;
|
||||
*/
|
||||
public function testEvaluateReturnsNothingIfAllOfTheComposedConstraintsEvaluateToTrue(array $constraints): void
|
||||
{
|
||||
$constraint = new LogicalAnd();
|
||||
$constraint = new LogicalAnd;
|
||||
|
||||
$constraint->setConstraints($constraints);
|
||||
|
||||
@@ -189,12 +189,12 @@ EOF;
|
||||
{
|
||||
$values = [
|
||||
'single' => [
|
||||
new \FalsyConstraint(),
|
||||
new \FalsyConstraint,
|
||||
],
|
||||
'multiple' => [
|
||||
new \TruthyConstraint(),
|
||||
new \FalsyConstraint(),
|
||||
new \TruthyConstraint(),
|
||||
new \TruthyConstraint,
|
||||
new \FalsyConstraint,
|
||||
new \TruthyConstraint,
|
||||
],
|
||||
];
|
||||
|
||||
@@ -209,12 +209,12 @@ EOF;
|
||||
{
|
||||
$values = [
|
||||
'single' => [
|
||||
new \TruthyConstraint(),
|
||||
new \TruthyConstraint,
|
||||
],
|
||||
'multiple' => [
|
||||
new \TruthyConstraint(),
|
||||
new \TruthyConstraint(),
|
||||
new \TruthyConstraint(),
|
||||
new \TruthyConstraint,
|
||||
new \TruthyConstraint,
|
||||
new \TruthyConstraint,
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
@@ -17,14 +17,14 @@ final class LogicalOrTest extends ConstraintTestCase
|
||||
public function testSetConstraintsDecoratesNonConstraintWithIsEqual(): void
|
||||
{
|
||||
$constraints = [
|
||||
new \stdClass(),
|
||||
new \stdClass,
|
||||
];
|
||||
|
||||
$constraint = new LogicalOr();
|
||||
$constraint = new LogicalOr;
|
||||
|
||||
$constraint->setConstraints($constraints);
|
||||
|
||||
$this->assertTrue($constraint->evaluate(new \stdClass(), '', true));
|
||||
$this->assertTrue($constraint->evaluate(new \stdClass, '', true));
|
||||
}
|
||||
|
||||
public function testCountReturnsCountOfComposedConstraints(): void
|
||||
@@ -39,7 +39,7 @@ final class LogicalOrTest extends ConstraintTestCase
|
||||
return \CountConstraint::fromCount($count);
|
||||
}, $counts);
|
||||
|
||||
$constraint = new LogicalOr();
|
||||
$constraint = new LogicalOr;
|
||||
|
||||
$constraint->setConstraints($constraints);
|
||||
|
||||
@@ -60,7 +60,7 @@ final class LogicalOrTest extends ConstraintTestCase
|
||||
return \NamedConstraint::fromName($name);
|
||||
}, $names);
|
||||
|
||||
$constraint = new LogicalOr();
|
||||
$constraint = new LogicalOr;
|
||||
|
||||
$constraint->setConstraints($constraints);
|
||||
|
||||
@@ -76,7 +76,7 @@ final class LogicalOrTest extends ConstraintTestCase
|
||||
*/
|
||||
public function testEvaluateReturnsFalseIfAllOfTheComposedConstraintsEvaluateToFalse(array $constraints): void
|
||||
{
|
||||
$constraint = new LogicalOr();
|
||||
$constraint = new LogicalOr;
|
||||
|
||||
$constraint->setConstraints($constraints);
|
||||
|
||||
@@ -90,7 +90,7 @@ final class LogicalOrTest extends ConstraintTestCase
|
||||
*/
|
||||
public function testEvaluateReturnsTrueIfAnyOfTheComposedConstraintsEvaluateToTrue(array $constraints): void
|
||||
{
|
||||
$constraint = new LogicalOr();
|
||||
$constraint = new LogicalOr;
|
||||
|
||||
$constraint->setConstraints($constraints);
|
||||
|
||||
@@ -106,7 +106,7 @@ final class LogicalOrTest extends ConstraintTestCase
|
||||
{
|
||||
$other = 'whatever';
|
||||
|
||||
$constraint = new LogicalOr();
|
||||
$constraint = new LogicalOr;
|
||||
|
||||
$constraint->setConstraints($constraints);
|
||||
|
||||
@@ -138,7 +138,7 @@ EOF;
|
||||
$other = 'whatever';
|
||||
$customDescription = 'Not very happy about the results at this point in time, I have to admit!';
|
||||
|
||||
$constraint = new LogicalOr();
|
||||
$constraint = new LogicalOr;
|
||||
|
||||
$constraint->setConstraints($constraints);
|
||||
|
||||
@@ -171,7 +171,7 @@ EOF;
|
||||
*/
|
||||
public function testEvaluateReturnsNothingIfAnyOfTheComposedConstraintsEvaluateToTrue(array $constraints): void
|
||||
{
|
||||
$constraint = new LogicalOr();
|
||||
$constraint = new LogicalOr;
|
||||
|
||||
$constraint->setConstraints($constraints);
|
||||
|
||||
@@ -182,14 +182,14 @@ EOF;
|
||||
{
|
||||
$values = [
|
||||
'single' => [
|
||||
new \FalsyConstraint(),
|
||||
new \FalsyConstraint(),
|
||||
new \FalsyConstraint(),
|
||||
new \FalsyConstraint,
|
||||
new \FalsyConstraint,
|
||||
new \FalsyConstraint,
|
||||
],
|
||||
'multiple' => [
|
||||
new \FalsyConstraint(),
|
||||
new \FalsyConstraint(),
|
||||
new \FalsyConstraint(),
|
||||
new \FalsyConstraint,
|
||||
new \FalsyConstraint,
|
||||
new \FalsyConstraint,
|
||||
],
|
||||
];
|
||||
|
||||
@@ -204,12 +204,12 @@ EOF;
|
||||
{
|
||||
$values = [
|
||||
'single' => [
|
||||
new \TruthyConstraint(),
|
||||
new \TruthyConstraint,
|
||||
],
|
||||
'multiple' => [
|
||||
new \FalsyConstraint(),
|
||||
new \TruthyConstraint(),
|
||||
new \FalsyConstraint(),
|
||||
new \FalsyConstraint,
|
||||
new \TruthyConstraint,
|
||||
new \FalsyConstraint,
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ class MockObjectTest extends TestCase
|
||||
|
||||
$mock->expects($this->any())
|
||||
->method('doSomething')
|
||||
->will($this->throwException(new \Exception()));
|
||||
->will($this->throwException(new \Exception));
|
||||
|
||||
$this->expectException(\Exception::class);
|
||||
|
||||
@@ -185,7 +185,7 @@ class MockObjectTest extends TestCase
|
||||
|
||||
$mock->expects($this->any())
|
||||
->method('doSomething')
|
||||
->willThrowException(new \Exception());
|
||||
->willThrowException(new \Exception);
|
||||
|
||||
$this->expectException(\Exception::class);
|
||||
|
||||
@@ -660,7 +660,7 @@ class MockObjectTest extends TestCase
|
||||
$this->fail('Expected exception');
|
||||
} catch (ExpectationFailedException $e) {
|
||||
$this->assertSame(
|
||||
'Expectation failed for method name is equal to "right" when invoked 1 time(s).' . "\n" .
|
||||
"Expectation failed for method name is equal to 'right' when invoked 1 time(s).\n" .
|
||||
'Method was expected to be called 1 times, actually called 0 times.' . "\n",
|
||||
$e->getMessage()
|
||||
);
|
||||
@@ -685,7 +685,7 @@ class MockObjectTest extends TestCase
|
||||
$this->fail('Expected exception');
|
||||
} catch (ExpectationFailedException $e) {
|
||||
$this->assertSame(
|
||||
'Expectation failed for method name is equal to "right" when invoked 1 time(s).' . "\n" .
|
||||
"Expectation failed for method name is equal to 'right' when invoked 1 time(s).\n" .
|
||||
'Method was expected to be called 1 times, actually called 0 times.' . "\n",
|
||||
$e->getMessage()
|
||||
);
|
||||
@@ -708,7 +708,7 @@ class MockObjectTest extends TestCase
|
||||
$mock->right(['second']);
|
||||
} catch (ExpectationFailedException $e) {
|
||||
$this->assertSame(
|
||||
'Expectation failed for method name is equal to "right" when invoked 1 time(s)' . "\n" .
|
||||
"Expectation failed for method name is equal to 'right' when invoked 1 time(s)\n" .
|
||||
'Parameter 0 for invocation SomeClass::right(Array (...)) does not match expected value.' . "\n" .
|
||||
'Failed asserting that two arrays are equal.',
|
||||
$e->getMessage()
|
||||
@@ -722,7 +722,7 @@ class MockObjectTest extends TestCase
|
||||
// $this->fail('Expected exception');
|
||||
} catch (ExpectationFailedException $e) {
|
||||
$this->assertSame(
|
||||
'Expectation failed for method name is equal to "right" when invoked 1 time(s).' . "\n" .
|
||||
"Expectation failed for method name is equal to 'right' when invoked 1 time(s).\n" .
|
||||
'Parameter 0 for invocation SomeClass::right(Array (...)) does not match expected value.' . "\n" .
|
||||
'Failed asserting that two arrays are equal.' . "\n" .
|
||||
'--- Expected' . "\n" .
|
||||
@@ -801,7 +801,7 @@ class MockObjectTest extends TestCase
|
||||
$this->fail('Expected exception');
|
||||
} catch (ExpectationFailedException $e) {
|
||||
$this->assertSame(
|
||||
'Expectation failed for method name is equal to "right" when invoked 1 time(s)' . "\n" .
|
||||
"Expectation failed for method name is equal to 'right' when invoked 1 time(s)\n" .
|
||||
'Parameter count for invocation SomeClass::right() is too low.' . "\n" .
|
||||
'To allow 0 or more parameters with any value, omit ->with() or use ->withAnyParameters() instead.',
|
||||
$e->getMessage()
|
||||
@@ -947,7 +947,7 @@ class MockObjectTest extends TestCase
|
||||
*/
|
||||
public function testCreateMockOfWsdlFileWithSpecialChars(): void
|
||||
{
|
||||
$mock = $this->getMockFromWsdl(__DIR__ . '/_fixture/Go ogle-Sea.rch.wsdl');
|
||||
$mock = $this->getMockFromWsdl(TEST_FILES_PATH . 'Go ogle-Sea.rch.wsdl');
|
||||
|
||||
$this->assertStringStartsWith('Mock_GoogleSearch_', \get_class($mock));
|
||||
}
|
||||
@@ -1000,7 +1000,7 @@ class MockObjectTest extends TestCase
|
||||
/** @var PHPUnit\Framework\MockObject\MockObject|StringableClass $mock */
|
||||
$mock = $this->getMockBuilder(StringableClass::class)->getMock();
|
||||
|
||||
$this->assertInternalType('string', (string) $mock);
|
||||
$this->assertIsString((string) $mock);
|
||||
}
|
||||
|
||||
public function testStringableClassCanBeMocked(): void
|
||||
|
||||
@@ -723,7 +723,7 @@ class TestCaseTest extends TestCase
|
||||
$test = new \TestAutoreferenced('testJsonEncodeException', $this->getAutoreferencedArray());
|
||||
$test->runBare();
|
||||
|
||||
$this->assertInternalType('array', $test->myTestData);
|
||||
$this->assertIsArray($test->myTestData);
|
||||
$this->assertArrayHasKey('data', $test->myTestData);
|
||||
$this->assertEquals($test->myTestData['data'][0], $test->myTestData['data']);
|
||||
}
|
||||
@@ -739,13 +739,13 @@ class TestCaseTest extends TestCase
|
||||
$test = new \TestAutoreferenced('testJsonEncodeException', [$data]);
|
||||
$test->runBare();
|
||||
|
||||
$this->assertInternalType('array', $test->myTestData);
|
||||
$this->assertIsArray($test->myTestData);
|
||||
$this->assertSame($data, $test->myTestData);
|
||||
}
|
||||
|
||||
public function testGettingNullTestResultObject(): void
|
||||
{
|
||||
$test = new \Success();
|
||||
$test = new \Success;
|
||||
$this->assertNull($test->getTestResultObject());
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
use PHPUnit\Framework\Error\Error;
|
||||
use SebastianBergmann\Comparator\ComparisonFailure;
|
||||
|
||||
class TestFailureTest extends TestCase
|
||||
{
|
||||
public function testToString(): void
|
||||
@@ -29,6 +32,15 @@ class TestFailureTest extends TestCase
|
||||
$this->assertEquals(__METHOD__ . ': message', $failure->toString());
|
||||
}
|
||||
|
||||
public function testToStringForNonSelfDescribing(): void
|
||||
{
|
||||
$test = new \NotSelfDescribingTest();
|
||||
$exception = new Exception('message');
|
||||
$failure = new TestFailure($test, $exception);
|
||||
|
||||
$this->assertEquals('NotSelfDescribingTest: message', $failure->toString());
|
||||
}
|
||||
|
||||
public function testgetExceptionAsString(): void
|
||||
{
|
||||
$test = new self(__FUNCTION__);
|
||||
@@ -37,4 +49,93 @@ class TestFailureTest extends TestCase
|
||||
|
||||
$this->assertEquals("Error: message\n", $failure->getExceptionAsString());
|
||||
}
|
||||
|
||||
public function testExceptionToString(): void
|
||||
{
|
||||
$exception = new AssertionFailedError('message');
|
||||
|
||||
$this->assertEquals("message\n", TestFailure::exceptionToString($exception));
|
||||
}
|
||||
|
||||
public function testExceptionToStringForExpectationFailedException(): void
|
||||
{
|
||||
$exception = new ExpectationFailedException('message');
|
||||
|
||||
$this->assertEquals("message\n", TestFailure::exceptionToString($exception));
|
||||
}
|
||||
|
||||
public function testExceptionToStringForExpectationFailedExceptionWithComparisonFailure(): void
|
||||
{
|
||||
$exception = new ExpectationFailedException('message', new ComparisonFailure('expected', 'actual', 'expected', 'actual'));
|
||||
|
||||
$this->assertEquals("message\n--- Expected\n+++ Actual\n@@ @@\n-expected\n+actual\n", TestFailure::exceptionToString($exception));
|
||||
}
|
||||
|
||||
public function testExceptionToStringForFrameworkError(): void
|
||||
{
|
||||
$exception = new Error('message', 0, 'file', 1);
|
||||
|
||||
$this->assertEquals("message\n", TestFailure::exceptionToString($exception));
|
||||
}
|
||||
|
||||
public function testExceptionToStringForExceptionWrapper(): void
|
||||
{
|
||||
$exception = new ExceptionWrapper(new \Error('message'));
|
||||
|
||||
$this->assertEquals("Error: message\n", TestFailure::exceptionToString($exception));
|
||||
}
|
||||
|
||||
public function testGetTestName(): void
|
||||
{
|
||||
$test = new self(__FUNCTION__);
|
||||
$exception = new Exception('message');
|
||||
$failure = new TestFailure($test, $exception);
|
||||
|
||||
$this->assertEquals($this->toString(), $failure->getTestName());
|
||||
}
|
||||
|
||||
public function testFailedTest(): void
|
||||
{
|
||||
$test = new self(__FUNCTION__);
|
||||
$exception = new Exception('message');
|
||||
$failure = new TestFailure($test, $exception);
|
||||
|
||||
$this->assertEquals($test, $failure->failedTest());
|
||||
}
|
||||
|
||||
public function testThrownException(): void
|
||||
{
|
||||
$test = new self(__FUNCTION__);
|
||||
$exception = new Exception('message');
|
||||
$failure = new TestFailure($test, $exception);
|
||||
|
||||
$this->assertEquals($exception, $failure->thrownException());
|
||||
}
|
||||
|
||||
public function testExceptionMessage(): void
|
||||
{
|
||||
$test = new self(__FUNCTION__);
|
||||
$exception = new Exception('message');
|
||||
$failure = new TestFailure($test, $exception);
|
||||
|
||||
$this->assertEquals('message', $failure->exceptionMessage());
|
||||
}
|
||||
|
||||
public function testIsFailure(): void
|
||||
{
|
||||
$test = new self(__FUNCTION__);
|
||||
$exception = new ExpectationFailedException('message');
|
||||
$failure = new TestFailure($test, $exception);
|
||||
|
||||
$this->assertTrue($failure->isFailure());
|
||||
}
|
||||
|
||||
public function testIsFailureFalse(): void
|
||||
{
|
||||
$test = new self(__FUNCTION__);
|
||||
$exception = new Warning('message');
|
||||
$failure = new TestFailure($test, $exception);
|
||||
|
||||
$this->assertFalse($failure->isFailure());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,85 +9,26 @@
|
||||
*/
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
class TestListenerTest extends TestCase implements TestListener
|
||||
use MyTestListener;
|
||||
|
||||
final class TestListenerTest extends TestCase
|
||||
{
|
||||
protected $endCount;
|
||||
/**
|
||||
* @var TestResult
|
||||
*/
|
||||
private $result;
|
||||
|
||||
protected $errorCount;
|
||||
|
||||
protected $failureCount;
|
||||
|
||||
protected $warningCount;
|
||||
|
||||
protected $notImplementedCount;
|
||||
|
||||
protected $riskyCount;
|
||||
|
||||
protected $skippedCount;
|
||||
|
||||
protected $result;
|
||||
|
||||
protected $startCount;
|
||||
/**
|
||||
* @var MyTestListener
|
||||
*/
|
||||
private $listener;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->result = new TestResult;
|
||||
$this->result->addListener($this);
|
||||
$this->result = new TestResult;
|
||||
$this->listener = new MyTestListener;
|
||||
|
||||
$this->endCount = 0;
|
||||
$this->failureCount = 0;
|
||||
$this->notImplementedCount = 0;
|
||||
$this->riskyCount = 0;
|
||||
$this->skippedCount = 0;
|
||||
$this->startCount = 0;
|
||||
}
|
||||
|
||||
public function addError(Test $test, \Throwable $t, float $time): void
|
||||
{
|
||||
$this->errorCount++;
|
||||
}
|
||||
|
||||
public function addWarning(Test $test, Warning $e, float $time): void
|
||||
{
|
||||
$this->warningCount++;
|
||||
}
|
||||
|
||||
public function addFailure(Test $test, AssertionFailedError $e, float $time): void
|
||||
{
|
||||
$this->failureCount++;
|
||||
}
|
||||
|
||||
public function addIncompleteTest(Test $test, \Throwable $t, float $time): void
|
||||
{
|
||||
$this->notImplementedCount++;
|
||||
}
|
||||
|
||||
public function addRiskyTest(Test $test, \Throwable $t, float $time): void
|
||||
{
|
||||
$this->riskyCount++;
|
||||
}
|
||||
|
||||
public function addSkippedTest(Test $test, \Throwable $t, float $time): void
|
||||
{
|
||||
$this->skippedCount++;
|
||||
}
|
||||
|
||||
public function startTestSuite(TestSuite $suite): void
|
||||
{
|
||||
}
|
||||
|
||||
public function endTestSuite(TestSuite $suite): void
|
||||
{
|
||||
}
|
||||
|
||||
public function startTest(Test $test): void
|
||||
{
|
||||
$this->startCount++;
|
||||
}
|
||||
|
||||
public function endTest(Test $test, float $time): void
|
||||
{
|
||||
$this->endCount++;
|
||||
$this->result->addListener($this->listener);
|
||||
}
|
||||
|
||||
public function testError(): void
|
||||
@@ -95,8 +36,8 @@ class TestListenerTest extends TestCase implements TestListener
|
||||
$test = new \TestError;
|
||||
$test->run($this->result);
|
||||
|
||||
$this->assertEquals(1, $this->errorCount);
|
||||
$this->assertEquals(1, $this->endCount);
|
||||
$this->assertEquals(1, $this->listener->errorCount());
|
||||
$this->assertEquals(1, $this->listener->endCount());
|
||||
}
|
||||
|
||||
public function testFailure(): void
|
||||
@@ -104,8 +45,8 @@ class TestListenerTest extends TestCase implements TestListener
|
||||
$test = new \Failure;
|
||||
$test->run($this->result);
|
||||
|
||||
$this->assertEquals(1, $this->failureCount);
|
||||
$this->assertEquals(1, $this->endCount);
|
||||
$this->assertEquals(1, $this->listener->failureCount());
|
||||
$this->assertEquals(1, $this->listener->endCount());
|
||||
}
|
||||
|
||||
public function testStartStop(): void
|
||||
@@ -113,7 +54,7 @@ class TestListenerTest extends TestCase implements TestListener
|
||||
$test = new \Success;
|
||||
$test->run($this->result);
|
||||
|
||||
$this->assertEquals(1, $this->startCount);
|
||||
$this->assertEquals(1, $this->endCount);
|
||||
$this->assertEquals(1, $this->listener->startCount());
|
||||
$this->assertEquals(1, $this->listener->endCount());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class TestResultTest extends TestCase
|
||||
{
|
||||
public function testRemoveListenerRemovesOnlyExpectedListener(): void
|
||||
{
|
||||
$result = new TestResult();
|
||||
$result = new TestResult;
|
||||
$firstListener = $this->getMockBuilder(TestListener::class)->getMock();
|
||||
$secondListener = $this->getMockBuilder(TestListener::class)->getMock();
|
||||
$thirdListener = $this->getMockBuilder(TestListener::class)->getMock();
|
||||
@@ -37,8 +37,8 @@ class TestResultTest extends TestCase
|
||||
public function testAddErrorOfTypeIncompleteTest(): void
|
||||
{
|
||||
$time = 17;
|
||||
$throwable = new IncompleteTestError();
|
||||
$result = new TestResult();
|
||||
$throwable = new IncompleteTestError;
|
||||
$result = new TestResult;
|
||||
$test = $this->getMockBuilder(Test::class)->getMock();
|
||||
$listener = $this->getMockBuilder(TestListener::class)->getMock();
|
||||
|
||||
@@ -79,7 +79,7 @@ class TestResultTest extends TestCase
|
||||
{
|
||||
require_once TEST_FILES_PATH . $testCase . '.php';
|
||||
|
||||
$test = new $testCase();
|
||||
$test = new $testCase;
|
||||
$canSkipCoverage = TestResult::isAnyCoverageRequired($test);
|
||||
$this->assertEquals($expectedCanSkip, $canSkipCoverage);
|
||||
}
|
||||
|
||||
@@ -84,6 +84,16 @@ EOF;
|
||||
$this->testCase = null;
|
||||
}
|
||||
|
||||
public function testAlwaysReportsNumberOfAssertionsIsOne(): void
|
||||
{
|
||||
$this->assertSame(1, $this->testCase->getNumAssertions());
|
||||
}
|
||||
|
||||
public function testAlwaysReportsItDoesNotUseADataprovider(): void
|
||||
{
|
||||
$this->assertSame(false, $this->testCase->usesDataProvider());
|
||||
}
|
||||
|
||||
public function testShouldRunFileSectionAsTest(): void
|
||||
{
|
||||
$this->setPhpContent($this->ensureCorrectEndOfLine(self::EXPECT_CONTENT));
|
||||
|
||||
@@ -61,14 +61,14 @@ class ResultCacheExtensionTest extends TestCase
|
||||
{
|
||||
return [
|
||||
'ClassName::testMethod' => [
|
||||
TestCaseTest::class . '::testSomething',
|
||||
'testSomething', ],
|
||||
'testSomething',
|
||||
TestCaseTest::class . '::testSomething', ],
|
||||
'ClassName::testMethod and data set number and vardump' => [
|
||||
TestCaseTest::class . '::testMethod with data set #123 (\'a\', "A", 0, false)',
|
||||
'testMethod with data set #123', ],
|
||||
'testMethod with data set #123 (\'a\', "A", 0, false)',
|
||||
TestCaseTest::class . '::testMethod with data set #123', ],
|
||||
'ClassName::testMethod and data set name and vardump' => [
|
||||
TestCaseTest::class . '::testMethod with data set "data name" (\'a\', "A\", 0, false)',
|
||||
'testMethod with data set "data name"', ],
|
||||
'testMethod with data set "data name" (\'a\', "A\", 0, false)',
|
||||
TestCaseTest::class . '::testMethod with data set "data name"', ],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ class ResultCacheExtensionTest extends TestCase
|
||||
$test = new \TestError('test_name');
|
||||
$test->run($this->result);
|
||||
|
||||
$this->assertSame(BaseTestRunner::STATUS_ERROR, $this->cache->getState('test_name'));
|
||||
$this->assertSame(BaseTestRunner::STATUS_ERROR, $this->cache->getState(\TestError::class . '::test_name'));
|
||||
}
|
||||
|
||||
public function testFailure(): void
|
||||
@@ -85,7 +85,7 @@ class ResultCacheExtensionTest extends TestCase
|
||||
$test = new \Failure('test_name');
|
||||
$test->run($this->result);
|
||||
|
||||
$this->assertSame(BaseTestRunner::STATUS_FAILURE, $this->cache->getState('test_name'));
|
||||
$this->assertSame(BaseTestRunner::STATUS_FAILURE, $this->cache->getState(\Failure::class . '::test_name'));
|
||||
}
|
||||
|
||||
public function testSkipped(): void
|
||||
@@ -93,7 +93,7 @@ class ResultCacheExtensionTest extends TestCase
|
||||
$test = new \TestSkipped('test_name');
|
||||
$test->run($this->result);
|
||||
|
||||
$this->assertSame(BaseTestRunner::STATUS_SKIPPED, $this->cache->getState('test_name'));
|
||||
$this->assertSame(BaseTestRunner::STATUS_SKIPPED, $this->cache->getState(\TestSkipped::class . '::test_name'));
|
||||
}
|
||||
|
||||
public function testIncomplete(): void
|
||||
@@ -101,7 +101,7 @@ class ResultCacheExtensionTest extends TestCase
|
||||
$test = new \TestIncomplete('test_name');
|
||||
$test->run($this->result);
|
||||
|
||||
$this->assertSame(BaseTestRunner::STATUS_INCOMPLETE, $this->cache->getState('test_name'));
|
||||
$this->assertSame(BaseTestRunner::STATUS_INCOMPLETE, $this->cache->getState(\TestIncomplete::class . '::test_name'));
|
||||
}
|
||||
|
||||
public function testPassedTestsOnlyCacheTime(): void
|
||||
@@ -109,7 +109,7 @@ class ResultCacheExtensionTest extends TestCase
|
||||
$test = new \Success('test_name');
|
||||
$test->run($this->result);
|
||||
|
||||
$this->assertSame(BaseTestRunner::STATUS_UNKNOWN, $this->cache->getState('test_name'));
|
||||
$this->assertSame(BaseTestRunner::STATUS_UNKNOWN, $this->cache->getState(\Success::class . '::test_name'));
|
||||
}
|
||||
|
||||
public function testWarning(): void
|
||||
@@ -117,7 +117,7 @@ class ResultCacheExtensionTest extends TestCase
|
||||
$test = new \TestWarning('test_name');
|
||||
$test->run($this->result);
|
||||
|
||||
$this->assertSame(BaseTestRunner::STATUS_WARNING, $this->cache->getState('test_name'));
|
||||
$this->assertSame(BaseTestRunner::STATUS_WARNING, $this->cache->getState(\TestWarning::class . '::test_name'));
|
||||
}
|
||||
|
||||
public function testRisky(): void
|
||||
@@ -125,7 +125,7 @@ class ResultCacheExtensionTest extends TestCase
|
||||
$test = new \TestRisky('test_name');
|
||||
$test->run($this->result);
|
||||
|
||||
$this->assertSame(BaseTestRunner::STATUS_RISKY, $this->cache->getState('test_name'));
|
||||
$this->assertSame(BaseTestRunner::STATUS_RISKY, $this->cache->getState(\TestRisky::class . '::test_name'));
|
||||
}
|
||||
|
||||
public function testEmptySuite(): void
|
||||
|
||||
+185
-73
@@ -24,11 +24,19 @@ class TestSuiteSorterTest extends TestCase
|
||||
|
||||
private const RESOLVE_DEPENDENCIES = true;
|
||||
|
||||
private const MULTIDEPENDENCYTEST_EXECUTION_ORDER = [
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
];
|
||||
|
||||
public function testThrowsExceptionWhenUsingInvalidOrderOption(): void
|
||||
{
|
||||
$suite = new TestSuite;
|
||||
$suite->addTestSuite(\MultiDependencyTest::class);
|
||||
$sorter = new TestSuiteSorter();
|
||||
$sorter = new TestSuiteSorter;
|
||||
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionMessage('$order must be one of TestSuiteSorter::ORDER_DEFAULT, TestSuiteSorter::ORDER_REVERSED, or TestSuiteSorter::ORDER_RANDOMIZED, or TestSuiteSorter::ORDER_DURATION');
|
||||
@@ -39,7 +47,7 @@ class TestSuiteSorterTest extends TestCase
|
||||
{
|
||||
$suite = new TestSuite;
|
||||
$suite->addTestSuite(\MultiDependencyTest::class);
|
||||
$sorter = new TestSuiteSorter();
|
||||
$sorter = new TestSuiteSorter;
|
||||
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionMessage('$orderDefects must be one of TestSuiteSorter::ORDER_DEFAULT, TestSuiteSorter::ORDER_DEFECTS_FIRST');
|
||||
@@ -54,49 +62,66 @@ class TestSuiteSorterTest extends TestCase
|
||||
$sorter = new TestSuiteSorter;
|
||||
$suite = new TestSuite;
|
||||
|
||||
$this->assertSame([], $suite->tests());
|
||||
|
||||
$sorter->reorderTestsInSuite($suite, $order, $resolveDependencies, $orderDefects);
|
||||
|
||||
$this->assertSame([], $suite->tests());
|
||||
$this->assertEmpty($suite->tests());
|
||||
$this->assertEmpty($sorter->getOriginalExecutionOrder());
|
||||
$this->assertEmpty($sorter->getExecutionOrder());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider commonSorterOptionsProvider
|
||||
*/
|
||||
public function testBasicExecutionOrderOptions(int $order, bool $resolveDependencies, array $expected): void
|
||||
public function testBasicExecutionOrderOptions(int $order, bool $resolveDependencies, array $expectedOrder): void
|
||||
{
|
||||
$suite = new TestSuite;
|
||||
$suite->addTestSuite(\MultiDependencyTest::class);
|
||||
$sorter = new TestSuiteSorter();
|
||||
$sorter = new TestSuiteSorter;
|
||||
|
||||
$sorter->reorderTestsInSuite($suite, $order, $resolveDependencies, TestSuiteSorter::ORDER_DEFAULT);
|
||||
|
||||
$this->assertSame($expected, $this->getTestExecutionOrder($suite));
|
||||
$this->assertSame(self::MULTIDEPENDENCYTEST_EXECUTION_ORDER, $sorter->getOriginalExecutionOrder());
|
||||
$this->assertSame($expectedOrder, $sorter->getExecutionOrder());
|
||||
}
|
||||
|
||||
public function testCanSetRandomizationWithASeed(): void
|
||||
{
|
||||
$suite = new TestSuite;
|
||||
$suite->addTestSuite(\MultiDependencyTest::class);
|
||||
$sorter = new TestSuiteSorter();
|
||||
$sorter = new TestSuiteSorter;
|
||||
|
||||
\mt_srand(54321);
|
||||
$sorter->reorderTestsInSuite($suite, TestSuiteSorter::ORDER_RANDOMIZED, false, TestSuiteSorter::ORDER_DEFAULT);
|
||||
|
||||
$this->assertSame(['testTwo', 'testFour', 'testFive', 'testThree', 'testOne'], $this->getTestExecutionOrder($suite));
|
||||
$expectedOrder = [
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
];
|
||||
|
||||
$this->assertSame($expectedOrder, $sorter->getExecutionOrder());
|
||||
}
|
||||
|
||||
public function testCanSetRandomizationWithASeedAndResolveDependencies(): void
|
||||
{
|
||||
$suite = new TestSuite;
|
||||
$suite->addTestSuite(\MultiDependencyTest::class);
|
||||
$sorter = new TestSuiteSorter();
|
||||
$sorter = new TestSuiteSorter;
|
||||
|
||||
\mt_srand(54321);
|
||||
$sorter->reorderTestsInSuite($suite, TestSuiteSorter::ORDER_RANDOMIZED, true, TestSuiteSorter::ORDER_DEFAULT);
|
||||
|
||||
$this->assertSame(['testTwo', 'testFive', 'testOne', 'testThree', 'testFour'], $this->getTestExecutionOrder($suite));
|
||||
$expectedOrder = [
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
];
|
||||
|
||||
$this->assertSame($expectedOrder, $sorter->getExecutionOrder());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,7 +133,7 @@ class TestSuiteSorterTest extends TestCase
|
||||
|
||||
$suite->addTestSuite(\MultiDependencyTest::class);
|
||||
|
||||
$sorter = new TestSuiteSorter();
|
||||
$sorter = new TestSuiteSorter;
|
||||
|
||||
$sorter->reorderTestsInSuite(
|
||||
$suite,
|
||||
@@ -117,7 +142,7 @@ class TestSuiteSorterTest extends TestCase
|
||||
TestSuiteSorter::ORDER_DEFAULT
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $this->getTestExecutionOrder($suite));
|
||||
$this->assertSame($expected, $sorter->getExecutionOrder());
|
||||
}
|
||||
|
||||
public function orderDurationWithoutCacheProvider(): array
|
||||
@@ -126,21 +151,21 @@ class TestSuiteSorterTest extends TestCase
|
||||
'dependency-ignore' => [
|
||||
self::IGNORE_DEPENDENCIES,
|
||||
[
|
||||
'testOne',
|
||||
'testTwo',
|
||||
'testThree',
|
||||
'testFour',
|
||||
'testFive',
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
],
|
||||
],
|
||||
'dependency-resolve' => [
|
||||
self::RESOLVE_DEPENDENCIES,
|
||||
[
|
||||
'testOne',
|
||||
'testTwo',
|
||||
'testThree',
|
||||
'testFour',
|
||||
'testFive',
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
],
|
||||
],
|
||||
];
|
||||
@@ -155,10 +180,10 @@ class TestSuiteSorterTest extends TestCase
|
||||
|
||||
$suite->addTestSuite(\MultiDependencyTest::class);
|
||||
|
||||
$cache = new TestResultCache();
|
||||
$cache = new TestResultCache;
|
||||
|
||||
foreach ($testTimes as $testName => $time) {
|
||||
$cache->setTime($testName, $time);
|
||||
$cache->setTime(\MultiDependencyTest::class . '::' . $testName, $time);
|
||||
}
|
||||
|
||||
$sorter = new TestSuiteSorter($cache);
|
||||
@@ -170,7 +195,7 @@ class TestSuiteSorterTest extends TestCase
|
||||
TestSuiteSorter::ORDER_DEFAULT
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $this->getTestExecutionOrder($suite));
|
||||
$this->assertSame($expected, $sorter->getExecutionOrder());
|
||||
}
|
||||
|
||||
public function orderDurationWithCacheProvider(): array
|
||||
@@ -186,11 +211,11 @@ class TestSuiteSorterTest extends TestCase
|
||||
'testFive' => 1,
|
||||
],
|
||||
[
|
||||
'testOne',
|
||||
'testTwo',
|
||||
'testThree',
|
||||
'testFour',
|
||||
'testFive',
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
],
|
||||
],
|
||||
'duration-same-dependency-resolve' => [
|
||||
@@ -203,11 +228,11 @@ class TestSuiteSorterTest extends TestCase
|
||||
'testFive' => 1,
|
||||
],
|
||||
[
|
||||
'testOne',
|
||||
'testTwo',
|
||||
'testThree',
|
||||
'testFour',
|
||||
'testFive',
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
],
|
||||
],
|
||||
'duration-different-dependency-ignore' => [
|
||||
@@ -220,11 +245,11 @@ class TestSuiteSorterTest extends TestCase
|
||||
'testFive' => 2,
|
||||
],
|
||||
[
|
||||
'testFour',
|
||||
'testFive',
|
||||
'testTwo',
|
||||
'testThree',
|
||||
'testOne',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
],
|
||||
],
|
||||
'duration-different-dependency-resolve' => [
|
||||
@@ -237,11 +262,11 @@ class TestSuiteSorterTest extends TestCase
|
||||
'testFive' => 2,
|
||||
],
|
||||
[
|
||||
'testFive',
|
||||
'testTwo',
|
||||
'testOne',
|
||||
'testThree',
|
||||
'testFour',
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
],
|
||||
],
|
||||
];
|
||||
@@ -255,17 +280,17 @@ class TestSuiteSorterTest extends TestCase
|
||||
$suite = new TestSuite;
|
||||
$suite->addTestSuite(\MultiDependencyTest::class);
|
||||
|
||||
$cache = new TestResultCache();
|
||||
$cache = new TestResultCache;
|
||||
|
||||
foreach ($runState as $testName => $data) {
|
||||
$cache->setState($testName, $data['state']);
|
||||
$cache->setTime($testName, $data['time']);
|
||||
$cache->setState(\MultiDependencyTest::class . '::' . $testName, $data['state']);
|
||||
$cache->setTime(\MultiDependencyTest::class . '::' . $testName, $data['time']);
|
||||
}
|
||||
|
||||
$sorter = new TestSuiteSorter($cache);
|
||||
$sorter->reorderTestsInSuite($suite, $order, $resolveDependencies, TestSuiteSorter::ORDER_DEFECTS_FIRST);
|
||||
|
||||
$this->assertSame($expected, $this->getTestExecutionOrder($suite));
|
||||
$this->assertSame($expected, $sorter->getExecutionOrder());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -282,28 +307,52 @@ class TestSuiteSorterTest extends TestCase
|
||||
'default' => [
|
||||
TestSuiteSorter::ORDER_DEFAULT,
|
||||
self::IGNORE_DEPENDENCIES,
|
||||
['testOne', 'testTwo', 'testThree', 'testFour', 'testFive'],
|
||||
[
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
],
|
||||
],
|
||||
|
||||
// Activating dependency resolution should have no effect under normal circumstances
|
||||
'resolve default' => [
|
||||
TestSuiteSorter::ORDER_DEFAULT,
|
||||
self::RESOLVE_DEPENDENCIES,
|
||||
['testOne', 'testTwo', 'testThree', 'testFour', 'testFive'],
|
||||
[
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
],
|
||||
],
|
||||
|
||||
// Reversing without checks should give a simple reverse order
|
||||
'reverse' => [
|
||||
TestSuiteSorter::ORDER_REVERSED,
|
||||
self::IGNORE_DEPENDENCIES,
|
||||
['testFive', 'testFour', 'testThree', 'testTwo', 'testOne'],
|
||||
[
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
],
|
||||
],
|
||||
|
||||
// Reversing with resolution still allows testFive to move to front, testTwo before testOne
|
||||
'resolve reverse' => [
|
||||
TestSuiteSorter::ORDER_REVERSED,
|
||||
self::RESOLVE_DEPENDENCIES,
|
||||
['testFive', 'testTwo', 'testOne', 'testThree', 'testFour'],
|
||||
[
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -330,7 +379,14 @@ class TestSuiteSorterTest extends TestCase
|
||||
'testFour' => ['state' => BaseTestRunner::STATUS_PASSED, 'time' => 1],
|
||||
'testFive' => ['state' => BaseTestRunner::STATUS_PASSED, 'time' => 1],
|
||||
],
|
||||
['testOne', 'testTwo', 'testThree', 'testFour', 'testFive'], ],
|
||||
[
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
],
|
||||
],
|
||||
|
||||
// Running with an empty cache should not spook the TestSuiteSorter
|
||||
'default, empty result cache' => [
|
||||
@@ -339,7 +395,14 @@ class TestSuiteSorterTest extends TestCase
|
||||
[
|
||||
// empty result cache
|
||||
],
|
||||
['testOne', 'testTwo', 'testThree', 'testFour', 'testFive'], ],
|
||||
[
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
],
|
||||
],
|
||||
|
||||
// testFive is independent and can be moved to the front
|
||||
'default, testFive skipped' => [
|
||||
@@ -352,7 +415,14 @@ class TestSuiteSorterTest extends TestCase
|
||||
'testFour' => ['state' => BaseTestRunner::STATUS_PASSED, 'time' => 1],
|
||||
'testFive' => ['state' => BaseTestRunner::STATUS_SKIPPED, 'time' => 1],
|
||||
],
|
||||
['testFive', 'testOne', 'testTwo', 'testThree', 'testFour'], ],
|
||||
[
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
],
|
||||
],
|
||||
|
||||
// Defects in testFive and testTwo, but the faster testFive should be run first
|
||||
'default, testTwo testFive skipped' => [
|
||||
@@ -365,7 +435,14 @@ class TestSuiteSorterTest extends TestCase
|
||||
'testFour' => ['state' => BaseTestRunner::STATUS_PASSED, 'time' => 1],
|
||||
'testFive' => ['state' => BaseTestRunner::STATUS_SKIPPED, 'time' => 0],
|
||||
],
|
||||
['testFive', 'testTwo', 'testOne', 'testThree', 'testFour'], ],
|
||||
[
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
],
|
||||
],
|
||||
|
||||
// Skipping testThree will move it to the front when ignoring dependencies
|
||||
'default, testThree skipped' => [
|
||||
@@ -378,7 +455,14 @@ class TestSuiteSorterTest extends TestCase
|
||||
'testFour' => ['state' => BaseTestRunner::STATUS_PASSED, 'time' => 1],
|
||||
'testFive' => ['state' => BaseTestRunner::STATUS_PASSED, 'time' => 1],
|
||||
],
|
||||
['testThree', 'testOne', 'testTwo', 'testFour', 'testFive'], ],
|
||||
[
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
],
|
||||
],
|
||||
|
||||
// Skipping testThree will move it to the front but behind its dependencies
|
||||
'default resolve, testThree skipped' => [
|
||||
@@ -391,7 +475,14 @@ class TestSuiteSorterTest extends TestCase
|
||||
'testFour' => ['state' => BaseTestRunner::STATUS_PASSED, 'time' => 1],
|
||||
'testFive' => ['state' => BaseTestRunner::STATUS_PASSED, 'time' => 1],
|
||||
],
|
||||
['testOne', 'testTwo', 'testThree', 'testFour', 'testFive'], ],
|
||||
[
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
],
|
||||
],
|
||||
|
||||
// Skipping testThree will move it to the front and keep the others reversed
|
||||
'reverse, testThree skipped' => [
|
||||
@@ -404,7 +495,14 @@ class TestSuiteSorterTest extends TestCase
|
||||
'testFour' => ['state' => BaseTestRunner::STATUS_PASSED, 'time' => 1],
|
||||
'testFive' => ['state' => BaseTestRunner::STATUS_PASSED, 'time' => 1],
|
||||
],
|
||||
['testThree', 'testFive', 'testFour', 'testTwo', 'testOne'], ],
|
||||
[
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
],
|
||||
],
|
||||
|
||||
// Demonstrate a limit of the dependency resolver: after sorting defects to the front,
|
||||
// the resolver will mark testFive done before testThree because of dependencies
|
||||
@@ -418,7 +516,14 @@ class TestSuiteSorterTest extends TestCase
|
||||
'testFour' => ['state' => BaseTestRunner::STATUS_PASSED, 'time' => 1],
|
||||
'testFive' => ['state' => BaseTestRunner::STATUS_SKIPPED, 'time' => 1],
|
||||
],
|
||||
['testFive', 'testOne', 'testTwo', 'testThree', 'testFour'], ],
|
||||
[
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
],
|
||||
],
|
||||
|
||||
// Torture test
|
||||
// - incomplete TestResultCache
|
||||
@@ -433,7 +538,14 @@ class TestSuiteSorterTest extends TestCase
|
||||
'testTwo' => ['state' => BaseTestRunner::STATUS_PASSED, 'time' => 1],
|
||||
'testThree' => ['state' => BaseTestRunner::STATUS_SKIPPED, 'time' => 1],
|
||||
],
|
||||
['testFive', 'testTwo', 'testOne', 'testThree', 'testFour'], ],
|
||||
[
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
],
|
||||
],
|
||||
|
||||
// Make sure the dependency resolver is not confused by failing tests.
|
||||
// Scenario: Four has a @depends on Three and fails. Result: Three is still run first
|
||||
@@ -448,7 +560,14 @@ class TestSuiteSorterTest extends TestCase
|
||||
'testFour' => ['state' => BaseTestRunner::STATUS_FAILURE, 'time' => 1],
|
||||
'testFive' => ['state' => BaseTestRunner::STATUS_FAILURE, 'time' => 1],
|
||||
],
|
||||
['testFive', 'testOne', 'testTwo', 'testThree', 'testFour'], ],
|
||||
[
|
||||
\MultiDependencyTest::class . '::testFive',
|
||||
\MultiDependencyTest::class . '::testOne',
|
||||
\MultiDependencyTest::class . '::testTwo',
|
||||
\MultiDependencyTest::class . '::testThree',
|
||||
\MultiDependencyTest::class . '::testFour',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -460,7 +579,7 @@ class TestSuiteSorterTest extends TestCase
|
||||
$suite = new TestSuite;
|
||||
$suite->addTestSuite(\EmptyTestCaseTest::class);
|
||||
|
||||
$sorter = new TestSuiteSorter();
|
||||
$sorter = new TestSuiteSorter;
|
||||
|
||||
$sorter->reorderTestsInSuite($suite, TestSuiteSorter::ORDER_DEFAULT, false, TestSuiteSorter::ORDER_DEFAULT);
|
||||
|
||||
@@ -486,11 +605,4 @@ class TestSuiteSorterTest extends TestCase
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function getTestExecutionOrder(TestSuite $suite): array
|
||||
{
|
||||
return \array_map(function ($test) {
|
||||
return $test->getName();
|
||||
}, $suite->tests()[0]->tests());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,14 +15,14 @@ class TestRunnerTest extends TestCase
|
||||
{
|
||||
public function testTestIsRunnable(): void
|
||||
{
|
||||
$runner = new TestRunner();
|
||||
$runner = new TestRunner;
|
||||
$runner->setPrinter($this->getResultPrinterMock());
|
||||
$runner->doRun(new \Success(), ['filter' => 'foo'], false);
|
||||
$runner->doRun(new \Success, ['filter' => 'foo'], false);
|
||||
}
|
||||
|
||||
public function testSuiteIsRunnable(): void
|
||||
{
|
||||
$runner = new TestRunner();
|
||||
$runner = new TestRunner;
|
||||
$runner->setPrinter($this->getResultPrinterMock());
|
||||
$runner->doRun($this->getSuiteMock(), ['filter' => 'foo'], false);
|
||||
}
|
||||
|
||||
@@ -428,11 +428,19 @@ class ConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testHandlePHPConfigurationDoesNotOverriteVariablesFromPutEnv(): void
|
||||
{
|
||||
$backupFoo = \getenv('foo');
|
||||
|
||||
\putenv('foo=putenv');
|
||||
$this->configuration->handlePHPConfiguration();
|
||||
|
||||
$this->assertEquals('putenv', $_ENV['foo']);
|
||||
$this->assertEquals('putenv', \getenv('foo'));
|
||||
|
||||
if ($backupFoo === false) {
|
||||
\putenv('foo'); // delete variable from environment
|
||||
} else {
|
||||
\putenv("foo=$backupFoo");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -73,7 +73,7 @@ final class CliTestDoxPrinterTest extends TestCase
|
||||
public function testPrintsCrossForTestWithError(): void
|
||||
{
|
||||
$this->printer->startTest($this);
|
||||
$this->printer->addError($this, new Exception(), 0);
|
||||
$this->printer->addError($this, new Exception, 0);
|
||||
$this->printer->endTest($this, 0.001);
|
||||
|
||||
$this->assertContains('✘', $this->printer->getBuffer());
|
||||
@@ -82,7 +82,7 @@ final class CliTestDoxPrinterTest extends TestCase
|
||||
public function testPrintsAdditionalInformationForTestWithError(): void
|
||||
{
|
||||
$this->printer->startTest($this);
|
||||
$this->printer->addError($this, new Exception(), 0);
|
||||
$this->printer->addError($this, new Exception, 0);
|
||||
$this->printer->endTest($this, 0.001);
|
||||
|
||||
$this->assertContains('│', $this->printer->getBuffer());
|
||||
@@ -91,7 +91,7 @@ final class CliTestDoxPrinterTest extends TestCase
|
||||
public function testPrintsCrossForTestWithWarning(): void
|
||||
{
|
||||
$this->printer->startTest($this);
|
||||
$this->printer->addWarning($this, new Warning(), 0);
|
||||
$this->printer->addWarning($this, new Warning, 0);
|
||||
$this->printer->endTest($this, 0.001);
|
||||
|
||||
$this->assertContains('✘', $this->printer->getBuffer());
|
||||
@@ -100,7 +100,7 @@ final class CliTestDoxPrinterTest extends TestCase
|
||||
public function testPrintsAdditionalInformationForTestWithWarning(): void
|
||||
{
|
||||
$this->printer->startTest($this);
|
||||
$this->printer->addWarning($this, new Warning(), 0);
|
||||
$this->printer->addWarning($this, new Warning, 0);
|
||||
$this->printer->endTest($this, 0.001);
|
||||
|
||||
$this->assertContains('│', $this->printer->getBuffer());
|
||||
@@ -109,7 +109,7 @@ final class CliTestDoxPrinterTest extends TestCase
|
||||
public function testPrintsCrossForTestWithFailure(): void
|
||||
{
|
||||
$this->printer->startTest($this);
|
||||
$this->printer->addFailure($this, new AssertionFailedError(), 0);
|
||||
$this->printer->addFailure($this, new AssertionFailedError, 0);
|
||||
$this->printer->endTest($this, 0.001);
|
||||
|
||||
$this->assertContains('✘', $this->printer->getBuffer());
|
||||
@@ -118,7 +118,7 @@ final class CliTestDoxPrinterTest extends TestCase
|
||||
public function testPrintsAdditionalInformationForTestWithFailure(): void
|
||||
{
|
||||
$this->printer->startTest($this);
|
||||
$this->printer->addFailure($this, new AssertionFailedError(), 0);
|
||||
$this->printer->addFailure($this, new AssertionFailedError, 0);
|
||||
$this->printer->endTest($this, 0.001);
|
||||
|
||||
$this->assertContains('│', $this->printer->getBuffer());
|
||||
@@ -127,7 +127,7 @@ final class CliTestDoxPrinterTest extends TestCase
|
||||
public function testPrintsEmptySetSymbolForTestWithFailure(): void
|
||||
{
|
||||
$this->printer->startTest($this);
|
||||
$this->printer->addIncompleteTest($this, new Exception(), 0);
|
||||
$this->printer->addIncompleteTest($this, new Exception, 0);
|
||||
$this->printer->endTest($this, 0.001);
|
||||
|
||||
$this->assertContains('∅', $this->printer->getBuffer());
|
||||
@@ -136,7 +136,7 @@ final class CliTestDoxPrinterTest extends TestCase
|
||||
public function testDoesNotPrintAdditionalInformationForIncompleteTestByDefault(): void
|
||||
{
|
||||
$this->printer->startTest($this);
|
||||
$this->printer->addIncompleteTest($this, new Exception(), 0);
|
||||
$this->printer->addIncompleteTest($this, new Exception, 0);
|
||||
$this->printer->endTest($this, 0.001);
|
||||
|
||||
$this->assertNotContains('│', $this->printer->getBuffer());
|
||||
@@ -155,7 +155,7 @@ final class CliTestDoxPrinterTest extends TestCase
|
||||
public function testPrintsRadioactiveSymbolForRiskyTest(): void
|
||||
{
|
||||
$this->printer->startTest($this);
|
||||
$this->printer->addRiskyTest($this, new Exception(), 0);
|
||||
$this->printer->addRiskyTest($this, new Exception, 0);
|
||||
$this->printer->endTest($this, 0.001);
|
||||
|
||||
$this->assertContains('☢', $this->printer->getBuffer());
|
||||
@@ -164,7 +164,7 @@ final class CliTestDoxPrinterTest extends TestCase
|
||||
public function testDoesNotPrintAdditionalInformationForRiskyTestByDefault(): void
|
||||
{
|
||||
$this->printer->startTest($this);
|
||||
$this->printer->addRiskyTest($this, new Exception(), 0);
|
||||
$this->printer->addRiskyTest($this, new Exception, 0);
|
||||
$this->printer->endTest($this, 0.001);
|
||||
|
||||
$this->assertNotContains('│', $this->printer->getBuffer());
|
||||
@@ -173,7 +173,7 @@ final class CliTestDoxPrinterTest extends TestCase
|
||||
public function testPrintsAdditionalInformationForRiskyTestInVerboseMode(): void
|
||||
{
|
||||
$this->verbosePrinter->startTest($this);
|
||||
$this->verbosePrinter->addRiskyTest($this, new Exception(), 0);
|
||||
$this->verbosePrinter->addRiskyTest($this, new Exception, 0);
|
||||
$this->verbosePrinter->endTest($this, 0.001);
|
||||
|
||||
$this->assertContains('│', $this->verbosePrinter->getBuffer());
|
||||
@@ -182,7 +182,7 @@ final class CliTestDoxPrinterTest extends TestCase
|
||||
public function testPrintsArrowForSkippedTest(): void
|
||||
{
|
||||
$this->printer->startTest($this);
|
||||
$this->printer->addSkippedTest($this, new Exception(), 0);
|
||||
$this->printer->addSkippedTest($this, new Exception, 0);
|
||||
$this->printer->endTest($this, 0.001);
|
||||
|
||||
$this->assertContains('→', $this->printer->getBuffer());
|
||||
@@ -191,7 +191,7 @@ final class CliTestDoxPrinterTest extends TestCase
|
||||
public function testDoesNotPrintAdditionalInformationForSkippedTestByDefault(): void
|
||||
{
|
||||
$this->printer->startTest($this);
|
||||
$this->printer->addSkippedTest($this, new Exception(), 0);
|
||||
$this->printer->addSkippedTest($this, new Exception, 0);
|
||||
$this->printer->endTest($this, 0.001);
|
||||
|
||||
$this->assertNotContains('│', $this->printer->getBuffer());
|
||||
|
||||
@@ -57,4 +57,116 @@ class NamePrettifierTest extends TestCase
|
||||
$this->assertEquals('Sets redirect header on 301', $this->namePrettifier->prettifyTestMethod('testSetsRedirectHeaderOn301'));
|
||||
$this->assertEquals('Sets redirect header on 302', $this->namePrettifier->prettifyTestMethod('testSetsRedirectHeaderOn302'));
|
||||
}
|
||||
|
||||
public function testPhpDoxIgnoreDataKeys(): void
|
||||
{
|
||||
$test = new class extends TestCase {
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('testAddition', [
|
||||
'augend' => 1,
|
||||
'addend' => 2,
|
||||
'result' => 3,
|
||||
]);
|
||||
}
|
||||
|
||||
public function testAddition(int $augend, int $addend, int $result): void
|
||||
{
|
||||
}
|
||||
|
||||
public function getAnnotations(): array
|
||||
{
|
||||
return [
|
||||
'method' => [
|
||||
'testdox' => ['$augend + $addend = $result'],
|
||||
],
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
$this->assertEquals('1 + 2 = 3', $this->namePrettifier->prettifyTestCase($test));
|
||||
}
|
||||
|
||||
public function testPhpDoxUsesDefaultValue(): void
|
||||
{
|
||||
$test = new class extends TestCase {
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('testAddition', []);
|
||||
}
|
||||
|
||||
public function testAddition(int $augend = 1, int $addend = 2, int $result = 3): void
|
||||
{
|
||||
}
|
||||
|
||||
public function getAnnotations(): array
|
||||
{
|
||||
return [
|
||||
'method' => [
|
||||
'testdox' => ['$augend + $addend = $result'],
|
||||
],
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
$this->assertEquals('1 + 2 = 3', $this->namePrettifier->prettifyTestCase($test));
|
||||
}
|
||||
|
||||
public function testPhpDoxArgumentExporting(): void
|
||||
{
|
||||
$test = new class extends TestCase {
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('testExport', [
|
||||
'int' => 1234,
|
||||
'strInt' => '1234',
|
||||
'float' => 2.123,
|
||||
'strFloat' => '2.123',
|
||||
'string' => 'foo',
|
||||
'bool' => true,
|
||||
'null' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function testExport($int, $strInt, $float, $strFloat, $string, $bool, $null): void
|
||||
{
|
||||
}
|
||||
|
||||
public function getAnnotations(): array
|
||||
{
|
||||
return [
|
||||
'method' => [
|
||||
'testdox' => ['$int, $strInt, $float, $strFloat, $string, $bool, $null'],
|
||||
],
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
$this->assertEquals('1234, 1234, 2.123, 2.123, foo, true, NULL', $this->namePrettifier->prettifyTestCase($test));
|
||||
}
|
||||
|
||||
public function testPhpDoxReplacesLongerVariablesFirst(): void
|
||||
{
|
||||
$test = new class extends TestCase {
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('testFoo', []);
|
||||
}
|
||||
|
||||
public function testFoo(int $a = 1, int $ab = 2, int $abc = 3): void
|
||||
{
|
||||
}
|
||||
|
||||
public function getAnnotations(): array
|
||||
{
|
||||
return [
|
||||
'method' => [
|
||||
'testdox' => ['$a, "$a", $a$ab, $abc, $abcd, $ab'],
|
||||
],
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
$this->assertEquals('1, "1", 12, 3, $abcd, 2', $this->namePrettifier->prettifyTestCase($test));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ class TestResultCacheTest extends TestCase
|
||||
$cache = new TestResultCache($cacheFile);
|
||||
$cache->load();
|
||||
|
||||
$this->assertSame(BaseTestRunner::STATUS_UNKNOWN, $cache->getState('testOne'));
|
||||
$this->assertSame(BaseTestRunner::STATUS_SKIPPED, $cache->getState('testFive'));
|
||||
$this->assertSame(BaseTestRunner::STATUS_UNKNOWN, $cache->getState(\MultiDependencyTest::class . '::testOne'));
|
||||
$this->assertSame(BaseTestRunner::STATUS_SKIPPED, $cache->getState(\MultiDependencyTest::class . '::testFive'));
|
||||
}
|
||||
|
||||
public function testDoesClearCacheBeforeLoad(): void
|
||||
@@ -32,12 +32,12 @@ class TestResultCacheTest extends TestCase
|
||||
$cache = new TestResultCache($cacheFile);
|
||||
$cache->setState('someTest', BaseTestRunner::STATUS_FAILURE);
|
||||
|
||||
$this->assertSame(BaseTestRunner::STATUS_UNKNOWN, $cache->getState('testFive'));
|
||||
$this->assertSame(BaseTestRunner::STATUS_UNKNOWN, $cache->getState(\MultiDependencyTest::class . '::testFive'));
|
||||
|
||||
$cache->load();
|
||||
|
||||
$this->assertSame(BaseTestRunner::STATUS_UNKNOWN, $cache->getState('someTest'));
|
||||
$this->assertSame(BaseTestRunner::STATUS_SKIPPED, $cache->getState('testFive'));
|
||||
$this->assertSame(BaseTestRunner::STATUS_UNKNOWN, $cache->getState(\MultiDependencyTest::class . '::someTest'));
|
||||
$this->assertSame(BaseTestRunner::STATUS_SKIPPED, $cache->getState(\MultiDependencyTest::class . '::testFive'));
|
||||
}
|
||||
|
||||
public function testShouldNotSerializePassedTestsAsDefectButTimeIsStored(): void
|
||||
|
||||
+2
-2
@@ -95,7 +95,7 @@ class XmlTest extends TestCase
|
||||
public function testXmlToVariableCanHandleMultipleOfTheSameArgumentType(): void
|
||||
{
|
||||
$xml = '<object class="SampleClass"><arguments><string>a</string><string>b</string><string>c</string></arguments></object>';
|
||||
$dom = new \DOMDocument();
|
||||
$dom = new \DOMDocument;
|
||||
$dom->loadXML($xml);
|
||||
|
||||
$expected = ['a' => 'a', 'b' => 'b', 'c' => 'c'];
|
||||
@@ -108,7 +108,7 @@ class XmlTest extends TestCase
|
||||
public function testXmlToVariableCanConstructObjectsWithConstructorArgumentsRecursively(): void
|
||||
{
|
||||
$xml = '<object class="Exception"><arguments><string>one</string><integer>0</integer><object class="Exception"><arguments><string>two</string></arguments></object></arguments></object>';
|
||||
$dom = new \DOMDocument();
|
||||
$dom = new \DOMDocument;
|
||||
$dom->loadXML($xml);
|
||||
|
||||
$actual = Xml::xmlToVariable($dom->documentElement);
|
||||
|
||||
Reference in New Issue
Block a user