Skip to content

Commit

Permalink
adapt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tfrommen committed Jan 9, 2025
1 parent a2c3d3d commit 94c891d
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 27 deletions.
4 changes: 4 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
backupGlobals="false"
stopOnFailure="false">

<php>
<ini name="error_reporting" value="E_ALL"/>
</php>

<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
Expand Down
4 changes: 0 additions & 4 deletions tests/boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

declare(strict_types=1);

// phpcs:disable PSR1

$testsDir = str_replace('\\', '/', __DIR__);
$libDir = dirname($testsDir);
$vendorDir = "{$libDir}/vendor";
Expand All @@ -17,8 +15,6 @@
putenv('LIB_DIR=' . $libDir);
putenv('VENDOR_DIR=' . $vendorDir);

error_reporting(E_ALL); // phpcs:ignore

require_once "{$libDir}/vendor/antecedent/patchwork/Patchwork.php";

if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
Expand Down
5 changes: 1 addition & 4 deletions tests/src/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,13 @@ protected function stubServices(string ...$ids): array
/**
* @param string ...$ids
* @return ContainerInterface
*
* phpcs:disable Inpsyde.CodeQuality.NestingLevel
*/
protected function stubContainer(string ...$ids): ContainerInterface
{
// phpcs:enable Inpsyde.CodeQuality.NestingLevel
return new class ($this->stubServices(...$ids)) implements ContainerInterface
{
/** @var array<string, callable> */
private array $services; // phpcs:ignore
private array $services;

/** @param array<string, callable> $services */
public function __construct(array $services)
Expand Down
3 changes: 0 additions & 3 deletions tests/unit/Container/ContainerConfiguratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,9 @@ static function () use (&$called): \B {
/**
* @test
* @runInSeparateProcess
*
* phpcs:disable Inpsyde.CodeQuality.NestingLevel
*/
public function testExtensionByTypeNested(): void
{
// phpcs:enable Inpsyde.CodeQuality.NestingLevel
$logs = [];
$log = static function (object $object, int ...$nums) use (&$logs): object {
foreach ($nums as $num) {
Expand Down
6 changes: 2 additions & 4 deletions tests/unit/Container/ReadOnlyContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Inpsyde\Modularity\Container\ServiceExtensions;
use Inpsyde\Modularity\Tests\TestCase;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;

class ReadOnlyContainerTest extends TestCase
{
Expand All @@ -27,7 +28,7 @@ public function testBasic(): void
*/
public function testGetUnknown(): void
{
static::expectException(\Exception::class);
static::expectException(NotFoundExceptionInterface::class);

$testee = $this->factoryContainer();
$testee->get('unknown');
Expand Down Expand Up @@ -125,12 +126,9 @@ public function has(string $id): bool

/**
* @test
*
* phpcs:disable Inpsyde.CodeQuality.NestingLevel
*/
public function testFactoriesAndServices(): void
{
// phpcs:enable Inpsyde.CodeQuality.NestingLevel
$expectedServiceKey = 'service';
$expectedFactoryKey = 'factory';

Expand Down
7 changes: 2 additions & 5 deletions tests/unit/PackageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
namespace Inpsyde\Modularity\Tests\Unit;

use Brain\Monkey;
use Inpsyde\Modularity\Module\ExecutableModule;
use Inpsyde\Modularity\Module\ExtendingModule;
use Inpsyde\Modularity\Module\FactoryModule;
use Inpsyde\Modularity\Module\ServiceModule;
use Inpsyde\Modularity\Package;
use Inpsyde\Modularity\Module\ExecutableModule;
use Inpsyde\Modularity\Properties\Properties;
use Inpsyde\Modularity\Tests\TestCase;
use Psr\Container\ContainerInterface;
Expand Down Expand Up @@ -453,12 +453,9 @@ public function testAddModuleFailsAfterBuild(): void

/**
* @test
*
* phpcs:disable Inpsyde.CodeQuality.NestingLevel
*/
public function testBuildResolveServices(): void
{
// phpcs:enable phpcs:disable Inpsyde.CodeQuality.NestingLevel
$module = new class () implements ServiceModule, ExtendingModule, ExecutableModule
{
public function id(): string
Expand Down Expand Up @@ -488,7 +485,7 @@ public function extensions(): array
'service' => function (\ArrayObject $current): object {
return new class ($current)
{
public \ArrayObject $object; // phpcs:ignore
private \ArrayObject $object;

public function __construct(\ArrayObject $object)
{
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Properties/BasePropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static function provideBaseNameData(): \Generator
private function factoryBaseProperties(
string $baseName,
string $basePath,
string $baseUrl = null,
?string $baseUrl = null,
array $properties = []
): BaseProperties {

Expand All @@ -89,7 +89,7 @@ private function factoryBaseProperties(
public function __construct(
string $baseName,
string $basePath,
string $baseUrl = null,
?string $baseUrl = null,
array $properties = []
) {

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Properties/LibraryPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Inpsyde\Modularity\Tests\Unit\Properties;

use Inpsyde\Modularity\Properties\Properties;
use Inpsyde\Modularity\Properties\LibraryProperties;
use Inpsyde\Modularity\Properties\Properties;
use Inpsyde\Modularity\Tests\TestCase;
use org\bovigo\vfs\vfsStream;

Expand All @@ -16,7 +16,7 @@ class LibraryPropertiesTest extends TestCase
*/
public function testForLibraryInvalidFile(): void
{
$this->expectException(\Exception::class);
$this->expectException(\Throwable::class);

LibraryProperties::new('non-existing.file')->basePath();
}
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Properties/PluginPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Inpsyde\Modularity\Tests\Unit\Properties;

use Inpsyde\Modularity\Properties\Properties;
use Brain\Monkey\Functions;
use Inpsyde\Modularity\Properties\PluginProperties;
use Inpsyde\Modularity\Properties\Properties;
use Inpsyde\Modularity\Tests\TestCase;
use Brain\Monkey\Functions;

class PluginPropertiesTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Properties/ThemePropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Inpsyde\Modularity\Tests\Unit\Properties;

use Brain\Monkey\Functions;
use Inpsyde\Modularity\Properties\Properties;
use Inpsyde\Modularity\Properties\ThemeProperties;
use Inpsyde\Modularity\Tests\TestCase;
use Brain\Monkey\Functions;

class ThemePropertiesTest extends TestCase
{
Expand Down

0 comments on commit 94c891d

Please sign in to comment.