Skip to content

Commit 31cb009

Browse files
author
Kai Eichinger
committed
Fix tests
1 parent 03ef46d commit 31cb009

File tree

6 files changed

+17
-14
lines changed

6 files changed

+17
-14
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"twig/twig": "^3.3.8"
3636
},
3737
"require-dev": {
38+
"dms/phpunit-arraysubset-asserts": "^0.4.0",
3839
"symfony/phpunit-bridge": "^5.4.3"
3940
},
4041
"conflict": {

tests/File/FileLoaderTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Tests\Becklyn\AssetsBundle\File;
44

55
use Becklyn\AssetsBundle\Asset\Asset;
6+
use Becklyn\AssetsBundle\Exception\AssetsException;
67
use Becklyn\AssetsBundle\File\FileLoader;
78
use Becklyn\AssetsBundle\File\FileTypeRegistry;
89
use Becklyn\AssetsBundle\File\Type\FileType;
@@ -78,11 +79,11 @@ public function dataProviderInvalid ()
7879
* @dataProvider dataProviderInvalid
7980
*
8081
* @param Asset $asset
81-
*
82-
* @expectedException \Becklyn\AssetsBundle\Exception\AssetsException
8382
*/
8483
public function testInvalid (Asset $asset) : void
8584
{
85+
$this->expectException(AssetsException::class);
86+
8687
$this->loader->loadFile($asset, FileLoader::MODE_UNTOUCHED);
8788
}
8889

tests/Html/AssetHtmlGeneratorTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ function (Asset $asset)
122122
);
123123

124124
$html = $generator->linkAssets(["@a/first.js", "@b/second.js"]);
125-
self::assertContains(\sprintf('integrity="%s-hash', Asset::HASH_ALGORITHM), $html);
125+
126+
self::assertStringContainsString(\sprintf('integrity="%s-hash', Asset::HASH_ALGORITHM), $html);
126127
}
127128

128129

@@ -144,7 +145,7 @@ function (Asset $asset)
144145
);
145146

146147
$html = $generator->linkAssets(["@a/first.css", "@b/second.css"]);
147-
self::assertContains(\sprintf('integrity="%s-hash', Asset::HASH_ALGORITHM), $html);
148+
self::assertStringContainsString(\sprintf('integrity="%s-hash', Asset::HASH_ALGORITHM), $html);
148149
}
149150

150151

tests/Storage/AssetStorageTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function testGenerate () : void
8989
$expectedOutputFilePath = "test/css/app2.zu+_RiyZqaqqHgSHa3Xv.css";
9090
$outputPath = "{$this->outDir}/assets/other/{$expectedOutputFilePath}";
9191

92-
self::assertFileNotExists($outputPath);
92+
self::assertFileDoesNotExist($outputPath);
9393
$asset = $this->storage->import(new Asset("other", "test/css/app2.css"));
9494
self::assertFileExists($outputPath);
9595

@@ -111,7 +111,7 @@ public function testGenerateWithoutHash () : void
111111
$expectedOutputFilePath = "test/js/test.js";
112112
$outputPath = "{$this->outDir}/assets/bundles/{$expectedOutputFilePath}";
113113

114-
self::assertFileNotExists($outputPath);
114+
self::assertFileDoesNotExist($outputPath);
115115
$asset = $this->storage->import(new Asset("bundles", "test/js/test.js"));
116116
self::assertFileExists($outputPath);
117117

@@ -144,6 +144,6 @@ public function testClear () : void
144144
self::assertFileExists("{$assetsDir}/test/a");
145145
self::assertDirectoryExists($assetsDir);
146146
$this->storage->removeAllStoredFiles();
147-
self::assertDirectoryNotExists($assetsDir);
147+
self::assertDirectoryDoesNotExist($assetsDir);
148148
}
149149
}

tests/Twig/AssetsTwigExtensionTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
use Becklyn\AssetsBundle\Twig\AssetsTwigExtension;
88
use PHPUnit\Framework\TestCase;
99
use Twig\TwigFunction;
10+
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
1011

1112
class AssetsTwigExtensionTest extends TestCase
1213
{
14+
use ArraySubsetAsserts;
15+
1316
/**
1417
* Assert that the exposed twig functions don't change.
1518
*/
@@ -25,14 +28,11 @@ public function testMethodNames () : void
2528

2629
$extension = new AssetsTwigExtension($htmlReferences, $helper);
2730
$functions = \array_map(
28-
function (TwigFunction $f)
29-
{
30-
return $f->getName();
31-
},
31+
static fn (TwigFunction $f) => $f->getName(),
3232
$extension->getFunctions()
3333
);
3434

35-
self::assertArraySubset([
35+
$this->assertArraySubset([
3636
"asset",
3737
"asset_inline",
3838
"assets_link",

tests/Url/AssetUrlTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@ public function testMissingFileInProdWithLogger () : void
183183
* Missing file in dev:.
184184
*
185185
* Throw exception
186-
*
187-
* @expectedException \Becklyn\AssetsBundle\Exception\AssetsException
188186
*/
189187
public function testMissingFileInDev () : void
190188
{
189+
$this->expectException(AssetsException::class);
190+
191191
/**
192192
* @var AssetUrl $assetUrl
193193
* @var \PHPUnit_Framework_MockObject_MockObject $router

0 commit comments

Comments
 (0)