Skip to content

Commit

Permalink
fixed even more issues after CR
Browse files Browse the repository at this point in the history
  • Loading branch information
ViniTou committed Dec 23, 2024
1 parent dd22550 commit 8e9c2c9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 46 deletions.
18 changes: 0 additions & 18 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,3 @@ parameters:
identifier: argument.type
count: 3
path: tests/bundle/SystemInfo/Registry/IdentifierBasedTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\SystemInfo\\View\\SystemInfoViewBuilderTest\:\:getCollectorMock\(\) should return Ibexa\\Bundle\\SystemInfo\\SystemInfo\\Collector\\SystemInfoCollector&PHPUnit\\Framework\\MockObject\\MockObject but returns Ibexa\\Bundle\\SystemInfo\\SystemInfo\\Collector\\SystemInfoCollector\.$#'
identifier: return.type
count: 1
path: tests/bundle/View/SystemInfoViewBuilderTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\SystemInfo\\View\\SystemInfoViewBuilderTest\:\:getConfiguratorMock\(\) should return Ibexa\\Core\\MVC\\Symfony\\View\\Configurator&PHPUnit\\Framework\\MockObject\\MockObject but returns Ibexa\\Core\\MVC\\Symfony\\View\\Configurator\.$#'
identifier: return.type
count: 1
path: tests/bundle/View/SystemInfoViewBuilderTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\SystemInfo\\View\\SystemInfoViewBuilderTest\:\:getRegistryMock\(\) should return Ibexa\\Bundle\\SystemInfo\\SystemInfo\\SystemInfoCollectorRegistry&PHPUnit\\Framework\\MockObject\\MockObject but returns Ibexa\\Bundle\\SystemInfo\\SystemInfo\\SystemInfoCollectorRegistry\.$#'
identifier: return.type
count: 1
path: tests/bundle/View/SystemInfoViewBuilderTest.php
5 changes: 1 addition & 4 deletions src/bundle/DependencyInjection/IbexaSystemInfoExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ public function getAlias()
return self::EXTENSION_NAME;
}

/**
* @return \Ibexa\Bundle\SystemInfo\DependencyInjection\Configuration
*/
public function getConfiguration(array $config, ContainerBuilder $container)
public function getConfiguration(array $config, ContainerBuilder $container): Configuration
{
return new Configuration();
}
Expand Down
9 changes: 1 addition & 8 deletions src/bundle/SystemInfo/Collector/IbexaSystemInfoCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,6 @@ class IbexaSystemInfoCollector implements SystemInfoCollector
/** @var string */
private $kernelProjectDir;

/**
* @param \Ibexa\Bundle\SystemInfo\SystemInfo\Collector\JsonComposerLockSystemInfoCollector|SystemInfoCollector $composerCollector
* @param bool $debug
*/
public function __construct(
SystemInfoCollector $composerCollector,
string $kernelProjectDir,
Expand Down Expand Up @@ -251,11 +247,8 @@ private static function getStability(ComposerSystemInfo $composerInfo): string
$stabilityFlags[$composerInfo->minimumStability] :
$stabilityFlags['stable'];

if ($composerInfo->packages === null) {
return Stability::STABILITIES[$stabilityFlag];
}
// Check if any of the watched packages has lower stability than root
foreach ($composerInfo->packages as $name => $package) {
foreach ($composerInfo->packages ?? [] as $name => $package) {
if (!preg_match(self::PACKAGE_WATCH_REGEX, $name)) {
continue;
}
Expand Down
8 changes: 4 additions & 4 deletions tests/bundle/SystemInfo/Registry/IdentifierBasedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function setUp(): void
/**
* Test adding items to the registry, and getting items from it.
*
* @covers \IdentifierBased::getItem
* @covers \Ibexa\Bundle\SystemInfo\SystemInfo\Registry\IdentifierBased::getItem
*/
public function testAddAndGetItems(): void
{
Expand All @@ -46,7 +46,7 @@ public function testAddAndGetItems(): void
/**
* Test exception when registry item is not found.
*
* @covers \IdentifierBased::getItem
* @covers \Ibexa\Bundle\SystemInfo\SystemInfo\Registry\IdentifierBased::getItem
*/
public function testGetItemNotFound(): void
{
Expand All @@ -57,7 +57,7 @@ public function testGetItemNotFound(): void
/**
* Test replacing an item in the registry.
*
* @covers \IdentifierBased::getItem
* @covers \Ibexa\Bundle\SystemInfo\SystemInfo\Registry\IdentifierBased::getItem
*/
public function testReplaceItem(): void
{
Expand All @@ -76,7 +76,7 @@ public function testReplaceItem(): void
/**
* Test getting all registered identifiers.
*
* @covers \IdentifierBased::getIdentifiers
* @covers \Ibexa\Bundle\SystemInfo\SystemInfo\Registry\IdentifierBased::getItem
* @depends testAddAndGetItems
*/
public function testGetIdentifiers(): void
Expand Down
27 changes: 15 additions & 12 deletions tests/bundle/View/SystemInfoViewBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,19 @@

class SystemInfoViewBuilderTest extends TestCase
{
/**
* @var \PHPUnit\Framework\MockObject\MockObject&\Ibexa\Core\MVC\Symfony\View\Configurator
*/
private Configurator $configuratorMock;

/**
* @var \PHPUnit\Framework\MockObject\MockObject&\Ibexa\Bundle\SystemInfo\SystemInfo\SystemInfoCollectorRegistry
*/
private SystemInfoCollectorRegistry $registryMock;

/**
* @var \PHPUnit\Framework\MockObject\MockObject&\Ibexa\Bundle\SystemInfo\SystemInfo\Collector\SystemInfoCollector
*/
private SystemInfoCollector $collectorMock;

public function testMatches(): void
Expand Down Expand Up @@ -61,9 +70,7 @@ public function testBuildView(): void
*/
protected function getConfiguratorMock(): Configurator
{
if (!isset($this->configuratorMock)) {
$this->configuratorMock = $this->createMock(Configurator::class);
}
$this->configuratorMock ??= $this->createMock(Configurator::class);

return $this->configuratorMock;
}
Expand All @@ -73,23 +80,19 @@ protected function getConfiguratorMock(): Configurator
*/
protected function getRegistryMock(): SystemInfoCollectorRegistry
{
if (!isset($this->registryMock)) {
$this->registryMock = $this->createMock(
SystemInfoCollectorRegistry::class
);
}
$this->registryMock ??= $this->createMock(
SystemInfoCollectorRegistry::class
);

return $this->registryMock;
}

/**
* @return \PHPUnit\Framework\MockObject\MockObject|\Ibexa\Bundle\SystemInfo\SystemInfo\Collector\SystemInfoCollector
* @return \PHPUnit\Framework\MockObject\MockObject&\Ibexa\Bundle\SystemInfo\SystemInfo\Collector\SystemInfoCollector
*/
protected function getCollectorMock(): SystemInfoCollector
{
if (!isset($this->collectorMock)) {
$this->collectorMock = $this->createMock(SystemInfoCollector::class);
}
$this->collectorMock ??= $this->createMock(SystemInfoCollector::class);

return $this->collectorMock;
}
Expand Down

0 comments on commit 8e9c2c9

Please sign in to comment.