Skip to content

Commit

Permalink
qa: remove virtual package dependency of `laminas/laminas-cache-stora…
Browse files Browse the repository at this point in the history
…ge-implementation`

`laminas/laminas-cache` can be required by libraries, etc. without having to care about specific implementations. To avoid those libraries to have to require at least one specific implementation during development, the virtual package dependency is being removed. Virtual package dependencies should be moved into projects rather than libraries.

Signed-off-by: Maximilian Bösing <[email protected]>
  • Loading branch information
boesing committed Jan 21, 2024
1 parent 3e46a3b commit f19caca
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 122 deletions.
8 changes: 0 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
},
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"laminas/laminas-cache-storage-implementation": "2.0",
"laminas/laminas-eventmanager": "^3.4",
"laminas/laminas-servicemanager": "^3.21",
"laminas/laminas-stdlib": "^3.6",
Expand All @@ -45,7 +44,6 @@
"webmozart/assert": "^1.9"
},
"require-dev": {
"laminas/laminas-cache-storage-adapter-dev": "^1.0",
"laminas/laminas-cli": "^1.7",
"laminas/laminas-coding-standard": "~2.5.0",
"laminas/laminas-config-aggregator": "^1.13",
Expand Down Expand Up @@ -84,12 +82,6 @@
"LaminasTest\\Cache\\": "test/"
}
},
"repositories": [
{
"type": "path",
"url": "./dev-implementation"
}
],
"scripts": {
"check": [
"@cs-check",
Expand Down
23 changes: 1 addition & 22 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions dev-implementation/README.md

This file was deleted.

36 changes: 0 additions & 36 deletions dev-implementation/VoidAdapter.php

This file was deleted.

13 changes: 0 additions & 13 deletions dev-implementation/composer.json

This file was deleted.

1 change: 0 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<!-- Paths to check -->
<file>src</file>
<file>test</file>
<file>dev-implementation</file>

<!-- Include all rules from the Laminas Coding Standard -->
<rule ref="LaminasCodingStandard">
Expand Down
14 changes: 0 additions & 14 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -876,20 +876,6 @@
<code>testShareByDefaultAndSharedByDefault</code>
</MissingReturnType>
</file>
<file src="test/Storage/CapabilitiesTest.php">
<ArgumentTypeCoercion>
<code><![CDATA['ArrayObject']]></code>
</ArgumentTypeCoercion>
<MissingClosureParamType>
<code>$eventArg</code>
</MissingClosureParamType>
<MixedMethodCall>
<code>attach</code>
</MixedMethodCall>
<UndefinedInterfaceMethod>
<code>getEventManager</code>
</UndefinedInterfaceMethod>
</file>
<file src="test/Storage/Plugin/AbstractCommonPluginTest.php">
<MissingReturnType>
<code>getCommonPluginNamesProvider</code>
Expand Down
1 change: 0 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<projectFiles>
<directory name="src"/>
<directory name="test"/>
<directory name="dev-implementation"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>
Expand Down
6 changes: 3 additions & 3 deletions test/StaticAnalysis/AdapterPluginManagerTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

namespace LaminasTest\Cache\StaticAnalysis;

use Laminas\Cache\Storage\Adapter\Dev\VoidAdapter;
use Laminas\Cache\Storage\AdapterPluginManager;
use Laminas\Cache\Storage\StorageInterface;
use LaminasTest\Cache\Storage\TestAsset\MockAdapter;

final class AdapterPluginManagerTypes
{
public function willReturnAnAdapterUsingFQCN(AdapterPluginManager $manager): StorageInterface
{
return $manager->get(VoidAdapter::class);
return $manager->get(MockAdapter::class);
}

public function validateWillAssertInstanceType(AdapterPluginManager $manager, object $instance): StorageInterface
Expand All @@ -24,6 +24,6 @@ public function validateWillAssertInstanceType(AdapterPluginManager $manager, ob

public function buildWillReturnAdapterUsingFQCN(AdapterPluginManager $manager): StorageInterface
{
return $manager->build(VoidAdapter::class);
return $manager->build(MockAdapter::class);
}
}
46 changes: 26 additions & 20 deletions test/Storage/CapabilitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

namespace LaminasTest\Cache\Storage;

use Laminas\Cache\Storage\Adapter\Dev\VoidAdapter;
use ArrayObject;
use Laminas\Cache\Storage\Capabilities;
use Laminas\EventManager\Event;
use Laminas\Cache\Storage\StorageInterface;
use Laminas\EventManager\EventManagerInterface;
use LaminasTest\Cache\Storage\TestAsset\EventsCapableStorageInterface;
use PHPUnit\Framework\TestCase;
use stdClass;

Expand Down Expand Up @@ -40,14 +42,14 @@ class CapabilitiesTest extends TestCase
/**
* The storage adapter
*
* @var VoidAdapter
* @var StorageInterface
*/
protected $adapter;

public function setUp(): void
{
$this->marker = new stdClass();
$this->adapter = new VoidAdapter();
$this->adapter = $this->createMock(StorageInterface::class);

$this->baseCapabilities = new Capabilities($this->adapter, $this->marker);
$this->capabilities = new Capabilities($this->adapter, $this->marker, [], $this->baseCapabilities);
Expand All @@ -73,21 +75,25 @@ public function testGetCapabilityByBaseCapabilities(): void

public function testTriggerCapabilityEvent(): void
{
$em = $this->capabilities->getAdapter()->getEventManager();
$event = null;
$em->attach('capability', static function ($eventArg) use (&$event): void {
$event = $eventArg;
});

$this->capabilities->setMaxTtl($this->marker, 100);

self::assertInstanceOf(Event::class, $event);
self::assertEquals('capability', $event->getName());
self::assertSame($this->adapter, $event->getTarget());

$params = $event->getParams();
self::assertInstanceOf('ArrayObject', $params);
self::assertTrue(isset($params ['maxTtl']));
self::assertEquals(100, $params['maxTtl']);
$eventManager = $this->createMock(EventManagerInterface::class);

$adapter = $this->createMock(EventsCapableStorageInterface::class);
$adapter
->expects(self::once())
->method('getEventManager')
->willReturn($eventManager);

$eventManager
->expects(self::once())
->method('trigger')
->with('capability', $adapter, self::callback(static function ($params): bool {
self::assertInstanceOf(ArrayObject::class, $params);
self::assertTrue(isset($params['maxTtl']));
self::assertEquals(100, $params['maxTtl']);
return true;
}));

$capabilities = new Capabilities($adapter, $this->marker);
$capabilities->setMaxTtl($this->marker, 100);
}
}
12 changes: 12 additions & 0 deletions test/Storage/TestAsset/EventsCapableStorageInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace LaminasTest\Cache\Storage\TestAsset;

use Laminas\Cache\Storage\StorageInterface;
use Laminas\EventManager\EventsCapableInterface;

interface EventsCapableStorageInterface extends EventsCapableInterface, StorageInterface
{
}

0 comments on commit f19caca

Please sign in to comment.