Skip to content

Commit d3a6ca4

Browse files
committed
Made tests compatible with PHPUnit 5.6 without warning
1 parent 4323603 commit d3a6ca4

20 files changed

+108
-102
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"mrclay/minify": "<2.3",
2727
"natxet/cssmin": "3.0.4",
2828
"patchwork/jsqueeze": "~1.0|~2.0",
29-
"phpunit/phpunit": "~4.8",
29+
"phpunit/phpunit": "~4.8 || ^5.6",
3030
"psr/log": "~1.0",
3131
"ptachoire/cssembed": "~1.0",
3232
"symfony/phpunit-bridge": "~2.7|~3.0",

tests/Assetic/Test/Asset/AssetCacheTest.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ class AssetCacheTest extends \PHPUnit_Framework_TestCase
1717
{
1818
private $inner;
1919
private $cache;
20+
/** @var AssetCache */
2021
private $asset;
2122

2223
protected function setUp()
2324
{
24-
$this->inner = $this->getMock('Assetic\\Asset\\AssetInterface');
25-
$this->cache = $this->getMock('Assetic\\Cache\\CacheInterface');
25+
$this->inner = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock();
26+
$this->cache = $this->getMockBuilder('Assetic\\Cache\\CacheInterface')->getMock();
2627

2728
$this->asset = new AssetCache($this->inner, $this->cache);
2829
}
@@ -37,7 +38,7 @@ protected function tearDown()
3738
public function testLoadFromCache()
3839
{
3940
$content = 'asdf';
40-
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
41+
$filter = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock();
4142

4243
$this->inner->expects($this->once())
4344
->method('getFilters')
@@ -121,7 +122,7 @@ public function testDumpToCache()
121122

122123
public function testEnsureFilter()
123124
{
124-
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
125+
$filter = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock();
125126
$this->inner->expects($this->once())->method('ensureFilter');
126127
$this->asset->ensureFilter($filter);
127128
}

tests/Assetic/Test/Asset/AssetCollectionTest.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testInterface()
2626

2727
public function testLoadFilter()
2828
{
29-
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
29+
$filter = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock();
3030
$filter->expects($this->once())->method('filterLoad');
3131

3232
$coll = new AssetCollection(array(new StringAsset('')), array($filter));
@@ -35,7 +35,7 @@ public function testLoadFilter()
3535

3636
public function testDumpFilter()
3737
{
38-
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
38+
$filter = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock();
3939
$filter->expects($this->once())->method('filterDump');
4040

4141
$coll = new AssetCollection(array(new StringAsset('')), array($filter));
@@ -154,7 +154,7 @@ public function testGetLastModified($timestamps, $expected)
154154
$assets = array();
155155

156156
for ($i = 0; $i < count($timestamps); $i++) {
157-
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
157+
$asset = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock();
158158
$asset->expects($this->once())
159159
->method('getLastModified')
160160
->will($this->returnValue($timestamps[$i]));
@@ -192,10 +192,10 @@ public function getTimestampsAndExpected()
192192

193193
public function testRecursiveIteration()
194194
{
195-
$asset1 = $this->getMock('Assetic\\Asset\\AssetInterface');
196-
$asset2 = $this->getMock('Assetic\\Asset\\AssetInterface');
197-
$asset3 = $this->getMock('Assetic\\Asset\\AssetInterface');
198-
$asset4 = $this->getMock('Assetic\\Asset\\AssetInterface');
195+
$asset1 = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock();
196+
$asset2 = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock();
197+
$asset3 = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock();
198+
$asset4 = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock();
199199

200200
$coll3 = new AssetCollection(array($asset1, $asset2));
201201
$coll2 = new AssetCollection(array($asset3, $coll3));
@@ -211,7 +211,7 @@ public function testRecursiveIteration()
211211

212212
public function testRecursiveDeduplication()
213213
{
214-
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
214+
$asset = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock();
215215

216216
$coll3 = new AssetCollection(array($asset, $asset));
217217
$coll2 = new AssetCollection(array($asset, $coll3));

tests/Assetic/Test/Asset/AssetReferenceTest.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class AssetReferenceTest extends \PHPUnit_Framework_TestCase
2121

2222
protected function setUp()
2323
{
24-
$this->am = $this->getMock('Assetic\\AssetManager');
24+
$this->am = $this->getMockBuilder('Assetic\\AssetManager')->getMock();
2525
$this->ref = new AssetReference($this->am, 'foo');
2626
}
2727

@@ -36,7 +36,7 @@ protected function tearDown()
3636
*/
3737
public function testMethods($method, $returnValue)
3838
{
39-
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
39+
$asset = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock();
4040

4141
$this->am->expects($this->once())
4242
->method('get')
@@ -63,12 +63,12 @@ public function getMethodAndRetVal()
6363
public function testLazyFilters()
6464
{
6565
$this->am->expects($this->never())->method('get');
66-
$this->ref->ensureFilter($this->getMock('Assetic\\Filter\\FilterInterface'));
66+
$this->ref->ensureFilter($this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock());
6767
}
6868

6969
public function testFilterFlush()
7070
{
71-
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
71+
$asset = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock();
7272

7373
$this->am->expects($this->exactly(2))
7474
->method('get')
@@ -79,14 +79,14 @@ public function testFilterFlush()
7979
->method('getFilters')
8080
->will($this->returnValue(array()));
8181

82-
$this->ref->ensureFilter($this->getMock('Assetic\\Filter\\FilterInterface'));
82+
$this->ref->ensureFilter($this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock());
8383

8484
$this->assertInternalType('array', $this->ref->getFilters(), '->getFilters() flushes and returns filters');
8585
}
8686

8787
public function testSetContent()
8888
{
89-
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
89+
$asset = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock();
9090

9191
$this->am->expects($this->once())
9292
->method('get')
@@ -101,8 +101,8 @@ public function testSetContent()
101101

102102
public function testLoad()
103103
{
104-
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
105-
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
104+
$filter = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock();
105+
$asset = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock();
106106

107107
$this->am->expects($this->exactly(2))
108108
->method('get')
@@ -117,8 +117,8 @@ public function testLoad()
117117

118118
public function testDump()
119119
{
120-
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
121-
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
120+
$filter = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock();
121+
$asset = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock();
122122

123123
$this->am->expects($this->exactly(2))
124124
->method('get')
@@ -133,9 +133,9 @@ public function testDump()
133133

134134
public function testClone()
135135
{
136-
$filter1 = $this->getMock('Assetic\\Filter\\FilterInterface');
137-
$filter2 = $this->getMock('Assetic\\Filter\\FilterInterface');
138-
$filter3 = $this->getMock('Assetic\\Filter\\FilterInterface');
136+
$filter1 = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock();
137+
$filter2 = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock();
138+
$filter3 = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock();
139139

140140
$asset = new StringAsset('');
141141
$this->am->expects($this->any())

tests/Assetic/Test/Asset/StringAssetTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function testInterface()
2323

2424
public function testLoadAppliesFilters()
2525
{
26-
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
26+
$filter = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock();
2727
$filter->expects($this->once())->method('filterLoad');
2828

2929
$asset = new StringAsset('foo', array($filter));
@@ -32,7 +32,7 @@ public function testLoadAppliesFilters()
3232

3333
public function testAutomaticLoad()
3434
{
35-
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
35+
$filter = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock();
3636
$filter->expects($this->once())->method('filterLoad');
3737

3838
$asset = new StringAsset('foo', array($filter));
@@ -50,7 +50,7 @@ public function testLoadAppliesAdditionalFilter()
5050
$asset = new StringAsset('');
5151
$asset->load();
5252

53-
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
53+
$filter = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock();
5454
$filter->expects($this->once())
5555
->method('filterLoad')
5656
->with($asset);
@@ -62,7 +62,7 @@ public function testDumpAppliesAdditionalFilter()
6262
{
6363
$asset = new StringAsset('');
6464

65-
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
65+
$filter = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock();
6666
$filter->expects($this->once())
6767
->method('filterDump')
6868
->with($asset);

tests/Assetic/Test/AssetManagerTest.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
class AssetManagerTest extends \PHPUnit_Framework_TestCase
1717
{
18+
/** @var AssetManager */
1819
private $am;
1920

2021
protected function setUp()
@@ -24,7 +25,7 @@ protected function setUp()
2425

2526
public function testGetAsset()
2627
{
27-
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
28+
$asset = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock();
2829
$this->am->set('foo', $asset);
2930
$this->assertSame($asset, $this->am->get('foo'), '->get() returns an asset');
3031
}
@@ -37,7 +38,7 @@ public function testGetInvalidAsset()
3738

3839
public function testHas()
3940
{
40-
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
41+
$asset = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock();
4142
$this->am->set('foo', $asset);
4243

4344
$this->assertTrue($this->am->has('foo'), '->has() returns true if the asset is set');
@@ -48,12 +49,12 @@ public function testInvalidName()
4849
{
4950
$this->setExpectedException('InvalidArgumentException');
5051

51-
$this->am->set('@foo', $this->getMock('Assetic\\Asset\\AssetInterface'));
52+
$this->am->set('@foo', $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock());
5253
}
5354

5455
public function testClear()
5556
{
56-
$this->am->set('foo', $this->getMock('Assetic\Asset\AssetInterface'));
57+
$this->am->set('foo', $this->getMockBuilder('Assetic\Asset\AssetInterface')->getMock());
5758
$this->am->clear();
5859

5960
$this->assertFalse($this->am->has('foo'));

tests/Assetic/Test/AssetWriterTest.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
namespace Assetic\Test;
1313

1414
use Assetic\Asset\FileAsset;
15-
use Assetic\AssetManager;
1615
use Assetic\AssetWriter;
1716

1817
class AssetWriterTest extends \PHPUnit_Framework_TestCase
1918
{
19+
private $dir;
20+
/** @var AssetWriter */
21+
private $writer;
22+
2023
protected function setUp()
2124
{
2225
$this->dir = sys_get_temp_dir().'/assetic_tests_'.rand(11111, 99999);
@@ -36,8 +39,8 @@ protected function tearDown()
3639

3740
public function testWriteManagerAssets()
3841
{
39-
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
40-
$am = $this->getMock('Assetic\\AssetManager');
42+
$asset = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock();
43+
$am = $this->getMockBuilder('Assetic\\AssetManager')->getMock();
4144

4245
$am->expects($this->once())
4346
->method('getNames')
@@ -67,7 +70,7 @@ public function testWriteManagerAssets()
6770

6871
public function testWriteAssetWithVars()
6972
{
70-
$asset = $this->getMock('Assetic\Asset\AssetInterface');
73+
$asset = $this->getMockBuilder('Assetic\Asset\AssetInterface')->getMock();
7174
$asset->expects($this->atLeastOnce())
7275
->method('getVars')
7376
->will($this->returnValue(array('locale')));

tests/Assetic/Test/Cache/ExpiringCacheTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ExpiringCacheTest extends \PHPUnit_Framework_TestCase
2121

2222
protected function setUp()
2323
{
24-
$this->inner = $this->getMock('Assetic\\Cache\\CacheInterface');
24+
$this->inner = $this->getMockBuilder('Assetic\\Cache\\CacheInterface')->getMock();
2525
$this->lifetime = 3600;
2626
$this->cache = new ExpiringCache($this->inner, $this->lifetime);
2727
}

tests/Assetic/Test/Extension/Twig/AsseticExtensionTest.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ protected function setUp()
4949
$this->markTestSkipped('Twig is not installed.');
5050
}
5151

52-
$this->am = $this->getMock('Assetic\\AssetManager');
53-
$this->fm = $this->getMock('Assetic\\FilterManager');
52+
$this->am = $this->getMockBuilder('Assetic\\AssetManager')->getMock();
53+
$this->fm = $this->getMockBuilder('Assetic\\FilterManager')->getMock();
5454

55-
$this->valueSupplier = $this->getMock('Assetic\ValueSupplierInterface');
55+
$this->valueSupplier = $this->getMockBuilder('Assetic\ValueSupplierInterface')->getMock();
5656

5757
$this->factory = new AssetFactory(__DIR__.'/templates');
5858
$this->factory->setAssetManager($this->am);
@@ -73,7 +73,7 @@ protected function tearDown()
7373

7474
public function testReference()
7575
{
76-
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
76+
$asset = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock();
7777
$this->am->expects($this->any())
7878
->method('get')
7979
->with('foo')
@@ -100,7 +100,7 @@ public function testAbsolutePath()
100100

101101
public function testFilters()
102102
{
103-
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
103+
$filter = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock();
104104

105105
$this->fm->expects($this->at(0))
106106
->method('get')
@@ -118,7 +118,7 @@ public function testFilters()
118118

119119
public function testOptionalFilter()
120120
{
121-
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
121+
$filter = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock();
122122

123123
$this->fm->expects($this->once())
124124
->method('get')
@@ -147,7 +147,7 @@ public function testOutput()
147147

148148
public function testMixture()
149149
{
150-
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
150+
$asset = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock();
151151
$this->am->expects($this->any())
152152
->method('get')
153153
->with('foo')
@@ -160,7 +160,7 @@ public function testMixture()
160160

161161
public function testDebug()
162162
{
163-
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
163+
$filter = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock();
164164

165165
$this->fm->expects($this->once())
166166
->method('get')
@@ -175,7 +175,7 @@ public function testDebug()
175175

176176
public function testCombine()
177177
{
178-
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
178+
$filter = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock();
179179

180180
$this->fm->expects($this->once())
181181
->method('get')
@@ -196,7 +196,7 @@ public function testImage()
196196

197197
public function testFilterFunction()
198198
{
199-
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
199+
$filter = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock();
200200

201201
$this->fm->expects($this->once())
202202
->method('get')

0 commit comments

Comments
 (0)