|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Jalle19\StatusManager\Test\Manager; |
|
4
|
|
|
|
|
5
|
|
|
use Jalle19\StatusManager\Configuration\Configuration; |
|
6
|
|
|
use Jalle19\StatusManager\Configuration\Instance; |
|
7
|
|
|
use Jalle19\StatusManager\Configuration\Parser as ConfigurationParser; |
|
8
|
|
|
use Jalle19\StatusManager\Configuration\Reader\ArrayReader; |
|
9
|
|
|
use Jalle19\StatusManager\Test\Configuration\BasicConfigurationTrait; |
|
10
|
|
|
use Monolog\Handler\NullHandler; |
|
11
|
|
|
use Monolog\Logger; |
|
12
|
|
|
use PHPUnit\Framework\TestCase; |
|
13
|
|
|
use Psr\Log\LoggerInterface; |
|
14
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcher; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class AbstractManagerTest |
|
18
|
|
|
* @package Jalle19\StatusManager\Test\Manager |
|
19
|
|
|
* @copyright Copyright © Sam Stenvall 2016- |
|
20
|
|
|
* @license https://www.gnu.org/licenses/gpl.html The GNU General Public License v2.0 |
|
21
|
|
|
*/ |
|
22
|
|
|
abstract class AbstractManagerTest extends TestCase |
|
23
|
|
|
{ |
|
24
|
|
|
|
|
25
|
|
|
use BasicConfigurationTrait; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var Configuration |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $configuration; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var LoggerInterface |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $logger; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var EventDispatcher |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $eventDispatcher; |
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* AbstractManagerTest constructor. |
|
45
|
|
|
*/ |
|
46
|
|
|
public function __construct() |
|
47
|
|
|
{ |
|
48
|
|
|
parent::__construct(); |
|
49
|
|
|
|
|
50
|
|
|
$this->eventDispatcher = new EventDispatcher(); |
|
51
|
|
|
|
|
52
|
|
|
// Configure a null logger to suppress unwanted output |
|
53
|
|
|
$this->logger = new Logger('TestLogger'); |
|
54
|
|
|
$this->logger->setHandlers([new NullHandler()]); |
|
55
|
|
|
|
|
56
|
|
|
// Configure a single test instance |
|
57
|
|
|
$this->configuration = ConfigurationParser::parseConfiguration(new ArrayReader($this->getBaseConfiguration())); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @return Instance |
|
63
|
|
|
*/ |
|
64
|
|
|
protected function getTestInstance() |
|
65
|
|
|
{ |
|
66
|
|
|
$instances = $this->configuration->getInstances(); |
|
67
|
|
|
|
|
68
|
|
|
return $instances[0]; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
|