Passed
Pull Request — master (#4)
by Alex
01:50
created

testSetAndGetCollectionReference()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 14
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arp\LaminasDoctrineFixtures\Service\Repository;
6
7
use Doctrine\Common\Persistence\ObjectManager;
8
use PHPUnit\Framework\MockObject\MockObject;
9
use PHPUnit\Framework\TestCase;
10
11
/**
12
 * @author  Alex Patterson <[email protected]>
13
 * @package Arp\LaminasDoctrineFixtures\Service\Repository
14
 */
15
final class ReferenceRepositoryTest extends TestCase
16
{
17
    /**
18
     * @var ObjectManager|MockObject
19
     */
20
    private $objectManager;
21
22
    public function setUp(): void
23
    {
24
        $this->objectManager = $this->getMockForAbstractClass(ObjectManager::class);
25
    }
26
27
    /**
28
     * Assert that the ReferenceRepository is of type \Doctrine\Common\DataFixtures\ReferenceRepository.
29
     *
30
     * @covers \Arp\LaminasDoctrineFixtures\Service\Repository\ReferenceRepository
31
     */
32
    public function testExtendsReferenceRepository(): void
33
    {
34
        $referenceRepository = new ReferenceRepository($this->objectManager);
35
36
        $this->assertInstanceOf(\Doctrine\Common\DataFixtures\ReferenceRepository::class, $referenceRepository);
37
    }
38
39
    /**
40
     * Assert a collection reference can be set and get on a ReferenceRepository via
41
     * setCollectionReference() and getCollectionReference().
42
     *
43
     * @covers \Arp\LaminasDoctrineFixtures\Service\Repository\ReferenceRepository::setCollectionReference
44
     * @covers \Arp\LaminasDoctrineFixtures\Service\Repository\ReferenceRepository::getCollectionReference
45
     */
46
    public function testSetAndGetCollectionReference(): void
47
    {
48
        $collectionReference = new ReferenceRepository($this->objectManager);
49
50
        /** @var \stdClass[] $data */
51
        $data = [
52
            new \stdClass(),
53
            new \stdClass(),
54
            new \stdClass(),
55
        ];
56
57
        $collectionReference->setCollectionReference('foo', $data);
58
59
        $this->assertSame($data, $collectionReference->getCollectionReference('foo'));
60
    }
61
}
62