Skip to content

Commit

Permalink
Make CI green (#26)
Browse files Browse the repository at this point in the history
* CI fixes

* Allow dev-master of nyholm/symfony-bundle-test

* cs

* Reduce number of SF versions

* Adapt to version 2 of test lib

* Fixes

* minor

* Updated baselien
  • Loading branch information
Nyholm authored Apr 3, 2022
1 parent a46b9ef commit 4366f0e
Show file tree
Hide file tree
Showing 14 changed files with 108 additions and 66 deletions.
14 changes: 7 additions & 7 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.editorconfig export-ignore
.gitattributes export-ignore
/.github/ export-ignore
.gitignore export-ignore
/.php_cs export-ignore
/phpunit.xml.dist export-ignore
/tests/ export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
/.github/ export-ignore
.gitignore export-ignore
/.php-cs-fixer.php export-ignore
/phpunit.xml.dist export-ignore
/tests/ export-ignore
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
strategy:
max-parallel: 10
matrix:
php: [ '7.2', '7.3', '7.4', '8.0']
sf_version: [ '4.4.*', '5.3.*' ]
php: [ '8.0', '8.1']
sf_version: [ '5.4.*', '6.0.*']
include:
- php: 8.0
sf_version: '6.0.*'
- php: 7.2
sf_version: '5.4.*'

steps:
- name: Set up PHP
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
coverage: none
tools: phpstan:0.12.92, cs2pr
tools: phpstan:1.5.3, cs2pr

- name: Download dependencies
uses: ramsey/composer-install@v1
Expand All @@ -34,9 +34,9 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
coverage: none
tools: php-cs-fixer:2.19.0, cs2pr
tools: php-cs-fixer:3.8.0, cs2pr

- name: PHP-CS-Fixer
run: php-cs-fixer fix --dry-run --format=checkstyle | cs2pr
Expand All @@ -51,9 +51,9 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
coverage: none
tools: vimeo/psalm:4.8.1
tools: vimeo/psalm:4.22.0

- name: Download dependencies
uses: ramsey/composer-install@v1
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/.php_cs.cache
/.php-cs-fixer.cache
/.phpunit.result.cache
/composer.lock
/phpunit.xml
Expand Down
4 changes: 2 additions & 2 deletions .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

$finder = PhpCsFixer\Finder::create()
$finder = (new PhpCsFixer\Finder())
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
;

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,
])
Expand Down
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "happyr/service-mocking",
"type": "symfony-bundle",
"description": "Make it easy to mock services in a built container",
"license": "MIT",
"type": "symfony-bundle",
"keywords": [
"Symfony",
"testing",
"mock"
],
"license": "MIT",
"authors": [
{
"name": "Tobias Nyholm",
Expand All @@ -17,14 +17,16 @@
"require": {
"php": ">=7.2",
"friendsofphp/proxy-manager-lts": "^1.0",
"symfony/config": "^4.4 || ^5.1 || ^6.0",
"symfony/dependency-injection": "^4.4 || ^5.1 || ^6.0",
"symfony/http-kernel": "^4.4 || ^5.1 || ^6.0"
"symfony/config": "^5.4 || ^6.0",
"symfony/dependency-injection": "^5.4 || ^6.0",
"symfony/http-kernel": "^5.4 || ^6.0"
},
"require-dev": {
"nyholm/symfony-bundle-test": "^1.6",
"symfony/phpunit-bridge": "^5.3"
"nyholm/symfony-bundle-test": "dev-clear-cache",
"symfony/phpunit-bridge": "^6.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"Happyr\\ServiceMocking\\": "src/"
Expand All @@ -34,7 +36,5 @@
"psr-4": {
"Happyr\\ServiceMocking\\Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ parameters:
count: 1
path: src/DependencyInjection/CompilerPass/ProxyServiceWithMockPass.php

-
message: "#^Parameter \\#1 \\$class of method Symfony\\\\Component\\\\DependencyInjection\\\\Definition\\:\\:setClass\\(\\) expects string\\|null, false given\\.$#"
count: 1
path: src/DependencyInjection/CompilerPass/ProxyServiceWithMockPass.php

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
count: 1
Expand Down
26 changes: 23 additions & 3 deletions psalm.baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.8.1@f73f2299dbc59a3e6c4d66cff4605176e728ee69">
<files psalm-version="4.22.0@fc2c6ab4d5fa5d644d8617089f012f3bb84b8703">
<file src="src/ServiceMock.php">
<UndefinedInterfaceMethod occurrences="1">
<code>getWrappedValueHolderValue</code>
Expand All @@ -15,8 +15,23 @@
<code>fn</code>
</ParseError>
</file>
<file src="vendor/laminas/laminas-code/src/Generator/FileGenerator.php">
<ParseError occurrences="4">
<code>,</code>
<code>,</code>
<code>=&gt;</code>
<code>fn</code>
</ParseError>
</file>
<file src="vendor/laminas/laminas-code/src/Generator/MethodGenerator.php">
<ParseError occurrences="3">
<code>$item1</code>
<code>)</code>
<code>fn</code>
</ParseError>
</file>
<file src="vendor/laminas/laminas-code/src/Generator/TypeGenerator.php">
<ParseError occurrences="13">
<ParseError occurrences="15">
<code>$left</code>
<code>$type</code>
<code>$type</code>
Expand All @@ -30,12 +45,17 @@
<code>,</code>
<code>fn</code>
<code>fn</code>
<code>fn</code>
<code>fn</code>
</ParseError>
</file>
<file src="vendor/laminas/laminas-code/src/Generator/TypeGenerator/AtomicType.php">
<ParseError occurrences="3">
<ParseError occurrences="6">
<code>$type</code>
<code>$type</code>
<code>)</code>
<code>)</code>
<code>fn</code>
<code>fn</code>
</ParseError>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ProxyServiceWithMockPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
/** @var array $serviceIds */
$serviceIds = $container->getParameter('happyr_service_mock.services');

foreach ($container->findTaggedServiceIds('happyr_service_mock') as $id => $tags) {
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Configuration implements ConfigurationInterface
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('happyr_service_mocking');

Expand Down
2 changes: 1 addition & 1 deletion src/Generator/LazyLoadingValueHolderGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class LazyLoadingValueHolderGenerator implements ProxyGeneratorInterface
*
* @psalm-param array{skipDestructor?: bool, fluentSafe?: bool} $proxyOptions
*/
public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator/*, array $proxyOptions = []*/)
public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator/* , array $proxyOptions = [] */)
{
/** @psalm-var array{skipDestructor?: bool, fluentSafe?: bool} $proxyOptions */
$proxyOptions = func_num_args() >= 3 ? func_get_arg(2) : [];
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function all($proxy, string $methodName, callable $func): void
*/
public static function resetAll(): void
{
foreach (static::$definitions as $definition) {
foreach (self::$definitions as $definition) {
$definition->clear();
}
}
Expand Down
63 changes: 33 additions & 30 deletions tests/Functional/BundleInitializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,43 @@
use Happyr\ServiceMocking\HappyrServiceMockingBundle;
use Happyr\ServiceMocking\ServiceMock;
use Happyr\ServiceMocking\Tests\Resource\ExampleService;
use Happyr\ServiceMocking\Tests\Resource\Kernel;
use Happyr\ServiceMocking\Tests\Resource\ServiceWithFactory;
use Happyr\ServiceMocking\Tests\Resource\StatefulService;
use Nyholm\BundleTest\BaseBundleTestCase;
use ProxyManager\Proxy\VirtualProxyInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\HttpKernel\KernelInterface;

class BundleInitializationTest extends BaseBundleTestCase
class BundleInitializationTest extends KernelTestCase
{
protected function getBundleClass()
protected static function getKernelClass(): string
{
return HappyrServiceMockingBundle::class;
return Kernel::class;
}

public function testInitBundle()
protected static function createKernel(array $options = []): KernelInterface
{
$kernel = $this->createKernel();
$kernel->addConfigFile(__DIR__.'/config.yml');

// Boot the kernel.
$this->bootKernel();
if (null !== static::$kernel) {
return static::$kernel;
}
/**
* @var Kernel $kernel
*/
$kernel = parent::createKernel($options);
$kernel->addTestBundle(HappyrServiceMockingBundle::class);
$configFile = $options['config_file'] ?? 'config.yml';
$kernel->addTestConfig(__DIR__.'/'.$configFile);
unset($options['config_file']);

$kernel->handleOptions($options);

return $kernel;
}

// Get the container
$container = $this->getContainer();
public function testInitBundle()
{
$kernel = self::bootKernel();
$container = $kernel->getContainer();

$this->assertTrue($container->has(ExampleService::class));
$service = $container->get(ExampleService::class);
Expand Down Expand Up @@ -74,11 +89,8 @@ public function testInitBundle()

public function testRebootBundle()
{
$kernel = $this->createKernel();
$kernel->addConfigFile(__DIR__.'/config.yml');

$this->bootKernel();
$container = $this->getContainer();
$kernel = self::bootKernel();
$container = $kernel->getContainer();

$this->assertTrue($container->has(StatefulService::class));
$service = $container->get(StatefulService::class);
Expand All @@ -98,11 +110,8 @@ public function testRebootBundle()

public function testReloadRealObjectOnRebootBundle()
{
$kernel = $this->createKernel();
$kernel->addConfigFile(__DIR__.'/config.yml');

$this->bootKernel();
$container = $this->getContainer();
$kernel = self::bootKernel();
$container = $kernel->getContainer();

$this->assertTrue($container->has(StatefulService::class));
$service = $container->get(StatefulService::class);
Expand All @@ -117,14 +126,8 @@ public function testReloadRealObjectOnRebootBundle()

public function testInitEmptyBundle()
{
$kernel = $this->createKernel();
$kernel->addConfigFile(__DIR__.'/empty.yml');

// Boot the kernel.
$this->bootKernel();

// Get the container
$container = $this->getContainer();
$kernel = self::bootKernel(['config_file' => 'empty.yml']);
$container = $kernel->getContainer();

$this->assertTrue($container->has(ExampleService::class));
$service = $container->get(ExampleService::class);
Expand Down
13 changes: 13 additions & 0 deletions tests/Resource/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Happyr\ServiceMocking\Tests\Resource;

use Nyholm\BundleTest\TestKernel;

class Kernel extends TestKernel
{
public function shutdown($clearCache = true): void
{
parent::shutdown(false);
}
}

0 comments on commit 4366f0e

Please sign in to comment.