AbstractManagerTestCase   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 40
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getManagerInterfaceName() 0 4 1
A getRepositoryInterfaceClass() 0 4 1
A getFactoryInterfaceClass() 0 4 1
get() 0 1 ?
getExpectedEntityInterface() 0 1 ?
A testServiceIsValid() 0 5 1
A testReturnsValidRepository() 0 5 1
A testReturnsValidEntityAfterInitialization() 0 6 1
1
<?php
2
/*
3
 * WellCommerce Open-Source E-Commerce Platform
4
 * 
5
 * This file is part of the WellCommerce package.
6
 *
7
 * (c) Adam Piotrowski <[email protected]>
8
 * 
9
 * For the full copyright and license information,
10
 * please view the LICENSE file that was distributed with this source code.
11
 */
12
13
namespace WellCommerce\Bundle\CoreBundle\Test\Manager;
14
15
use WellCommerce\Bundle\CoreBundle\Doctrine\Factory\EntityFactoryInterface;
16
use WellCommerce\Bundle\CoreBundle\Doctrine\Repository\RepositoryInterface;
17
use WellCommerce\Bundle\CoreBundle\Manager\ManagerInterface;
18
use WellCommerce\Bundle\CoreBundle\Test\AbstractTestCase;
19
20
/**
21
 * Class AbstractManagerTestCase
22
 *
23
 * @author  Adam Piotrowski <[email protected]>
24
 */
25
abstract class AbstractManagerTestCase extends AbstractTestCase
26
{
27
    public function testServiceIsValid()
28
    {
29
        $manager = $this->get();
30
        $this->assertInstanceOf($this->getManagerInterfaceName(), $manager);
31
    }
32
    
33
    public function testReturnsValidRepository()
34
    {
35
        $manager = $this->get();
36
        $this->assertInstanceOf($this->getRepositoryInterfaceClass(), $manager->getRepository());
37
    }
38
    
39
    public function testReturnsValidEntityAfterInitialization()
40
    {
41
        $manager  = $this->get();
42
        $resource = $manager->initResource();
43
        $this->assertInstanceOf($this->getExpectedEntityInterface(), $resource);
44
    }
45
    
46
    protected function getManagerInterfaceName(): string
47
    {
48
        return ManagerInterface::class;
49
    }
50
    
51
    protected function getRepositoryInterfaceClass(): string
52
    {
53
        return RepositoryInterface::class;
54
    }
55
    
56
    protected function getFactoryInterfaceClass(): string
57
    {
58
        return EntityFactoryInterface::class;
59
    }
60
    
61
    abstract protected function get(): ManagerInterface;
62
    
63
    abstract protected function getExpectedEntityInterface(): string;
64
}
65