Completed
Push — migrate-files-no-interaction ( 025687...608925 )
by
unknown
46:43 queued 18:48
created

HandlerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 13

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 8 1
B setUp() 0 25 1
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Publish\Core\Persistence\Cache\Tests;
8
9
use eZ\Publish\Core\Persistence\Cache\Handler as CacheHandler;
10
use eZ\Publish\Core\Persistence\Cache\SectionHandler as CacheSectionHandler;
11
use eZ\Publish\Core\Persistence\Cache\LocationHandler as CacheLocationHandler;
12
use eZ\Publish\Core\Persistence\Cache\ContentHandler as CacheContentHandler;
13
use eZ\Publish\Core\Persistence\Cache\ContentLanguageHandler as CacheContentLanguageHandler;
14
use eZ\Publish\Core\Persistence\Cache\ContentTypeHandler as CacheContentTypeHandler;
15
use eZ\Publish\Core\Persistence\Cache\UserHandler as CacheUserHandler;
16
use eZ\Publish\Core\Persistence\Cache\TransactionHandler as CacheTransactionHandler;
17
use eZ\Publish\Core\Persistence\Cache\TrashHandler as CacheTrashHandler;
18
use eZ\Publish\Core\Persistence\Cache\UrlAliasHandler as CacheUrlAliasHandler;
19
use eZ\Publish\Core\Persistence\Cache\ObjectStateHandler as CacheObjectStateHandler;
20
use eZ\Publish\Core\Persistence\Cache\URLHandler as CacheUrlHandler;
21
use eZ\Publish\SPI\Persistence\Handler;
22
use eZ\Publish\Core\Persistence\Cache\CacheServiceDecorator;
23
use eZ\Publish\Core\Persistence\Cache\PersistenceLogger;
24
use PHPUnit\Framework\TestCase;
25
26
/**
27
 * Abstract test case for spi cache impl.
28
 */
29
abstract class HandlerTest extends TestCase
30
{
31
    /**
32
     * @var \Stash\Interfaces\PoolInterface|\PHPUnit_Framework_MockObject_MockObject
33
     */
34
    protected $cacheMock;
35
36
    /**
37
     * @var \eZ\Publish\SPI\Persistence\Handler|\PHPUnit_Framework_MockObject_MockObject
38
     */
39
    protected $persistenceHandlerMock;
40
41
    /**
42
     * @var \eZ\Publish\SPI\Persistence\TransactionHandler|\PHPUnit_Framework_MockObject_MockObject
43
     */
44
    protected $transactionHandlerMock;
45
46
    /**
47
     * @var \eZ\Publish\Core\Persistence\Cache\Handler
48
     */
49
    protected $persistenceCacheHandler;
50
51
    /**
52
     * @var \eZ\Publish\Core\Persistence\Cache\PersistenceLogger|\PHPUnit_Framework_MockObject_MockObject
53
     */
54
    protected $loggerMock;
55
56
    /**
57
     * @param array|null $persistenceFactoryMockMethod
58
     */
59
    protected $persistenceFactoryMockMethods = array();
60
61
    /**
62
     * Setup the HandlerTest.
63
     */
64
    protected function setUp()
65
    {
66
        parent::setUp();
67
68
        $this->persistenceHandlerMock = $this->createMock(Handler::class);
69
        $this->cacheMock = $this->createMock(CacheServiceDecorator::class);
70
        $this->loggerMock = $this->createMock(PersistenceLogger::class);
71
72
        $this->persistenceCacheHandler = new CacheHandler(
73
            $this->persistenceHandlerMock,
74
            new CacheSectionHandler($this->cacheMock, $this->persistenceHandlerMock, $this->loggerMock),
75
            new CacheLocationHandler($this->cacheMock, $this->persistenceHandlerMock, $this->loggerMock),
76
            new CacheContentHandler($this->cacheMock, $this->persistenceHandlerMock, $this->loggerMock),
77
            new CacheContentLanguageHandler($this->cacheMock, $this->persistenceHandlerMock, $this->loggerMock),
78
            new CacheContentTypeHandler($this->cacheMock, $this->persistenceHandlerMock, $this->loggerMock),
79
            new CacheUserHandler($this->cacheMock, $this->persistenceHandlerMock, $this->loggerMock),
80
            new CacheTransactionHandler($this->cacheMock, $this->persistenceHandlerMock, $this->loggerMock),
81
            new CacheTrashHandler($this->cacheMock, $this->persistenceHandlerMock, $this->loggerMock),
82
            new CacheUrlAliasHandler($this->cacheMock, $this->persistenceHandlerMock, $this->loggerMock),
83
            new CacheObjectStateHandler($this->cacheMock, $this->persistenceHandlerMock, $this->loggerMock),
84
            new CacheUrlHandler($this->cacheMock, $this->persistenceHandlerMock, $this->loggerMock),
85
            $this->loggerMock,
86
            $this->cacheMock
87
        );
88
    }
89
90
    /**
91
     * Tear down test (properties).
92
     */
93
    protected function tearDown()
94
    {
95
        unset($this->cacheMock);
96
        unset($this->persistenceHandlerMock);
97
        unset($this->persistenceCacheHandler);
98
        unset($this->loggerMock);
99
        parent::tearDown();
100
    }
101
}
102