|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Jaxon\Attributes\Tests\TestAttributes; |
|
4
|
|
|
|
|
5
|
|
|
use Jaxon\Attributes\Tests\AttributeTrait; |
|
6
|
|
|
use Jaxon\Attributes\Tests\Attr\Ajax\Component\FuncComponent; |
|
7
|
|
|
use Jaxon\Attributes\Tests\Attr\Ajax\Component\NodeComponent; |
|
8
|
|
|
use Jaxon\Attributes\Tests\Attr\Ajax\Component\PageComponent; |
|
9
|
|
|
use Jaxon\Exception\SetupException; |
|
10
|
|
|
use PHPUnit\Framework\TestCase; |
|
11
|
|
|
|
|
12
|
|
|
use function Jaxon\Attributes\_register; |
|
13
|
|
|
use function Jaxon\jaxon; |
|
14
|
|
|
|
|
15
|
|
|
class ComponentTest extends TestCase |
|
16
|
|
|
{ |
|
17
|
|
|
use AttributeTrait; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @var string |
|
21
|
|
|
*/ |
|
22
|
|
|
private $sCacheDir; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @throws SetupException |
|
26
|
|
|
*/ |
|
27
|
|
|
public function setUp(): void |
|
28
|
|
|
{ |
|
29
|
|
|
$this->sCacheDir = __DIR__ . '/../cache'; |
|
30
|
|
|
@mkdir($this->sCacheDir); |
|
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
jaxon()->di()->getPluginManager()->registerPlugins(); |
|
33
|
|
|
_register(); |
|
34
|
|
|
|
|
35
|
|
|
jaxon()->di()->val('jaxon_attributes_cache_dir', $this->sCacheDir); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @throws SetupException |
|
40
|
|
|
*/ |
|
41
|
|
|
public function tearDown(): void |
|
42
|
|
|
{ |
|
43
|
|
|
jaxon()->reset(); |
|
44
|
|
|
parent::tearDown(); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @throws SetupException |
|
49
|
|
|
*/ |
|
50
|
|
|
public function testNodeComponentExportMethods() |
|
51
|
|
|
{ |
|
52
|
|
|
$xMetadata = $this->getAttributes(NodeComponent::class, |
|
53
|
|
|
[], ['item', 'html', 'render', 'clear', 'visible']); |
|
54
|
|
|
$bExcluded = $xMetadata->isExcluded(); |
|
55
|
|
|
$aProperties = $xMetadata->getProperties(); |
|
56
|
|
|
$aProtected = $xMetadata->getProtectedMethods(); |
|
57
|
|
|
|
|
58
|
|
|
$this->assertFalse($bExcluded); |
|
59
|
|
|
$this->assertCount(0, $aProperties); |
|
60
|
|
|
$this->assertCount(0, $aProtected); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @throws SetupException |
|
65
|
|
|
*/ |
|
66
|
|
|
public function testPageComponentExportMethods() |
|
67
|
|
|
{ |
|
68
|
|
|
$xMetadata = $this->getAttributes(PageComponent::class, |
|
69
|
|
|
[], ['item', 'html', 'render', 'clear', 'visible']); |
|
70
|
|
|
$bExcluded = $xMetadata->isExcluded(); |
|
71
|
|
|
$aProperties = $xMetadata->getProperties(); |
|
72
|
|
|
$aProtected = $xMetadata->getProtectedMethods(); |
|
73
|
|
|
|
|
74
|
|
|
$this->assertFalse($bExcluded); |
|
75
|
|
|
$this->assertCount(0, $aProperties); |
|
76
|
|
|
$this->assertCount(0, $aProtected); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @throws SetupException |
|
81
|
|
|
*/ |
|
82
|
|
|
public function testFuncComponentExportMethods() |
|
83
|
|
|
{ |
|
84
|
|
|
$xMetadata = $this->getAttributes(FuncComponent::class, |
|
85
|
|
|
[], ['paginator']); |
|
86
|
|
|
$bExcluded = $xMetadata->isExcluded(); |
|
87
|
|
|
$aProperties = $xMetadata->getProperties(); |
|
88
|
|
|
$aProtected = $xMetadata->getProtectedMethods(); |
|
89
|
|
|
|
|
90
|
|
|
$this->assertFalse($bExcluded); |
|
91
|
|
|
$this->assertCount(0, $aProperties); |
|
92
|
|
|
$this->assertCount(0, $aProtected); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
// public function testContainerAttributeErrorTwoDi() |
|
96
|
|
|
// { |
|
97
|
|
|
// $this->expectException(SetupException::class); |
|
98
|
|
|
// $this->getAttributes(PropertyAttribute::class, [], ['errorTwoDi']); |
|
99
|
|
|
// } |
|
100
|
|
|
|
|
101
|
|
|
// public function testContainerAttributeErrorDiClass() |
|
102
|
|
|
// { |
|
103
|
|
|
// $this->expectException(SetupException::class); |
|
104
|
|
|
// $this->getAttributes(PropertyAttribute::class, ['errorDiClass']); |
|
105
|
|
|
// } |
|
106
|
|
|
} |
|
107
|
|
|
|
If you suppress an error, we recommend checking for the error condition explicitly: