1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Sylius package. |
5
|
|
|
* |
6
|
|
|
* (c) Paweł Jędrzejewski |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Sylius\Bundle\ThemeBundle\Tests\Functional; |
13
|
|
|
|
14
|
|
|
use Sylius\Bundle\ThemeBundle\Asset\Installer\AssetsInstallerInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @author Kamil Kokot <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class AssetTest extends ThemeBundleTestCase |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @dataProvider getSymlinkMasks |
23
|
|
|
* |
24
|
|
|
* @param int $symlinkMask |
25
|
|
|
*/ |
26
|
|
|
public function testAssets($symlinkMask) |
27
|
|
|
{ |
28
|
|
|
$webDirectory = $this->getTmpDirPath(self::TEST_CASE) . '/web'; |
29
|
|
|
if (!is_dir($webDirectory)) { |
30
|
|
|
mkdir($webDirectory, 0777, true); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
chdir($webDirectory); |
34
|
|
|
|
35
|
|
|
$client = $this->getClient(); |
36
|
|
|
|
37
|
|
|
$client->getContainer()->get('sylius.theme.asset.assets_installer')->installAssets($webDirectory, $symlinkMask); |
38
|
|
|
|
39
|
|
|
$crawler = $client->request('GET', '/template/:Asset:assetsTest.txt.twig'); |
40
|
|
|
$lines = explode("\n", $crawler->text()); |
41
|
|
|
foreach ($lines as $line) { |
42
|
|
|
if (empty($line)) { |
43
|
|
|
continue; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
list($expectedText, $assetFile) = explode(": ", $line); |
47
|
|
|
|
48
|
|
|
$contents = file_get_contents($webDirectory . $assetFile); |
49
|
|
|
|
50
|
|
|
$this->assertEquals($expectedText, trim($contents)); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return array |
56
|
|
|
*/ |
57
|
|
|
public function getSymlinkMasks() |
58
|
|
|
{ |
59
|
|
|
return [ |
60
|
|
|
[AssetsInstallerInterface::RELATIVE_SYMLINK], |
61
|
|
|
[AssetsInstallerInterface::SYMLINK], |
62
|
|
|
[AssetsInstallerInterface::HARD_COPY], |
63
|
|
|
]; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|