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

ReferenceRepositoryTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testExtendsReferenceRepository() 0 5 1
A setUp() 0 3 1
A testSetAndGetCollectionReference() 0 14 1
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