Skip to content

Commit

Permalink
adapted unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
driehle committed Dec 24, 2024
1 parent b2a5491 commit c8be74b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/Cache/DoctrineCacheStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public function __construct($options, protected Cache $cache)

/**
* {@inheritDoc}
*
* @param-out bool $success
*/
protected function internalGetItem(&$normalizedKey, &$success = null, &$casToken = null)
{
Expand Down
6 changes: 1 addition & 5 deletions tests/Form/Element/ProxyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
use function array_shift;
use function func_get_args;

use const PHP_VERSION_ID;

/**
* Tests for the Collection pagination adapter
*
Expand Down Expand Up @@ -279,9 +277,7 @@ public function testExceptionThrownForNonCallableLabelGenerator(): void
'TypeError',
);
$this->expectExceptionMessage(
PHP_VERSION_ID >= 80000
? 'DoctrineModule\Form\Element\Proxy::setLabelGenerator(): Argument #1 ($callable) must be of type callable'
: 'Argument 1 passed to DoctrineModule\Form\Element\Proxy::setLabelGenerator() must be callable',
'DoctrineModule\Form\Element\Proxy::setLabelGenerator(): Argument #1 ($callable) must be of type callable',
);

$this->proxy->setOptions(['label_generator' => 'I throw an invalid type error']);
Expand Down
25 changes: 25 additions & 0 deletions tests/Persistence/ProvidesObjectManagerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace DoctrineModuleTest\Persistence;

use Doctrine\Persistence\ObjectManager;
use DoctrineModuleTest\Persistence\TestAsset\DummyObjectManager;
use PHPUnit\Framework\TestCase as BaseTestCase;

/**
* Test for {@see \DoctrineModule\Persistence\ProvidesObjectManager}
*/
class ProvidesObjectManagerTest extends BaseTestCase
{
public function testSetAndGetObjectManager(): void
{
$objectManager = $this->createMock(ObjectManager::class);
$dummy = new DummyObjectManager();
$dummy->setObjectManager($objectManager);
$retrieved = $dummy->getObjectManager();

$this->assertSame($dummy, $retrieved);
}
}
12 changes: 12 additions & 0 deletions tests/Persistence/TestAsset/DummyObjectManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace DoctrineModuleTest\Persistence\TestAsset;

use DoctrineModule\Persistence\ProvidesObjectManager;

class DummyObjectManager
{
use ProvidesObjectManager;
}
3 changes: 0 additions & 3 deletions tests/Service/DriverFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
use Laminas\ServiceManager\ServiceManager;
use PHPUnit\Framework\TestCase as BaseTestCase;

use function assert;

/**
* Base test case to be used when a service manager instance is required
*/
Expand Down Expand Up @@ -67,7 +65,6 @@ public function testCreateDriverChain(): void
$factory = new DriverFactory('testChainDriver');
$driver = $factory->__invoke($serviceManager, MappingDriverChain::class);
$this->assertInstanceOf(MappingDriverChain::class, $driver);
assert($driver instanceof MappingDriverChain);

$drivers = $driver->getDrivers();
$this->assertCount(1, $drivers);
Expand Down

0 comments on commit c8be74b

Please sign in to comment.