Skip to content

Commit

Permalink
Add compatibility to symfony 5
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Feb 19, 2020
1 parent 31258ea commit 072b1dc
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ vendor
testapp/app/cache
testapp/app/logs
.htaccess
/var
18 changes: 11 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,23 @@ matrix:
- php: 5.6
env: SYMFONY_VERSION='2.8.*'
- php: 7.1
env: SYMFONY_VERSION='3.3.*'
env: SYMFONY_VERSION='^3.4'
- php: 7.1
env: DEPS=dev SYMFONY_VERSION='3.4.*'
- php: 7.1
env: DEVS=dev SYMFONY_VERSION='4.0.*'
env: SYMFONY_VERSION='^4.3'
- php: 7.2
env: SYMFONY_VERSION='^4.4'
- php: 7.3
env: SYMFONY_VERSION='5.0.*'
- php: 7.4
env: SYMFONY_VERSION='^5.0'
allow_failures:
- php: 7.1
env: SYMFONY_VERSION='4.0.x-dev'
- php: 7.4
env: DEPS=dev SYMFONY_VERSION='^5.0@dev'

before_install:
- composer self-update
- mkdir -p ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d && echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- if [ "$DEPS" = 'dev' ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi;
- if [ "$DEPS" != "" ]; then composer config minimum-stability $DEPS; fi;
- if [ "$SYMFONY_VERSION" != "" ]; then composer require --no-update "symfony/symfony:${SYMFONY_VERSION}"; fi;

install:
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
"require": {
"php": ">=5.3.3",
"behat/behat": "^3.4.3",
"symfony/framework-bundle": "~2.0|~3.0|~4.0"
"symfony/framework-bundle": "~2.0|~3.0|~4.0|~5.0"
},

"require-dev": {
"symfony/symfony": "~2.1|~3.0|~4.0",
"symfony/symfony": "~2.1|~3.0|~4.0|~5.0",
"behat/mink-extension": "~2.0",
"behat/mink": "~1.7@dev",
"behat/mink-browserkit-driver": "~1.3@dev",
"phpspec/phpspec": "~2.0|~3.0|~4.0",
"phpunit/phpunit": "~4.0|~5.0"
"phpspec/phpspec": "~2.0|~3.0|~4.0|~5.0|~6.0",
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.0 || ^7.0 || ^8.0 || ^9.0"
},

"autoload": {
Expand Down
12 changes: 9 additions & 3 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
use Behat\Gherkin\Node\PyStringNode;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;
use PHPUnit\Framework\Assert;

// BC Layer for older PHPUnit versions.
if (!class_exists('PHPUnit\Framework\Assert')) {
class_alias('PHPUnit_Framework_Assert', 'PHPUnit\Framework\Assert');
}

/**
* Behat context class.
Expand Down Expand Up @@ -82,7 +88,7 @@ public function itShouldPassWith($success, PyStringNode $text)
*/
public function theOutputShouldContain(PyStringNode $text)
{
PHPUnit_Framework_Assert::assertContains($this->getExpectedOutput($text), $this->getOutput());
Assert::assertContains($this->getExpectedOutput($text), $this->getOutput());
}

private function getExpectedOutput(PyStringNode $expectedText)
Expand Down Expand Up @@ -125,13 +131,13 @@ public function itShouldFail($success)
echo 'Actual output:' . PHP_EOL . PHP_EOL . $this->getOutput();
}

PHPUnit_Framework_Assert::assertNotEquals(0, $this->getExitCode());
Assert::assertNotEquals(0, $this->getExitCode());
} else {
if (0 !== $this->getExitCode()) {
echo 'Actual output:' . PHP_EOL . PHP_EOL . $this->getOutput();
}

PHPUnit_Framework_Assert::assertEquals(0, $this->getExitCode());
Assert::assertEquals(0, $this->getExitCode());
}
}

Expand Down
2 changes: 2 additions & 0 deletions testapp/behat.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
default:
translation:
locale: en
formatters:
progress:
paths: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

use Symfony\Component\HttpKernel\KernelInterface;
use Behat\Symfony2Extension\Context\KernelAwareContext;
use PHPUnit\Framework\Assert;

// BC Layer for older PHPUnit versions.
if (!class_exists('PHPUnit\Framework\Assert')) {
class_alias('PHPUnit_Framework_Assert', 'PHPUnit\Framework\Assert');
}

class FeatureContext implements KernelAwareContext
{
Expand All @@ -27,7 +33,7 @@ public function setKernel(KernelInterface $kernel)
*/
public function iHaveAKernelInstance()
{
\PHPUnit_Framework_Assert::assertInstanceOf('Symfony\\Component\\HttpKernel\\KernelInterface', $this->kernel);
Assert::assertInstanceOf('Symfony\\Component\\HttpKernel\\KernelInterface', $this->kernel);
}

/**
Expand All @@ -43,7 +49,7 @@ public function iGetContainerParametersFromIt()
*/
public function thereShouldBeParameter($key)
{
\PHPUnit_Framework_Assert::assertArrayHasKey($key, $this->containerParameters);
Assert::assertArrayHasKey($key, $this->containerParameters);
$this->parameterKey = $key;
}

Expand All @@ -52,23 +58,23 @@ public function thereShouldBeParameter($key)
*/
public function thereShouldNotBeParameter($key)
{
\PHPUnit_Framework_Assert::assertArrayNotHasKey($key, $this->containerParameters);
Assert::assertArrayNotHasKey($key, $this->containerParameters);
}

/**
* @Given /^it should be set to "([^"]*)" value$/
*/
public function itShouldBeSetToValue($val)
{
\PHPUnit_Framework_Assert::assertSame($val, $this->containerParameters[$this->parameterKey]);
Assert::assertSame($val, $this->containerParameters[$this->parameterKey]);
}

/**
* @Then the value should be an array
*/
public function theValueShouldBeAnArray()
{
\PHPUnit_Framework_Assert::assertInternalType('array', $this->containerParameters[$this->parameterKey]);
Assert::assertInternalType('array', $this->containerParameters[$this->parameterKey]);
}

/**
Expand All @@ -78,7 +84,7 @@ public function theValueShouldBeAnArray()
public function theArrayShouldContainOnlyTheValues($arg)
{
$values = explode(',', $arg);
\PHPUnit_Framework_Assert::assertSame($values, $this->containerParameters[$this->parameterKey]);

Assert::assertSame($values, $this->containerParameters[$this->parameterKey]);
}
}

0 comments on commit 072b1dc

Please sign in to comment.