This repository has been archived by the owner on Jan 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
/
AssetTest.php
89 lines (72 loc) · 2.28 KB
/
AssetTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zendframework for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace ZendTest\View\Helper;
use PHPUnit_Framework_TestCase as TestCase;
use Zend\ServiceManager\ServiceManager;
use Zend\View\Exception;
use Zend\View\Helper\Asset;
use Zend\View\HelperPluginManager;
class AssetTest extends TestCase
{
/** @var array */
protected $resourceMap = [
'css/style.css' => 'css/style-3a97ff4ee3.css',
'js/vendor.js' => 'js/vendor-a507086eba.js',
];
/** @var Asset */
protected $asset;
protected function setUp()
{
parent::setUp();
$this->asset = new Asset();
$this->asset->setResourceMap($this->resourceMap);
}
public function testHelperPluginManagerReturnsAssetHelper()
{
$helpers = $this->getHelperPluginManager();
$asset = $helpers->get('asset');
$this->assertInstanceOf(Asset::class, $asset);
}
public function testHelperPluginManagerReturnsAssetHelperByClassName()
{
$helpers = $this->getHelperPluginManager();
$asset = $helpers->get(Asset::class);
$this->assertInstanceOf(Asset::class, $asset);
}
public function testInvalidAssetName()
{
$this->setExpectedException(Exception\InvalidArgumentException::class, 'Asset is not defined.');
$this->asset->__invoke('unknown');
}
/**
* @dataProvider assets
*
* @param string $name
* @param string $expected
*/
public function testInvokeResult($name, $expected)
{
$result = $this->asset->__invoke($name);
$this->assertEquals($expected, $result);
}
public function assets()
{
$data = [];
foreach ($this->resourceMap as $key => $value) {
$data[] = [$key, $value];
}
return $data;
}
protected function getHelperPluginManager(array $config = [])
{
$services = $this->prophesize(ServiceManager::class);
$services->get('config')->willReturn($config);
return new HelperPluginManager($services->reveal());
}
}