17
17
18
18
namespace OpenMage \Tests \Unit \Mage \Admin \Model ;
19
19
20
+ use Exception ;
20
21
use Generator ;
21
22
use Mage ;
22
23
use Mage_Admin_Model_Block as Subject ;
23
24
use PHPUnit \Framework \TestCase ;
24
25
25
26
class BlockTest extends TestCase
26
27
{
27
- public Subject $ subject ;
28
+ private static Subject $ subject ;
28
29
29
- public function setUp (): void
30
+ public static function setUpBeforeClass (): void
30
31
{
31
32
Mage::app ();
32
- $ this -> subject = Mage::getModel ('admin/block ' );
33
+ self :: $ subject = Mage::getModel ('admin/block ' );
33
34
}
34
35
35
36
/**
@@ -38,7 +39,7 @@ public function setUp(): void
38
39
*
39
40
* @group Mage_Admin
40
41
* @group Mage_Admin_Model
41
- * @group Mage_Admin_Model_Test
42
+ * @throws Exception
42
43
*/
43
44
public function testValidate ($ expectedResult , array $ methods ): void
44
45
{
@@ -51,7 +52,7 @@ public function testValidate($expectedResult, array $methods): void
51
52
52
53
$ mock ->method ('getBlockName ' )->willReturn ($ methods ['getBlockName ' ]);
53
54
$ mock ->method ('getIsAllowed ' )->willReturn ($ methods ['getIsAllowed ' ]);
54
- $ this -> assertEquals ($ expectedResult , $ mock ->validate ());
55
+ static :: assertEquals ($ expectedResult , $ mock ->validate ());
55
56
}
56
57
57
58
public function provideValidateAdminBlockData (): Generator
@@ -86,7 +87,7 @@ public function provideValidateAdminBlockData(): Generator
86
87
[$ errorIncorrectBlockName ],
87
88
[
88
89
'getBlockName ' => '~ ' ,
89
- 'getIsAllowed ' => '0 ' ,
90
+ 'getIsAllowed ' => '1 ' ,
90
91
],
91
92
];
92
93
yield 'errors: invalid blockname ' => [
@@ -96,6 +97,34 @@ public function provideValidateAdminBlockData(): Generator
96
97
'getIsAllowed ' => '0 ' ,
97
98
],
98
99
];
100
+ yield 'errors: null blockname ' => [
101
+ ['Block Name is required field. ' ],
102
+ [
103
+ 'getBlockName ' => null ,
104
+ 'getIsAllowed ' => '1 ' ,
105
+ ],
106
+ ];
107
+ yield 'errors: special chars in blockname ' => [
108
+ [$ errorIncorrectBlockName ],
109
+ [
110
+ 'getBlockName ' => '!@#$%^&*() ' ,
111
+ 'getIsAllowed ' => '1 ' ,
112
+ ],
113
+ ];
114
+ yield 'errors: numeric blockname ' => [
115
+ [$ errorIncorrectBlockName ],
116
+ [
117
+ 'getBlockName ' => '12345 ' ,
118
+ 'getIsAllowed ' => '1 ' ,
119
+ ],
120
+ ];
121
+ yield 'valid: mixed case blockname ' => [
122
+ true ,
123
+ [
124
+ 'getBlockName ' => 'Test/Block ' ,
125
+ 'getIsAllowed ' => '1 ' ,
126
+ ],
127
+ ];
99
128
}
100
129
101
130
/**
@@ -104,6 +133,6 @@ public function provideValidateAdminBlockData(): Generator
104
133
*/
105
134
public function testIsTypeAllowed (): void
106
135
{
107
- $ this -> assertIsBool ($ this -> subject ->isTypeAllowed ('invalid-type ' ));
136
+ static :: assertIsBool (self :: $ subject ->isTypeAllowed ('invalid-type ' ));
108
137
}
109
138
}
0 commit comments