Skip to content

Commit

Permalink
Merge pull request #1317 from phil-davis/phpunit8
Browse files Browse the repository at this point in the history
Use PHPUnit8 for unit testing
  • Loading branch information
stof committed Jul 21, 2020
2 parents 2b456ee + 3880e9c commit 205ed41
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,3 +4,4 @@
behat.yml
vendor
composer.lock
.phpunit.result.cache
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -29,7 +29,7 @@

"require-dev": {
"symfony/process": "^4.4 || ^5.0",
"phpunit/phpunit": "^7.5.20",
"phpunit/phpunit": "^8.5",
"herrera-io/box": "~1.6.1",
"container-interop/container-interop": "^1.2"
},
Expand Down
12 changes: 6 additions & 6 deletions features/append_snippets.feature
Expand Up @@ -61,7 +61,7 @@ Feature: Append snippets option
* @Given /^context parameter "([^"]*)" should be array with (\d+) elements$/
*/
public function contextParameterShouldBeArrayWithElements($key, $count) {
\PHPUnit\Framework\Assert::assertInternalType('array', $this->parameters[$key]);
\PHPUnit\Framework\Assert::assertIsArray($this->parameters[$key]);
\PHPUnit\Framework\Assert::assertEquals(2, count($this->parameters[$key]));
}
Expand Down Expand Up @@ -176,7 +176,7 @@ Feature: Append snippets option
* @Given /^context parameter "([^"]*)" should be array with (\d+) elements$/
*/
public function contextParameterShouldBeArrayWithElements($key, $count) {
\PHPUnit\Framework\Assert::assertInternalType('array', $this->parameters[$key]);
\PHPUnit\Framework\Assert::assertIsArray($this->parameters[$key]);
\PHPUnit\Framework\Assert::assertEquals(2, count($this->parameters[$key]));
}
Expand Down Expand Up @@ -281,7 +281,7 @@ Feature: Append snippets option
* @Given /^context parameter "([^"]*)" should be array with (\d+) elements$/
*/
public function contextParameterShouldBeArrayWithElements($key, $count) {
\PHPUnit\Framework\Assert::assertInternalType('array', $this->parameters[$key]);
\PHPUnit\Framework\Assert::assertIsArray($this->parameters[$key]);
\PHPUnit\Framework\Assert::assertEquals(2, count($this->parameters[$key]));
}
Expand Down Expand Up @@ -346,7 +346,7 @@ Feature: Append snippets option
* @Given /^context parameter "([^"]*)" should be array with (\d+) elements$/
*/
public function contextParameterShouldBeArrayWithElements($key, $count) {
\PHPUnit\Framework\Assert::assertInternalType('array', $this->parameters[$key]);
\PHPUnit\Framework\Assert::assertIsArray($this->parameters[$key]);
\PHPUnit\Framework\Assert::assertEquals(2, count($this->parameters[$key]));
}
Expand Down Expand Up @@ -449,7 +449,7 @@ Feature: Append snippets option
* @Given /^context parameter "([^"]*)" should be array with (\d+) elements$/
*/
public function contextParameterShouldBeArrayWithElements($key, $count) {
\PHPUnit\Framework\Assert::assertInternalType('array', $this->parameters[$key]);
\PHPUnit\Framework\Assert::assertIsArray($this->parameters[$key]);
\PHPUnit\Framework\Assert::assertEquals(2, count($this->parameters[$key]));
}
Expand Down Expand Up @@ -514,7 +514,7 @@ Feature: Append snippets option
* @Given /^context parameter "([^"]*)" should be array with (\d+) elements$/
*/
public function contextParameterShouldBeArrayWithElements($key, $count) {
\PHPUnit\Framework\Assert::assertInternalType('array', $this->parameters[$key]);
\PHPUnit\Framework\Assert::assertIsArray($this->parameters[$key]);
\PHPUnit\Framework\Assert::assertEquals(2, count($this->parameters[$key]));
}
Expand Down
2 changes: 1 addition & 1 deletion features/bootstrap/FeatureContext.php
Expand Up @@ -337,7 +337,7 @@ public function fileXmlShouldBeLike($path, PyStringNode $text)
*/
public function theOutputShouldContain(PyStringNode $text)
{
Assert::assertContains($this->getExpectedOutput($text), $this->getOutput());
Assert::assertStringContainsString($this->getExpectedOutput($text), $this->getOutput());
}

private function getExpectedOutput(PyStringNode $expectedText)
Expand Down
4 changes: 2 additions & 2 deletions features/context.feature
Expand Up @@ -61,7 +61,7 @@ Feature: Context consistency
* @Given /^context parameter "([^"]*)" should be array with (\d+) elements$/
*/
public function contextParameterShouldBeArrayWithElements($key, $count) {
PHPUnit\Framework\Assert::assertInternalType('array', $this->parameters[$key]);
PHPUnit\Framework\Assert::assertIsArray($this->parameters[$key]);
PHPUnit\Framework\Assert::assertEquals(2, count($this->parameters[$key]));
}
}
Expand Down Expand Up @@ -496,7 +496,7 @@ Feature: Context consistency
/** @Given foo */
public function foo() {
PHPUnit\Framework\Assert::assertInternalType('array', $this->foo);
PHPUnit\Framework\Assert::assertIsArray($this->foo);
PHPUnit\Framework\Assert::assertSame('foo', $this->foo[0]);
PHPUnit\Framework\Assert::assertSame('bar', $this->foo[1]);
Expand Down
2 changes: 1 addition & 1 deletion features/definitions_transformations.feature
Expand Up @@ -125,7 +125,7 @@ Feature: Step Arguments Transformations
*/
public function ageMustBe($age) {
PHPUnit\Framework\Assert::assertEquals($age, $this->user->getAge());
PHPUnit\Framework\Assert::assertInternalType('int', $age);
PHPUnit\Framework\Assert::assertIsInt($age);
}
/**
Expand Down
2 changes: 1 addition & 1 deletion features/format_options.feature
Expand Up @@ -61,7 +61,7 @@ Feature: Format options
* @Given /^context parameter "([^"]*)" should be array with (\d+) elements$/
*/
public function contextParameterShouldBeArrayWithElements($key, $count) {
PHPUnit\Framework\Assert::assertInternalType('array', $this->parameters[$key]);
PHPUnit\Framework\Assert::assertIsArray($this->parameters[$key]);
PHPUnit\Framework\Assert::assertEquals(2, count($this->parameters[$key]));
}
}
Expand Down
2 changes: 1 addition & 1 deletion features/multiple_formats.feature
Expand Up @@ -61,7 +61,7 @@ Feature: Multiple formats
* @Given /^context parameter "([^"]*)" should be array with (\d+) elements$/
*/
public function contextParameterShouldBeArrayWithElements($key, $count) {
PHPUnit\Framework\Assert::assertInternalType('array', $this->parameters[$key]);
PHPUnit\Framework\Assert::assertIsArray($this->parameters[$key]);
PHPUnit\Framework\Assert::assertEquals(2, count($this->parameters[$key]));
}
}
Expand Down
2 changes: 1 addition & 1 deletion features/rerun.feature
Expand Up @@ -58,7 +58,7 @@ Feature: Rerun
* @Given /^context parameter "([^"]*)" should be array with (\d+) elements$/
*/
public function contextParameterShouldBeArrayWithElements($key, $count) {
PHPUnit\Framework\Assert::assertInternalType('array', $this->parameters[$key]);
PHPUnit\Framework\Assert::assertIsArray($this->parameters[$key]);
PHPUnit\Framework\Assert::assertEquals(2, count($this->parameters[$key]));
}
}
Expand Down
2 changes: 1 addition & 1 deletion features/rerun_with_multiple_suite.feature
Expand Up @@ -74,7 +74,7 @@ Feature: Rerun with multiple suite
* @Given /^context parameter "([^"]*)" should be array with (\d+) elements$/
*/
public function contextParameterShouldBeArrayWithElements($key, $count) {
PHPUnit\Framework\Assert::assertInternalType('array', $this->parameters[$key]);
PHPUnit\Framework\Assert::assertIsArray($this->parameters[$key]);
PHPUnit\Framework\Assert::assertEquals(2, count($this->parameters[$key]));
}
}
Expand Down
Expand Up @@ -66,10 +66,6 @@ public function testTransformPatternToRegexCacheAndRegisterNewPolicy()
$this->assertEquals('/hello world/', $regex3);
}

/**
* @expectedException \Behat\Behat\Definition\Exception\UnknownPatternException
* @expectedExceptionMessage Can not find policy for a pattern `hello world`.
*/
public function testTransformPatternToRegexNoMatch()
{
// first pattern
Expand All @@ -81,6 +77,8 @@ public function testTransformPatternToRegexNoMatch()

$testedInstance = new PatternTransformer();
$testedInstance->registerPatternPolicy($policy1Prophecy->reveal());
$this->expectException('\Behat\Behat\Definition\Exception\UnknownPatternException');
$this->expectExceptionMessage("Can not find policy for a pattern `hello world`.");
$regex = $testedInstance->transformPatternToRegex('hello world');
}
}

0 comments on commit 205ed41

Please sign in to comment.