|
9 | 9 |
|
10 | 10 | namespace Symfony\WebpackEncoreBundle\Tests\Asset; |
11 | 11 |
|
| 12 | +use PHPUnit\Framework\TestCase; |
12 | 13 | use Symfony\Component\Cache\Adapter\ArrayAdapter; |
13 | 14 | use Symfony\WebpackEncoreBundle\Asset\EntrypointLookup; |
14 | | -use PHPUnit\Framework\TestCase; |
15 | 15 |
|
16 | 16 | class EntrypointLookupTest extends TestCase |
17 | 17 | { |
@@ -45,7 +45,7 @@ class EntrypointLookupTest extends TestCase |
45 | 45 | } |
46 | 46 | EOF; |
47 | 47 |
|
48 | | - public function setUp() |
| 48 | + protected function setUp(): void |
49 | 49 | { |
50 | 50 | $filename = tempnam(sys_get_temp_dir(), 'WebpackEncoreBundle'); |
51 | 51 | file_put_contents($filename, self::$testJson); |
@@ -119,57 +119,52 @@ public function testMissingIntegrityData() |
119 | 119 | $this->assertEquals([], $this->entrypointLookup->getIntegrityData()); |
120 | 120 | } |
121 | 121 |
|
122 | | - /** |
123 | | - * @expectedException \InvalidArgumentException |
124 | | - * @expectedExceptionMessageContains There was a problem JSON decoding the |
125 | | - */ |
126 | 122 | public function testExceptionOnInvalidJson() |
127 | 123 | { |
| 124 | + $this->expectException(\InvalidArgumentException::class); |
| 125 | + $this->expectExceptionMessage('There was a problem JSON decoding the'); |
| 126 | + |
128 | 127 | $filename = tempnam(sys_get_temp_dir(), 'WebpackEncoreBundle'); |
129 | 128 | file_put_contents($filename, 'abcd'); |
130 | 129 |
|
131 | 130 | $this->entrypointLookup = new EntrypointLookup($filename); |
132 | 131 | $this->entrypointLookup->getJavaScriptFiles('an_entry'); |
133 | 132 | } |
134 | 133 |
|
135 | | - /** |
136 | | - * @expectedException \InvalidArgumentException |
137 | | - * @expectedExceptionMessageContains Could not find an "entrypoints" key in the |
138 | | - */ |
139 | 134 | public function testExceptionOnMissingEntrypointsKeyInJson() |
140 | 135 | { |
| 136 | + $this->expectException(\InvalidArgumentException::class); |
| 137 | + $this->expectExceptionMessage('Could not find an "entrypoints" key in the'); |
| 138 | + |
141 | 139 | $filename = tempnam(sys_get_temp_dir(), 'WebpackEncoreBundle'); |
142 | 140 | file_put_contents($filename, '{}'); |
143 | 141 |
|
144 | 142 | $this->entrypointLookup = new EntrypointLookup($filename); |
145 | 143 | $this->entrypointLookup->getJavaScriptFiles('an_entry'); |
146 | 144 | } |
147 | 145 |
|
148 | | - /** |
149 | | - * @expectedException \InvalidArgumentException |
150 | | - * @expectedExceptionMessage Could not find the entrypoints file |
151 | | - */ |
152 | 146 | public function testExceptionOnBadFilename() |
153 | 147 | { |
| 148 | + $this->expectException(\InvalidArgumentException::class); |
| 149 | + $this->expectExceptionMessage('Could not find the entrypoints file'); |
| 150 | + |
154 | 151 | $entrypointLookup = new EntrypointLookup('fake_file'); |
155 | 152 | $entrypointLookup->getCssFiles('anything'); |
156 | 153 | } |
157 | 154 |
|
158 | | - /** |
159 | | - * @expectedException \Symfony\WebpackEncoreBundle\Exception\EntrypointNotFoundException |
160 | | - * @expectedExceptionMessage Could not find the entry |
161 | | - */ |
162 | 155 | public function testExceptionOnMissingEntry() |
163 | 156 | { |
| 157 | + $this->expectException(\Symfony\WebpackEncoreBundle\Exception\EntrypointNotFoundException::class); |
| 158 | + $this->expectExceptionMessage('Could not find the entry'); |
| 159 | + |
164 | 160 | $this->entrypointLookup->getCssFiles('fake_entry'); |
165 | 161 | } |
166 | 162 |
|
167 | | - /** |
168 | | - * @expectedException \Symfony\WebpackEncoreBundle\Exception\EntrypointNotFoundException |
169 | | - * @expectedExceptionMessage Try "my_entry" instead |
170 | | - */ |
171 | 163 | public function testExceptionOnEntryWithExtension() |
172 | 164 | { |
| 165 | + $this->expectException(\Symfony\WebpackEncoreBundle\Exception\EntrypointNotFoundException::class); |
| 166 | + $this->expectExceptionMessage('Try "my_entry" instead'); |
| 167 | + |
173 | 168 | $this->entrypointLookup->getJavaScriptFiles('my_entry.js'); |
174 | 169 | } |
175 | 170 |
|
|
0 commit comments