Skip to content

Commit c8be74b

Browse files
committed
adapted unit tests
1 parent b2a5491 commit c8be74b

File tree

5 files changed

+40
-8
lines changed

5 files changed

+40
-8
lines changed

src/Cache/DoctrineCacheStorage.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public function __construct($options, protected Cache $cache)
2828

2929
/**
3030
* {@inheritDoc}
31+
*
32+
* @param-out bool $success
3133
*/
3234
protected function internalGetItem(&$normalizedKey, &$success = null, &$casToken = null)
3335
{

tests/Form/Element/ProxyTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
use function array_shift;
2020
use function func_get_args;
2121

22-
use const PHP_VERSION_ID;
23-
2422
/**
2523
* Tests for the Collection pagination adapter
2624
*
@@ -279,9 +277,7 @@ public function testExceptionThrownForNonCallableLabelGenerator(): void
279277
'TypeError',
280278
);
281279
$this->expectExceptionMessage(
282-
PHP_VERSION_ID >= 80000
283-
? 'DoctrineModule\Form\Element\Proxy::setLabelGenerator(): Argument #1 ($callable) must be of type callable'
284-
: 'Argument 1 passed to DoctrineModule\Form\Element\Proxy::setLabelGenerator() must be callable',
280+
'DoctrineModule\Form\Element\Proxy::setLabelGenerator(): Argument #1 ($callable) must be of type callable',
285281
);
286282

287283
$this->proxy->setOptions(['label_generator' => 'I throw an invalid type error']);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DoctrineModuleTest\Persistence;
6+
7+
use Doctrine\Persistence\ObjectManager;
8+
use DoctrineModuleTest\Persistence\TestAsset\DummyObjectManager;
9+
use PHPUnit\Framework\TestCase as BaseTestCase;
10+
11+
/**
12+
* Test for {@see \DoctrineModule\Persistence\ProvidesObjectManager}
13+
*/
14+
class ProvidesObjectManagerTest extends BaseTestCase
15+
{
16+
public function testSetAndGetObjectManager(): void
17+
{
18+
$objectManager = $this->createMock(ObjectManager::class);
19+
$dummy = new DummyObjectManager();
20+
$dummy->setObjectManager($objectManager);
21+
$retrieved = $dummy->getObjectManager();
22+
23+
$this->assertSame($dummy, $retrieved);
24+
}
25+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DoctrineModuleTest\Persistence\TestAsset;
6+
7+
use DoctrineModule\Persistence\ProvidesObjectManager;
8+
9+
class DummyObjectManager
10+
{
11+
use ProvidesObjectManager;
12+
}

tests/Service/DriverFactoryTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
use Laminas\ServiceManager\ServiceManager;
1818
use PHPUnit\Framework\TestCase as BaseTestCase;
1919

20-
use function assert;
21-
2220
/**
2321
* Base test case to be used when a service manager instance is required
2422
*/
@@ -67,7 +65,6 @@ public function testCreateDriverChain(): void
6765
$factory = new DriverFactory('testChainDriver');
6866
$driver = $factory->__invoke($serviceManager, MappingDriverChain::class);
6967
$this->assertInstanceOf(MappingDriverChain::class, $driver);
70-
assert($driver instanceof MappingDriverChain);
7168

7269
$drivers = $driver->getDrivers();
7370
$this->assertCount(1, $drivers);

0 commit comments

Comments
 (0)