Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/Update dependencies #15

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
- '5.4.*'
- '6.0.*'
- '6.2.*'
- '7.0.*'
exclude:
- php: '8.1'
symfony-versions: '7.0.*'
include:
- php: '7.4'
symfony-versions: '^4.4'
Expand All @@ -34,7 +38,7 @@ jobs:
- description: 'Log Code Coverage'
php: '8.2'
coverage: 'xdebug'
symfony-versions: '^6.2'
symfony-versions: '^7.0'

name: PHP ${{ matrix.php }} Symfony ${{ matrix.symfony-versions }} ${{ matrix.description }}
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/composer.lock
/build/
/.phpunit.result.cache
/.phpunit.cache
/node_modules/
/.idea/
/package-lock.json
Expand Down
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
"license": "MIT",
"require": {
"ext-json": "*",
"php": "^7.4 || ^8.0",
"behat/behat": "^3.0",
"symfony/dependency-injection": "^4.4 || ^5.4 || ^6.0",
"symfony/http-client": "^4.4 || ^5.4 || ^6.0",
"symfony/http-kernel": "^4.4 || ^5.4 || ^6.0",
"symfony/routing": "^4.4 || ^5.4 || ^6.0",
"php": "^7.4 || ^8.0 || ^8.2",
"behat/behat": "^3.14",
"symfony/dependency-injection": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/http-client": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/http-kernel": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/routing": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"macpaw/similar-arrays": "^1.0"
},
"require-dev": {
"phpstan/phpstan": "^1.4",
"phpunit/phpunit": "^9.3",
"slevomat/coding-standard": "^7.0",
"squizlabs/php_codesniffer": "^3.6"
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^11.0",
"slevomat/coding-standard": "^8.14",
"squizlabs/php_codesniffer": "^3.8"
},
"autoload": {
"psr-4": {
Expand Down
35 changes: 17 additions & 18 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
backupStaticProperties="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
cacheDirectory=".phpunit.cache"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Behat Api Context Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory>./src</directory>
</include>
<report>
<clover outputFile="clover.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="Behat Api Context Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<clover outputFile="clover.xml"/>
</report>
</coverage>
<source>
<include>
<directory>./src</directory>
</include>
</source>
</phpunit>
6 changes: 5 additions & 1 deletion src/Context/ApiContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@

if (Request::METHOD_GET === $method) {
$queryString = http_build_query($this->requestParams);
} elseif (Request::METHOD_POST === $method || Request::METHOD_PATCH === $method || Request::METHOD_PUT === $method) {
} elseif (
Request::METHOD_POST === $method
|| Request::METHOD_PATCH === $method
|| Request::METHOD_PUT === $method

Check warning on line 142 in src/Context/ApiContext.php

View check run for this annotation

Codecov / codecov/patch

src/Context/ApiContext.php#L140-L142

Added lines #L140 - L142 were not covered by tests
) {
$postFields = $this->requestParams;
}

Expand Down
3 changes: 3 additions & 0 deletions tests/DependencyInjection/BehatApiContextExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
use BehatApiContext\Context\ApiContext;
use BehatApiContext\DependencyInjection\BehatApiContextExtension;
use BehatApiContext\Service\ResetManager\DoctrineResetManager;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;

class BehatApiContextExtensionTest extends TestCase
{
#[Test]
public function testWithEmptyConfig(): void
{
$container = $this->createContainerFromFixture('empty_bundle_config');
Expand All @@ -24,6 +26,7 @@ public function testWithEmptyConfig(): void
self::assertCount(0, $methodCalls);
}

#[Test]
public function testWithFilledConfig(): void
{
$container = $this->createContainerFromFixture('filled_bundle_config');
Expand Down
4 changes: 4 additions & 0 deletions tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

use BehatApiContext\DependencyInjection\Configuration;
use BehatApiContext\Service\ResetManager\DoctrineResetManager;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Processor;

final class ConfigurationTest extends TestCase
{
#[Test]
public function testProcessConfigurationWithEmptyConfiguration(): void
{
$expectedBundleDefaultConfig = [
Expand All @@ -20,6 +22,7 @@ public function testProcessConfigurationWithEmptyConfiguration(): void
$this->assertSame($expectedBundleDefaultConfig, $this->processConfiguration([]));
}

#[Test]
public function testProcessConfigurationWithDefaultConfiguration(): void
{
$config = [
Expand All @@ -35,6 +38,7 @@ public function testProcessConfigurationWithDefaultConfiguration(): void
$this->assertSame($expectedBundleDefaultConfig, $this->processConfiguration($config));
}

#[Test]
public function testProcessConfigurationWithFilledConfiguration(): void
{
$config = [
Expand Down
21 changes: 8 additions & 13 deletions tests/Unit/Context/ApiContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

use Behat\Gherkin\Node\PyStringNode;
use BehatApiContext\Context\ApiContext;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use RuntimeException;
use Symfony\Component\HttpFoundation\RequestStack;
Expand All @@ -27,12 +29,8 @@ protected function setUp(): void
$this->apiContext = new ApiContext($routerMock, $requestStackMock, $kernelMock);
}

/**
* @param PyStringNode $paramsValues
* @param string $initialParamValue
*
* @dataProvider getTheRequestContainsParamsSuccess
*/
#[Test]
#[DataProvider('getTheRequestContainsParamsSuccess')]
public function testTheRequestContainsParamsSuccess(PyStringNode $paramsValues, string $initialParamValue): void
{
$this->assertTrue(str_contains($paramsValues->getStrings()[3], $initialParamValue));
Expand Down Expand Up @@ -84,18 +82,15 @@ public function testTheRequestContainsParamsSuccess(PyStringNode $paramsValues,
);
}

/**
* @param PyStringNode $paramsValues
*
* @dataProvider getTheRequestContainsParamsRuntimeException
*/
#[Test]
#[DataProvider('getTheRequestContainsParamsRuntimeException')]
public function testTheRequestContainsParamsRuntimeException(PyStringNode $paramsValues): void
{
$this->expectException(RuntimeException::class);
$this->apiContext->theRequestContainsParams($paramsValues);
}

public function getTheRequestContainsParamsSuccess(): array
public static function getTheRequestContainsParamsSuccess(): array
{
return [
[
Expand All @@ -122,7 +117,7 @@ public function getTheRequestContainsParamsSuccess(): array
];
}

public function getTheRequestContainsParamsRuntimeException(): array
public static function getTheRequestContainsParamsRuntimeException(): array
{
return [
[
Expand Down
15 changes: 7 additions & 8 deletions tests/Unit/Service/ArrayManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace BehatApiContext\Tests\Unit\Service;

use BehatApiContext\Service\StringManager;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use RuntimeException;
use PHPUnit\Framework\TestCase;

Expand All @@ -21,13 +23,8 @@ protected function setUp(): void
$this->stringManager = new StringManager();
}

/**
* @param array $substitutionValues
* @param string $initialString
* @param string $resultString
*
* @dataProvider getSubstituteValuesDataProvider
*/
#[Test]
#[DataProvider('getSubstituteValuesDataProvider')]
public function testSubstituteValuesSuccess(
array $substitutionValues,
string $initialString,
Expand All @@ -37,7 +34,7 @@ public function testSubstituteValuesSuccess(
self::assertSame($resultString, $result);
}

public function getSubstituteValuesDataProvider(): array
public static function getSubstituteValuesDataProvider(): array
{
return [
[
Expand Down Expand Up @@ -81,6 +78,7 @@ public function getSubstituteValuesDataProvider(): array
];
}

#[Test]
public function testSubstituteValuesKeyNotFound(): void
{
$substitutionValues = ['headerKey' => 'headerValue'];
Expand All @@ -91,6 +89,7 @@ public function testSubstituteValuesKeyNotFound(): void
$this->stringManager->substituteValues($substitutionValues, $initialString);
}

#[Test]
public function testSubstituteValuesInvalidSyntax(): void
{
$substitutionValues = ['headerKey' => 'headerValue'];
Expand Down
Loading