|
1 | 1 | <?php |
2 | 2 |
|
3 | | -namespace skrtdev\Prototypes; |
| 3 | +namespace skrtdev\PrototypesTests; |
4 | 4 |
|
| 5 | +use Error; |
5 | 6 | use PHPUnit\Framework\TestCase; |
| 7 | +use skrtdev\Prototypes\Exception; |
6 | 8 |
|
7 | | -class DemoClass { |
8 | | - use Prototypeable; |
9 | | - |
10 | | - public function existentMethod(): void |
11 | | - { |
12 | | - |
13 | | - } |
14 | | -} |
15 | 9 |
|
16 | 10 | class PrototypesTest extends TestCase |
17 | 11 | { |
18 | 12 | public function testPrototypeCanBeCreated(): void |
19 | 13 | { |
20 | | - $this->assertNull(DemoClass::addMethod('prototypeMethod', fn() => true)); |
| 14 | + $this->assertNull(DemoClassTest::addMethod('prototypeMethod', fn() => $this->property)); |
21 | 15 | } |
22 | 16 |
|
23 | | - public function testErrorIsThrownInNonExistentMethods(): void |
| 17 | + public function testPrototypeCanBeCalled(): void |
24 | 18 | { |
25 | | - $this->expectException(\Error::class); |
26 | | - (new DemoClass)->nonExistentMethod(); |
| 19 | + $this->assertTrue((new DemoClassTest)->prototypeMethod()); |
27 | 20 | } |
28 | 21 |
|
29 | | - public function testCantOverridePrototypes(): void |
| 22 | + public function testErrorIsThrownInNonExistentMethods(): void |
30 | 23 | { |
31 | | - $this->expectException(Exception::class); |
32 | | - DemoClass::addMethod('prototypeMethod', fn() => true); |
| 24 | + $this->expectException(Error::class); |
| 25 | + (new DemoClassTest)->nonExistentMethod(); |
33 | 26 | } |
34 | 27 |
|
35 | | - public function testCantOverrideMethods(): void |
| 28 | + public function testCantOverridePrototypes(): void |
36 | 29 | { |
37 | 30 | $this->expectException(Exception::class); |
38 | | - DemoClass::addMethod('existentMethod', fn() => true); |
| 31 | + DemoClassTest::addMethod('prototypeMethod', fn() => $this->property); |
39 | 32 | } |
40 | 33 |
|
41 | | - public function testNonExistentClass(): void |
| 34 | + public function testCantOverrideMethods(): void |
42 | 35 | { |
43 | 36 | $this->expectException(Exception::class); |
44 | | - Prototypes::addClassMethod('RandomClass', 'RandomMethod', fn() => true); |
| 37 | + DemoClassTest::addMethod('existentMethod', fn() => $this->property); |
45 | 38 | } |
46 | 39 |
|
47 | | - public function testNonPrototypeableClass(): void |
48 | | - { |
49 | | - $this->expectException(Exception::class); |
50 | | - Prototypes::addClassMethod(\stdClass::class, 'RandomMethod', fn() => true); |
51 | | - } |
52 | 40 | } |
0 commit comments