15
15
*/
16
16
final class DocumentTest extends TestCase
17
17
{
18
- /**
19
- * @var Document
20
- */
21
- private $ subject ;
22
-
23
- protected function setUp (): void
24
- {
25
- $ this ->subject = new Document ();
26
- }
27
-
28
18
/**
29
19
* @test
30
20
*/
31
21
public function implementsRenderable (): void
32
22
{
33
- self ::assertInstanceOf (Renderable::class, $ this -> subject );
23
+ self ::assertInstanceOf (Renderable::class, new Document () );
34
24
}
35
25
36
26
/**
37
27
* @test
38
28
*/
39
29
public function implementsCommentable (): void
40
30
{
41
- self ::assertInstanceOf (Commentable::class, $ this -> subject );
31
+ self ::assertInstanceOf (Commentable::class, new Document () );
42
32
}
43
33
44
34
/**
45
35
* @test
46
36
*/
47
37
public function getContentsInitiallyReturnsEmptyArray (): void
48
38
{
49
- self ::assertSame ([], $ this ->subject ->getContents ());
39
+ $ subject = new Document ();
40
+
41
+ self ::assertSame ([], $ subject ->getContents ());
50
42
}
51
43
52
44
/**
@@ -70,29 +62,35 @@ public static function contentsDataProvider(): array
70
62
*/
71
63
public function setContentsSetsContents (array $ contents ): void
72
64
{
73
- $ this ->subject ->setContents ($ contents );
65
+ $ subject = new Document ();
66
+
67
+ $ subject ->setContents ($ contents );
74
68
75
- self ::assertSame ($ contents , $ this -> subject ->getContents ());
69
+ self ::assertSame ($ contents , $ subject ->getContents ());
76
70
}
77
71
78
72
/**
79
73
* @test
80
74
*/
81
75
public function setContentsReplacesContentsSetInPreviousCall (): void
82
76
{
77
+ $ subject = new Document ();
78
+
83
79
$ contents2 = [new DeclarationBlock ()];
84
80
85
- $ this -> subject ->setContents ([new DeclarationBlock ()]);
86
- $ this -> subject ->setContents ($ contents2 );
81
+ $ subject ->setContents ([new DeclarationBlock ()]);
82
+ $ subject ->setContents ($ contents2 );
87
83
88
- self ::assertSame ($ contents2 , $ this -> subject ->getContents ());
84
+ self ::assertSame ($ contents2 , $ subject ->getContents ());
89
85
}
90
86
91
87
/**
92
88
* @test
93
89
*/
94
90
public function insertContentBeforeInsertsContentBeforeSibling (): void
95
91
{
92
+ $ subject = new Document ();
93
+
96
94
$ bogusOne = new DeclarationBlock ();
97
95
$ bogusOne ->setSelectors ('.bogus-one ' );
98
96
$ bogusTwo = new DeclarationBlock ();
@@ -104,21 +102,23 @@ public function insertContentBeforeInsertsContentBeforeSibling(): void
104
102
$ sibling = new DeclarationBlock ();
105
103
$ sibling ->setSelectors ('.sibling ' );
106
104
107
- $ this -> subject ->setContents ([$ bogusOne , $ sibling , $ bogusTwo ]);
105
+ $ subject ->setContents ([$ bogusOne , $ sibling , $ bogusTwo ]);
108
106
109
- self ::assertCount (3 , $ this -> subject ->getContents ());
107
+ self ::assertCount (3 , $ subject ->getContents ());
110
108
111
- $ this -> subject ->insertBefore ($ item , $ sibling );
109
+ $ subject ->insertBefore ($ item , $ sibling );
112
110
113
- self ::assertCount (4 , $ this -> subject ->getContents ());
114
- self ::assertSame ([$ bogusOne , $ item , $ sibling , $ bogusTwo ], $ this -> subject ->getContents ());
111
+ self ::assertCount (4 , $ subject ->getContents ());
112
+ self ::assertSame ([$ bogusOne , $ item , $ sibling , $ bogusTwo ], $ subject ->getContents ());
115
113
}
116
114
117
115
/**
118
116
* @test
119
117
*/
120
118
public function insertContentBeforeAppendsIfSiblingNotFound (): void
121
119
{
120
+ $ subject = new Document ();
121
+
122
122
$ bogusOne = new DeclarationBlock ();
123
123
$ bogusOne ->setSelectors ('.bogus-one ' );
124
124
$ bogusTwo = new DeclarationBlock ();
@@ -133,13 +133,13 @@ public function insertContentBeforeAppendsIfSiblingNotFound(): void
133
133
$ orphan = new DeclarationBlock ();
134
134
$ orphan ->setSelectors ('.forever-alone ' );
135
135
136
- $ this -> subject ->setContents ([$ bogusOne , $ sibling , $ bogusTwo ]);
136
+ $ subject ->setContents ([$ bogusOne , $ sibling , $ bogusTwo ]);
137
137
138
- self ::assertCount (3 , $ this -> subject ->getContents ());
138
+ self ::assertCount (3 , $ subject ->getContents ());
139
139
140
- $ this -> subject ->insertBefore ($ item , $ orphan );
140
+ $ subject ->insertBefore ($ item , $ orphan );
141
141
142
- self ::assertCount (4 , $ this -> subject ->getContents ());
143
- self ::assertSame ([$ bogusOne , $ sibling , $ bogusTwo , $ item ], $ this -> subject ->getContents ());
142
+ self ::assertCount (4 , $ subject ->getContents ());
143
+ self ::assertSame ([$ bogusOne , $ sibling , $ bogusTwo , $ item ], $ subject ->getContents ());
144
144
}
145
145
}
0 commit comments