|
5 | 5 | namespace Hyde\Framework\Testing\Unit; |
6 | 6 |
|
7 | 7 | use Hyde\Markdown\Models\FrontMatter; |
8 | | -use PHPUnit\Framework\TestCase; |
| 8 | +use Hyde\Testing\UnitTestCase; |
9 | 9 |
|
10 | 10 | /** |
11 | 11 | * @covers \Hyde\Markdown\Models\FrontMatter |
12 | 12 | */ |
13 | | -class FrontMatterModelTest extends TestCase |
| 13 | +class FrontMatterModelTest extends UnitTestCase |
14 | 14 | { |
15 | | - public function test_constructor_creates_new_front_matter_model() |
| 15 | + public function testConstructorCreatesNewFrontMatterModel() |
16 | 16 | { |
17 | | - $matter = new FrontMatter([]); |
18 | | - $this->assertInstanceOf(FrontMatter::class, $matter); |
| 17 | + $this->assertInstanceOf(FrontMatter::class, new FrontMatter([])); |
19 | 18 | } |
20 | 19 |
|
21 | | - public function test_constructor_arguments_are_optional() |
| 20 | + public function testConstructorArgumentsAreOptional() |
22 | 21 | { |
23 | | - $matter = new FrontMatter(); |
24 | | - $this->assertInstanceOf(FrontMatter::class, $matter); |
| 22 | + $this->assertInstanceOf(FrontMatter::class, new FrontMatter()); |
25 | 23 | } |
26 | 24 |
|
27 | | - public function test_constructor_arguments_are_assigned() |
| 25 | + public function testConstructorArgumentsAreAssigned() |
28 | 26 | { |
29 | | - $matter = new FrontMatter(['foo' => 'bar']); |
30 | | - $this->assertEquals(['foo' => 'bar'], $matter->toArray()); |
| 27 | + $this->assertEquals(['foo' => 'bar'], (new FrontMatter(['foo' => 'bar']))->toArray()); |
31 | 28 | } |
32 | 29 |
|
33 | | - public function test_static_from_array_method_creates_new_front_matter_model() |
| 30 | + public function testStaticFromArrayMethodCreatesNewFrontMatterModel() |
34 | 31 | { |
35 | 32 | $matter = FrontMatter::fromArray(['foo' => 'bar']); |
36 | 33 | $this->assertInstanceOf(FrontMatter::class, $matter); |
37 | 34 | $this->assertEquals(['foo' => 'bar'], $matter->toArray()); |
38 | 35 | } |
39 | 36 |
|
40 | | - public function test_to_string_magic_method_converts_model_array_into_yaml_front_matter() |
| 37 | + public function testToStringMagicMethodConvertsModelArrayIntoYamlFrontMatter() |
41 | 38 | { |
42 | 39 | $matter = new FrontMatter(['foo' => 'bar']); |
43 | | - $this->assertEquals("---\nfoo: bar\n---\n", (string) $matter); |
| 40 | + $this->assertEquals("---\nfoo: bar\n---\n", (string) (new FrontMatter(['foo' => 'bar']))); |
44 | 41 | } |
45 | 42 |
|
46 | | - public function test_magic_get_method_returns_front_matter_property() |
| 43 | + public function testMagicGetMethodReturnsFrontMatterProperty() |
47 | 44 | { |
48 | | - $matter = new FrontMatter(['foo' => 'bar']); |
49 | | - $this->assertEquals('bar', $matter->foo); |
| 45 | + $this->assertEquals('bar', (new FrontMatter(['foo' => 'bar']))->foo); |
50 | 46 | } |
51 | 47 |
|
52 | | - public function test_magic_get_method_returns_null_if_property_does_not_exist() |
| 48 | + public function testMagicGetMethodReturnsNullIfPropertyDoesNotExist() |
53 | 49 | { |
54 | | - $matter = new FrontMatter(); |
55 | | - $this->assertNull($matter->foo); |
| 50 | + $this->assertNull((new FrontMatter())->foo); |
56 | 51 | } |
57 | 52 |
|
58 | | - public function test_get_method_returns_data_when_no_argument_is_specified() |
| 53 | + public function testGetMethodReturnsDataWhenNoArgumentIsSpecified() |
59 | 54 | { |
60 | | - $matter = new FrontMatter(); |
61 | | - $this->assertSame([], $matter->get()); |
| 55 | + $this->assertSame([], (new FrontMatter())->get()); |
62 | 56 | } |
63 | 57 |
|
64 | | - public function test_get_method_returns_data_when_no_argument_is_specified_with_data() |
| 58 | + public function testGetMethodReturnsDataWhenNoArgumentIsSpecifiedWithData() |
65 | 59 | { |
66 | | - $matter = new FrontMatter(['foo' => 'bar']); |
67 | | - $this->assertSame(['foo' => 'bar'], $matter->get()); |
| 60 | + $this->assertSame(['foo' => 'bar'], (new FrontMatter(['foo' => 'bar']))->get()); |
68 | 61 | } |
69 | 62 |
|
70 | | - public function test_get_method_returns_null_if_specified_front_matter_key_does_not_exist() |
| 63 | + public function testGetMethodReturnsNullIfSpecifiedFrontMatterKeyDoesNotExist() |
71 | 64 | { |
72 | | - $matter = new FrontMatter(); |
73 | | - $this->assertNull($matter->get('bar')); |
| 65 | + $this->assertNull((new FrontMatter())->get('bar')); |
74 | 66 | } |
75 | 67 |
|
76 | | - public function test_get_method_returns_specified_default_value_if_property_does_not_exist() |
| 68 | + public function testGetMethodReturnsSpecifiedDefaultValueIfPropertyDoesNotExist() |
77 | 69 | { |
78 | 70 | $matter = new FrontMatter(); |
79 | 71 | $this->assertEquals('default', $matter->get('bar', 'default')); |
80 | 72 | } |
81 | 73 |
|
82 | | - public function test_get_method_returns_specified_front_matter_value_if_key_is_specified() |
| 74 | + public function testGetMethodReturnsSpecifiedFrontMatterValueIfKeyIsSpecified() |
83 | 75 | { |
84 | | - $matter = new FrontMatter(['foo' => 'bar']); |
85 | | - $this->assertEquals('bar', $matter->get('foo')); |
| 76 | + $this->assertEquals('bar', (new FrontMatter(['foo' => 'bar']))->get('foo')); |
86 | 77 | } |
87 | 78 |
|
88 | | - public function test_set_method_sets_front_matter_property() |
| 79 | + public function testSetMethodSetsFrontMatterProperty() |
89 | 80 | { |
90 | | - $matter = new FrontMatter(); |
91 | | - $matter->set('foo', 'bar'); |
92 | | - $this->assertEquals('bar', $matter->get('foo')); |
| 81 | + $this->assertEquals('bar', (new FrontMatter())->set('foo', 'bar')->get('foo')); |
93 | 82 | } |
94 | 83 |
|
95 | | - public function test_set_method_returns_self() |
| 84 | + public function testSetMethodReturnsSelf() |
96 | 85 | { |
97 | 86 | $matter = new FrontMatter(); |
98 | 87 | $this->assertSame($matter, $matter->set('foo', 'bar')); |
99 | 88 | } |
100 | 89 |
|
101 | | - public function test_has_method_returns_true_if_property_exists() |
| 90 | + public function testHasMethodReturnsTrueIfPropertyExists() |
102 | 91 | { |
103 | | - $matter = new FrontMatter(['foo' => 'bar']); |
104 | | - $this->assertTrue($matter->has('foo')); |
| 92 | + $this->assertTrue((new FrontMatter(['foo' => 'bar']))->has('foo')); |
105 | 93 | } |
106 | 94 |
|
107 | | - public function test_has_method_returns_false_if_property_does_not_exist() |
| 95 | + public function testHasMethodReturnsFalseIfPropertyDoesNotExist() |
108 | 96 | { |
109 | | - $matter = new FrontMatter(); |
110 | | - $this->assertFalse($matter->has('foo')); |
| 97 | + $this->assertFalse((new FrontMatter())->has('foo')); |
111 | 98 | } |
112 | 99 |
|
113 | | - public function test_to_array_returns_front_matter_array() |
| 100 | + public function testToArrayReturnsFrontMatterArray() |
114 | 101 | { |
115 | | - $matter = new FrontMatter(['foo' => 'bar']); |
116 | | - $this->assertEquals(['foo' => 'bar'], $matter->toArray()); |
| 102 | + $this->assertEquals(['foo' => 'bar'], (new FrontMatter(['foo' => 'bar']))->toArray()); |
117 | 103 | } |
118 | 104 | } |
0 commit comments