1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @author : Korotkov Danila <[email protected]> |
7
|
|
|
* @license https://mit-license.org/ MIT |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Structural\Adapter\Tests; |
11
|
|
|
|
12
|
|
|
use Structural\Adapter\Registry; |
13
|
|
|
use Structural\Adapter\Adapter; |
14
|
|
|
use Structural\Adapter\AnotherRegistry; |
15
|
|
|
use Structural\Adapter\RegistryInterface; |
16
|
|
|
use PHPUnit\Framework\TestCase as PHPUnit_Framework_TestCase; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Class AdapterTest |
20
|
|
|
* @package Structural\Adapter\Tests |
21
|
|
|
*/ |
22
|
|
|
class AdapterTest extends PHPUnit_Framework_TestCase |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var Adapter |
26
|
|
|
*/ |
27
|
|
|
private $adapter; |
28
|
|
|
/** |
29
|
|
|
* @var RegistryInterface |
30
|
|
|
*/ |
31
|
|
|
private $registry; |
32
|
|
|
|
33
|
|
|
protected function setUp(): void |
34
|
|
|
{ |
35
|
|
|
$this->registry = new Registry(); |
36
|
|
|
$this->adapter = new Adapter(new AnotherRegistry()); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function testSecond() |
40
|
|
|
{ |
41
|
|
|
$this->getRegistry()->setFirst('First'); |
42
|
|
|
$this->assertEquals('First', $this->getRegistry()->getFirst()); |
43
|
|
|
$this->getRegistry()->setSecond('3.14'); |
44
|
|
|
$this->assertEquals('3.14', $this->getRegistry()->getSecond()); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function testAdapt() |
48
|
|
|
{ |
49
|
|
|
$this->getAdapter()->setFirst('First'); |
50
|
|
|
$this->assertEquals('First', $this->getAdapter()->getFirst()); |
51
|
|
|
$this->getAdapter()->setSecond('3.14'); |
52
|
|
|
$this->assertEquals('3.14', $this->getAdapter()->getSecond()); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return Adapter |
57
|
|
|
*/ |
58
|
|
|
public function getAdapter(): Adapter |
59
|
|
|
{ |
60
|
|
|
return $this->adapter; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return RegistryInterface |
65
|
|
|
*/ |
66
|
|
|
public function getRegistry(): RegistryInterface |
67
|
|
|
{ |
68
|
|
|
return $this->registry; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|