Skip to content

Commit c98b217

Browse files
committed
Updated dependencies and tests
1 parent 543d4cd commit c98b217

39 files changed

+324
-366
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ php-cs-fixer.phar
33
vendor
44
.idea
55
composer.lock
6+
.phpunit.result.cache

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ matrix:
3131
before_script:
3232
- travis_retry composer install $COMPOSER_ARGS --ignore-platform-reqs
3333
- if [[ "$dependencies" == "lowest" ]]; then travis_retry composer update --prefer-dist --prefer-lowest --prefer-stable $COMPOSER_ARGS; fi;
34+
- if [[ "$dependencies" == "highest" ]]; then travis_retry composer update --prefer-dist $COMPOSER_ARGS; fi;
3435
- if [[ "$dependencies" == "highest" ]]; then travis_retry composer require laminas/laminas-mvc-console:^1.1 --prefer-dist $COMPOSER_ARGS; fi;
3536

3637
script:
3738
- ./vendor/bin/phpunit
38-
- ./vendor/bin/phpcs --standard=PSR2 ./src ./tests/AssetManagerTest
39+
- if [[ "$CS_CHECK" == "true" ]]; then ./vendor/bin/phpcs --standard=PSR2 ./src ./tests/AssetManagerTest; fi;

composer.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
}
2323
],
2424
"require": {
25-
"php": "^7.3",
25+
"php": "^7.3 || ^8.0",
2626
"laminas/laminas-modulemanager": "^2.7.2",
27-
"laminas/laminas-stdlib": "^2.7.7 || ^3.0.1",
27+
"laminas/laminas-stdlib": "^3.2.1",
2828
"laminas/laminas-servicemanager": "^2.7.6 || ^3.1.1",
2929
"laminas/laminas-loader": "^2.5.1",
3030
"laminas/laminas-eventmanager": "^2.6.3 || ^3.0.1",
@@ -37,8 +37,8 @@
3737
"laminas/laminas-view": "^2.8.1",
3838
"laminas/laminas-cache": "^2.7.1",
3939
"laminas/laminas-console": "^2.6",
40-
"squizlabs/php_codesniffer": "~1.5.0",
41-
"phpunit/phpunit": "^7.0"
40+
"squizlabs/php_codesniffer": "^3.5.6",
41+
"phpunit/phpunit": "^8.5.8 || ^9.1"
4242
},
4343
"suggest": {
4444
"laminas/laminas-mvc-console": "laminas-mvc-console provides the ability to expose laminas-mvc as a console application"

phpunit.xml.dist

+13-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
<?xml version="1.0"?>
2-
<!-- works fine with PHPUnit-3.6.10 -->
3-
<phpunit
4-
bootstrap="./tests/Bootstrap.php"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
verbose="true"
10-
stopOnFailure="false"
11-
processIsolation="false"
12-
backupGlobals="false"
13-
syntaxCheck="true"
14-
>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="./tests/Bootstrap.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
verbose="true"
10+
stopOnFailure="false"
11+
processIsolation="false"
12+
backupGlobals="false"
13+
>
1514
<testsuite name="AssetManager tests">
1615
<directory>./tests/AssetManagerTest</directory>
1716
</testsuite>

src/AssetManager/Controller/ConsoleController.php

-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ protected function purgeCache($verbose = false)
101101
}
102102

103103
foreach ($this->appConfig['asset_manager']['caching'] as $configName => $config) {
104-
105104
if (empty($config['options']['dir'])) {
106105
continue;
107106
}

src/AssetManager/Resolver/AliasPathStackResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class AliasPathStackResolver implements ResolverInterface, MimeResolverAwareInterface
1717
{
1818
/**
19-
* @var Array
19+
* @var array
2020
*/
2121
protected $aliases = array();
2222

src/AssetManager/Resolver/CollectionResolver.php

-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ public function resolve($name)
122122
$collection->setTargetPath($name);
123123

124124
foreach ($this->collections[$name] as $asset) {
125-
126125
if (!is_string($asset)) {
127126
throw new Exception\RuntimeException(
128127
'Asset should be of type string. got ' . gettype($asset)

src/AssetManager/Resolver/ConcatResolver.php

-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ public function resolve($name)
128128
$resolvedAssets = array();
129129

130130
foreach ((array) $this->concats[$name] as $assetName) {
131-
132131
$resolvedAsset = $this->getAggregateResolver()->resolve((string) $assetName);
133132

134133
if (!$resolvedAsset instanceof AssetInterface) {

src/AssetManager/Resolver/PathStackResolver.php

-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ public function resolve($name)
176176
}
177177

178178
foreach ($this->getPaths() as $path) {
179-
180179
$file = new SplFileInfo($path . $name);
181180

182181
if ($file->isReadable() && !$file->isDir()) {

src/AssetManager/Service/AggregateResolverServiceFactory.php

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o
3333
}
3434

3535
foreach ($config['resolvers'] as $resolverService => $priority) {
36-
3736
$resolverService = $container->get($resolverService);
3837

3938
if (!$resolverService instanceof ResolverInterface) {

src/AssetManager/View/Helper/Asset.php

-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ private function elaborateFilePath($filename, $queryString)
5757
{
5858
$asset = $this->assetManagerResolver->resolve($filename);
5959
if ($asset !== null) {
60-
6160
// append last modified date to the filepath and use a custom query string
6261
return $this->appendTimestamp($filename, $queryString, $asset->getLastModified());
6362
}
@@ -121,7 +120,6 @@ public function __invoke($filename)
121120

122121
// no cache dir is defined
123122
if (!isset($cacheConfig['options']['dir'])) {
124-
125123
// append current timestamp to the filepath and use a custom query string
126124
return $this->appendTimestamp($filename, $queryString);
127125
}

tests/AssetManagerTest/Cache/FilePathCacheTest.php

+30-37
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,30 @@
88

99
class FilePathCacheTest extends TestCase
1010
{
11-
public function testConstruct()
11+
public function testConstruct(): void
1212
{
1313
$cache = new FilePathCache('/imagination', 'bacon.porn');
1414
$this->assertTrue($cache instanceof CacheInterface);
1515

16-
$this->assertAttributeEquals(
16+
$refClass = new \ReflectionClass(FilePathCache::class);
17+
$dirProp = $refClass->getProperty('dir');
18+
$dirProp->setAccessible(true);
19+
20+
$filenameProp = $refClass->getProperty('filename');
21+
$filenameProp->setAccessible(true);
22+
23+
$this->assertSame(
1724
'/imagination',
18-
'dir',
19-
$cache
25+
$dirProp->getValue($cache)
2026
);
2127

22-
$this->assertAttributeEquals(
28+
$this->assertSame(
2329
'bacon.porn',
24-
'filename',
25-
$cache
30+
$filenameProp->getValue($cache)
2631
);
2732
}
2833

29-
public function testHas()
34+
public function testHas(): void
3035
{
3136
// Check fail
3237
$cache = new FilePathCache('/imagination', 'bacon.porn');
@@ -37,31 +42,26 @@ public function testHas()
3742
$this->assertTrue($cache->has('bacon'));
3843
}
3944

40-
/**
41-
* @expectedException \RunTimeException
42-
*
43-
*/
44-
public function testGetException()
45+
public function testGetException(): void
4546
{
47+
$this->expectException(\RuntimeException::class);
4648
$cache = new FilePathCache('/imagination', 'bacon.porn');
4749
$cache->get('bacon');
4850
}
4951

50-
public function testGet()
52+
public function testGet(): void
5153
{
5254
$cache = new FilePathCache('', __FILE__);
5355
$this->assertEquals(file_get_contents(__FILE__), $cache->get('bacon'));
5456
}
5557

56-
/**
57-
* @expectedException \RuntimeException
58-
*/
59-
public function testSetMayNotWriteFile()
58+
public function testSetMayNotWriteFile(): void
6059
{
60+
$this->expectException(\RuntimeException::class);
6161
restore_error_handler(); // Previous test fails, so doesn't unset.
6262
$time = time();
6363
$sentence = 'I am, what I am. Cached data, please don\'t hate, '
64-
. 'for we are all equals. Except you, you\'re a dick.';
64+
. 'for we are all equals. Except you, you\'re a dick.';
6565
$base = '/tmp/_cachetest.' . $time . '/';
6666
mkdir($base, 0777);
6767
mkdir($base.'readonly', 0400, true);
@@ -70,33 +70,28 @@ public function testSetMayNotWriteFile()
7070
$cache->set('bacon', $sentence);
7171
}
7272

73-
/**
74-
* @expectedException \RuntimeException
75-
*/
76-
public function testSetMayNotWriteDir()
73+
public function testSetMayNotWriteDir(): void
7774
{
75+
$this->expectException(\RuntimeException::class);
7876
restore_error_handler(); // Previous test fails, so doesn't unset.
7977
$time = time()+1;
8078
$sentence = 'I am, what I am. Cached data, please don\'t hate, '
81-
. 'for we are all equals. Except you, you\'re a dick.';
79+
. 'for we are all equals. Except you, you\'re a dick.';
8280
$base = '/tmp/_cachetest.' . $time . '/';
8381
mkdir($base, 0400, true);
8482

8583
$cache = new FilePathCache($base.'readonly', 'bacon.'.$time.'.hammertime');
8684

8785
$cache->set('bacon', $sentence);
88-
8986
}
9087

91-
/**
92-
* @expectedException \RuntimeException
93-
*/
94-
public function testSetCanNotWriteToFileThatExists()
88+
public function testSetCanNotWriteToFileThatExists(): void
9589
{
90+
$this->expectException(\RuntimeException::class);
9691
restore_error_handler(); // Previous test fails, so doesn't unset.
9792
$time = time()+333;
9893
$sentence = 'I am, what I am. Cached data, please don\'t hate, '
99-
. 'for we are all equals. Except you, you\'re a dick.';
94+
. 'for we are all equals. Except you, you\'re a dick.';
10095
$base = '/tmp/_cachetest.' . $time . '/';
10196
mkdir($base, 0777);
10297

@@ -110,7 +105,7 @@ public function testSetCanNotWriteToFileThatExists()
110105
$cache->set('bacon', $sentence);
111106
}
112107

113-
public function testSetSuccess()
108+
public function testSetSuccess(): void
114109
{
115110
$time = time();
116111
$sentence = 'I am, what I am. Cached data, please don\'t hate, '
@@ -122,17 +117,15 @@ public function testSetSuccess()
122117
$this->assertEquals($sentence, file_get_contents($base.'bacon.'.$time));
123118
}
124119

125-
/**
126-
* @expectedException \RuntimeException
127-
*/
128-
public function testRemoveFails()
120+
public function testRemoveFails(): void
129121
{
122+
$this->expectException(\RuntimeException::class);
130123
$cache = new FilePathCache('/dev', 'null');
131124

132125
$cache->remove('bacon');
133126
}
134127

135-
public function testRemoveSuccess()
128+
public function testRemoveSuccess(): void
136129
{
137130
$time = time();
138131
$sentence = 'I am, what I am. Cached data, please don\'t hate, '
@@ -145,7 +138,7 @@ public function testRemoveSuccess()
145138
$this->assertTrue($cache->remove('bacon'));
146139
}
147140

148-
public function testCachedFile()
141+
public function testCachedFile(): void
149142
{
150143
$method = new \ReflectionMethod(FilePathCache::class, 'cachedFile');
151144

tests/AssetManagerTest/Cache/LaminasCacheAdapterTest.php

+7-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
class LaminasCacheAdapterTest extends \PHPUnit\Framework\TestCase
1414
{
15-
public function testConstructor()
15+
public function testConstructor(): void
1616
{
1717
$mockLaminasCache = $this->getMockBuilder(Memory::class)
1818
->disableOriginalConstructor()
@@ -23,19 +23,17 @@ public function testConstructor()
2323
$this->assertInstanceOf(LaminasCacheAdapter::class, $adapter);
2424
}
2525

26-
/**
27-
* @expectedException \PHPUnit\Framework\Error\Error
28-
*/
29-
public function testConstructorOnlyAcceptsALaminasCacheStorageInterface()
26+
public function testConstructorOnlyAcceptsALaminasCacheStorageInterface(): void
3027
{
28+
$this->expectError();
3129
if (PHP_MAJOR_VERSION >= 7) {
3230
$this->expectException('\TypeError');
3331
}
3432

3533
new LaminasCacheAdapter(new \DateTime());
3634
}
3735

38-
public function testHasMethodCallsLaminasCacheHasItem()
36+
public function testHasMethodCallsLaminasCacheHasItem(): void
3937
{
4038
$mockLaminasCache = $this->getMockBuilder(Memory::class)
4139
->disableOriginalConstructor()
@@ -48,7 +46,7 @@ public function testHasMethodCallsLaminasCacheHasItem()
4846
$adapter->has('SomeKey');
4947
}
5048

51-
public function testGetMethodCallsLaminasCacheGetItem()
49+
public function testGetMethodCallsLaminasCacheGetItem(): void
5250
{
5351
$mockLaminasCache = $this->getMockBuilder(Memory::class)
5452
->disableOriginalConstructor()
@@ -61,7 +59,7 @@ public function testGetMethodCallsLaminasCacheGetItem()
6159
$adapter->get('SomeKey');
6260
}
6361

64-
public function testSetMethodCallsLaminasCacheSetItem()
62+
public function testSetMethodCallsLaminasCacheSetItem(): void
6563
{
6664
$mockLaminasCache = $this->getMockBuilder(Memory::class)
6765
->disableOriginalConstructor()
@@ -74,7 +72,7 @@ public function testSetMethodCallsLaminasCacheSetItem()
7472
$adapter->set('SomeKey', array());
7573
}
7674

77-
public function testRemoveMethodCallsLaminasCacheRemoveItem()
75+
public function testRemoveMethodCallsLaminasCacheRemoveItem(): void
7876
{
7977
$mockLaminasCache = $this->getMockBuilder(Memory::class)
8078
->disableOriginalConstructor()

0 commit comments

Comments
 (0)