1
|
|
|
<?php |
2
|
|
|
namespace Evheniy\HTML5CacheBundle\Tests\Command; |
3
|
|
|
|
4
|
|
|
use Evheniy\HTML5CacheBundle\Command\DumpCommand; |
5
|
|
|
use Symfony\Component\DependencyInjection\Container; |
6
|
|
|
use PHPUnit\Framework\TestCase; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class DumpCommandTest |
10
|
|
|
* |
11
|
|
|
* @package Evheniy\HTML5CacheBundle\Tests\Command |
12
|
|
|
*/ |
13
|
|
|
class DumpCommandUrlsTest extends TestCase |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var DumpCommand |
17
|
|
|
*/ |
18
|
|
|
protected $command; |
19
|
|
|
/** |
20
|
|
|
* @var \ReflectionClass |
21
|
|
|
*/ |
22
|
|
|
protected $reflectionClass; |
23
|
|
|
/** |
24
|
|
|
* @var Container |
25
|
|
|
*/ |
26
|
|
|
protected $container; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* |
30
|
|
|
*/ |
31
|
|
|
protected function setUp() |
32
|
|
|
{ |
33
|
|
|
$this->command = new DumpCommand(); |
34
|
|
|
$this->reflectionClass = new \ReflectionClass('\Evheniy\HTML5CacheBundle\Command\DumpCommand'); |
35
|
|
|
$this->container = new Container(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* |
40
|
|
|
*/ |
41
|
|
|
public function testGetJqueryUrls() |
42
|
|
|
{ |
43
|
|
|
$version = '1.11.3'; |
44
|
|
|
$this->container->setParameter('jquery', array('version' => $version)); |
45
|
|
|
$jqueryUrls = $this->getUrls('getJqueryUrls'); |
46
|
|
|
$this->assertCount(1, $jqueryUrls); |
|
|
|
|
47
|
|
|
$this->assertEquals($jqueryUrls[0], 'https://ajax.googleapis.com/ajax/libs/jquery/' . $version . '/jquery.min.js'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* |
52
|
|
|
*/ |
53
|
|
|
public function testGetTwitterBootstrapUrls() |
54
|
|
|
{ |
55
|
|
|
$version = '3.3.4'; |
56
|
|
|
$this->container->setParameter('twitter_bootstrap', array('version' => $version)); |
57
|
|
|
$twitterBootstrapUrls = $this->getUrls('getTwitterBootstrapUrls'); |
58
|
|
|
$this->assertCount(3, $twitterBootstrapUrls); |
|
|
|
|
59
|
|
|
$this->assertEquals($twitterBootstrapUrls[0], 'https://maxcdn.bootstrapcdn.com/bootstrap/' . $version . '/css/bootstrap.min.css'); |
60
|
|
|
$this->assertEquals($twitterBootstrapUrls[1], 'https://maxcdn.bootstrapcdn.com/bootstrap/' . $version . '/css/bootstrap-theme.min.css'); |
61
|
|
|
$this->assertEquals($twitterBootstrapUrls[2], 'https://maxcdn.bootstrapcdn.com/bootstrap/' . $version . '/js/bootstrap.min.js'); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* |
66
|
|
|
*/ |
67
|
|
|
public function testGetMaterializeUrls() |
68
|
|
|
{ |
69
|
|
|
$version = '0.97.0'; |
70
|
|
|
$this->container->setParameter('materialize', array('version' => $version)); |
71
|
|
|
$materializeUrls = $this->getUrls('getMaterializeUrls'); |
72
|
|
|
$this->assertCount(2, $materializeUrls); |
|
|
|
|
73
|
|
|
$this->assertEquals($materializeUrls[0], 'https://cdnjs.cloudflare.com/ajax/libs/materialize/' . $version . '/css/materialize.min.css'); |
74
|
|
|
$this->assertEquals($materializeUrls[1], 'https://cdnjs.cloudflare.com/ajax/libs/materialize/' . $version . '/js/materialize.min.js'); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @param string $method |
79
|
|
|
* |
80
|
|
|
* @return array |
81
|
|
|
*/ |
82
|
|
|
protected function getUrls($method) |
83
|
|
|
{ |
84
|
|
|
$this->command->setContainer($this->container); |
85
|
|
|
$method = $this->reflectionClass->getMethod($method); |
86
|
|
|
$method->setAccessible(true); |
87
|
|
|
$urls = $method->invoke($this->command); |
88
|
|
|
$this->assertTrue(is_array($urls)); |
89
|
|
|
$this->assertNotEmpty($urls); |
90
|
|
|
|
91
|
|
|
return $urls; |
92
|
|
|
} |
93
|
|
|
} |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: