diff --git a/.gitignore b/.gitignore
index 87904ecb..46466ef9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+/.phpunit.result.cache
/clover.xml
/composer.lock
/coveralls-upload.json
diff --git a/.travis.yml b/.travis.yml
index f8bf4477..3bdcc7d6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,42 +12,25 @@ env:
matrix:
fast_finish: true
include:
- - php: 5.6
- env:
- - DEPS=lowest
- - php: 5.6
- env:
- - DEPS=latest
- - php: 7
- env:
- - DEPS=lowest
- - php: 7
- env:
- - DEPS=latest
- - php: 7.1
+ - php: 7.3
env:
- DEPS=lowest
- - php: 7.1
+ - php: 7.3
env:
- DEPS=latest
- CS_CHECK=true
- BENCHMARKS=true
- TEST_COVERAGE=true
- - php: 7.2
+ - php: 7.4
env:
- DEPS=lowest
- - php: 7.2
+ - php: 7.4
env:
- DEPS=latest
- - php: 7.3
+ - php: nightly
env:
- DEPS=lowest
- - php: 7.3
- env:
- - DEPS=latest
- - php: 7.4
- env:
- - DEPS=latest
+ - COMPOSER_ARGS="--no-interaction --ignore-platform-reqs"
- php: nightly
env:
- DEPS=latest
@@ -60,7 +43,6 @@ before_install:
install:
- travis_retry composer install $COMPOSER_ARGS --ignore-platform-reqs
- - if [[ $LEGACY_DEPS != '' ]]; then travis_retry composer update $COMPOSER_ARGS --with-dependencies $LEGACY_DEPS ; fi
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2b7ada25..1b169ff0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,7 +18,7 @@ All notable changes to this project will be documented in this file, in reverse
### Removed
-- Nothing.
+- [#10](https://github.com/laminas/laminas-stdlib/pull/10) removes support for PHP versions prior to PHP 7.3.
### Fixed
diff --git a/composer.json b/composer.json
index a265936d..58c03a16 100644
--- a/composer.json
+++ b/composer.json
@@ -25,13 +25,13 @@
}
},
"require": {
- "php": "^5.6 || ^7.0 || ^8.0",
+ "php": "^7.3 || ^8.0",
"laminas/laminas-zendframework-bridge": "^1.0"
},
"require-dev": {
"laminas/laminas-coding-standard": "~1.0.0",
"phpbench/phpbench": "^0.13",
- "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.2"
+ "phpunit/phpunit": "^9.3.7"
},
"autoload": {
"psr-4": {
diff --git a/test/ArrayObjectTest.php b/test/ArrayObjectTest.php
index de33ec53..4ddfe87b 100644
--- a/test/ArrayObjectTest.php
+++ b/test/ArrayObjectTest.php
@@ -18,23 +18,23 @@ class ArrayObjectTest extends TestCase
public function testConstructorDefaults()
{
$ar = new ArrayObject();
- $this->assertEquals(ArrayObject::STD_PROP_LIST, $ar->getFlags());
- $this->assertEquals('ArrayIterator', $ar->getIteratorClass());
- $this->assertInstanceOf('ArrayIterator', $ar->getIterator());
- $this->assertSame([], $ar->getArrayCopy());
- $this->assertEquals(0, $ar->count());
+ self::assertEquals(ArrayObject::STD_PROP_LIST, $ar->getFlags());
+ self::assertEquals('ArrayIterator', $ar->getIteratorClass());
+ self::assertInstanceOf('ArrayIterator', $ar->getIterator());
+ self::assertSame([], $ar->getArrayCopy());
+ self::assertEquals(0, $ar->count());
}
public function testConstructorParameters()
{
$ar = new ArrayObject(['foo' => 'bar'], ArrayObject::ARRAY_AS_PROPS, 'RecursiveArrayIterator');
- $this->assertEquals(ArrayObject::ARRAY_AS_PROPS, $ar->getFlags());
- $this->assertEquals('RecursiveArrayIterator', $ar->getIteratorClass());
- $this->assertInstanceOf('RecursiveArrayIterator', $ar->getIterator());
- $this->assertSame(['foo' => 'bar'], $ar->getArrayCopy());
- $this->assertEquals(1, $ar->count());
- $this->assertSame('bar', $ar->foo);
- $this->assertSame('bar', $ar['foo']);
+ self::assertEquals(ArrayObject::ARRAY_AS_PROPS, $ar->getFlags());
+ self::assertEquals('RecursiveArrayIterator', $ar->getIteratorClass());
+ self::assertInstanceOf('RecursiveArrayIterator', $ar->getIterator());
+ self::assertSame(['foo' => 'bar'], $ar->getArrayCopy());
+ self::assertEquals(1, $ar->count());
+ self::assertSame('bar', $ar->foo);
+ self::assertSame('bar', $ar['foo']);
}
public function testStdPropList()
@@ -42,12 +42,12 @@ public function testStdPropList()
$ar = new ArrayObject();
$ar->foo = 'bar';
$ar->bar = 'baz';
- $this->assertSame('bar', $ar->foo);
- $this->assertSame('baz', $ar->bar);
- $this->assertFalse(isset($ar['foo']));
- $this->assertFalse(isset($ar['bar']));
- $this->assertEquals(0, $ar->count());
- $this->assertSame([], $ar->getArrayCopy());
+ self::assertSame('bar', $ar->foo);
+ self::assertSame('baz', $ar->bar);
+ self::assertFalse(isset($ar['foo']));
+ self::assertFalse(isset($ar['bar']));
+ self::assertEquals(0, $ar->count());
+ self::assertSame([], $ar->getArrayCopy());
}
public function testStdPropListCannotAccessObjectVars()
@@ -63,9 +63,9 @@ public function testStdPropListStillHandlesArrays()
$ar->foo = 'bar';
$ar['foo'] = 'baz';
- $this->assertSame('bar', $ar->foo);
- $this->assertSame('baz', $ar['foo']);
- $this->assertEquals(1, $ar->count());
+ self::assertSame('bar', $ar->foo);
+ self::assertSame('baz', $ar['foo']);
+ self::assertEquals(1, $ar->count());
}
public function testArrayAsProps()
@@ -76,21 +76,21 @@ public function testArrayAsProps()
$ar->bar = 'foo';
$ar['baz'] = 'bar';
- $this->assertSame('baz', $ar->foo);
- $this->assertSame('baz', $ar['foo']);
- $this->assertSame($ar->foo, $ar['foo']);
- $this->assertEquals(3, $ar->count());
+ self::assertSame('baz', $ar->foo);
+ self::assertSame('baz', $ar['foo']);
+ self::assertSame($ar->foo, $ar['foo']);
+ self::assertEquals(3, $ar->count());
}
public function testAppend()
{
$ar = new ArrayObject(['one', 'two']);
- $this->assertEquals(2, $ar->count());
+ self::assertEquals(2, $ar->count());
$ar->append('three');
- $this->assertSame('three', $ar[2]);
- $this->assertEquals(3, $ar->count());
+ self::assertSame('three', $ar[2]);
+ self::assertEquals(3, $ar->count());
}
public function testAsort()
@@ -99,34 +99,21 @@ public function testAsort()
$sorted = $ar->getArrayCopy();
asort($sorted);
$ar->asort();
- $this->assertSame($sorted, $ar->getArrayCopy());
- }
-
- /**
- * PHPUnit 5.7 does not namespace error classes; retrieve appropriate one
- * based on what is available.
- *
- * @return string
- */
- protected function getExpectedWarningClass()
- {
- return class_exists(Warning::class) ? Warning::class : \PHPUnit_Framework_Error_Warning::class;
+ self::assertSame($sorted, $ar->getArrayCopy());
}
public function testCount()
{
- if (PHP_VERSION_ID >= 70200) {
- $this->expectException($this->getExpectedWarningClass());
- $this->expectExceptionMessage('Parameter must be an array or an object that implements Countable');
- }
+ $this->expectWarning();
+ $this->expectExceptionMessage('Parameter must be an array or an object that implements Countable');
$ar = new ArrayObject(new TestAsset\ArrayObjectObjectVars());
- $this->assertCount(1, $ar);
+ self::assertCount(1, $ar);
}
public function testCountable()
{
$ar = new ArrayObject(new TestAsset\ArrayObjectObjectCount());
- $this->assertCount(42, $ar);
+ self::assertCount(42, $ar);
}
public function testExchangeArray()
@@ -134,8 +121,8 @@ public function testExchangeArray()
$ar = new ArrayObject(['foo' => 'bar']);
$old = $ar->exchangeArray(['bar' => 'baz']);
- $this->assertSame(['foo' => 'bar'], $old);
- $this->assertSame(['bar' => 'baz'], $ar->getArrayCopy());
+ self::assertSame(['foo' => 'bar'], $old);
+ self::assertSame(['bar' => 'baz'], $ar->getArrayCopy());
}
public function testExchangeArrayPhpArrayObject()
@@ -143,8 +130,8 @@ public function testExchangeArrayPhpArrayObject()
$ar = new ArrayObject(['foo' => 'bar']);
$old = $ar->exchangeArray(new \ArrayObject(['bar' => 'baz']));
- $this->assertSame(['foo' => 'bar'], $old);
- $this->assertSame(['bar' => 'baz'], $ar->getArrayCopy());
+ self::assertSame(['foo' => 'bar'], $old);
+ self::assertSame(['bar' => 'baz'], $ar->getArrayCopy());
}
public function testExchangeArrayStdlibArrayObject()
@@ -152,8 +139,8 @@ public function testExchangeArrayStdlibArrayObject()
$ar = new ArrayObject(['foo' => 'bar']);
$old = $ar->exchangeArray(new ArrayObject(['bar' => 'baz']));
- $this->assertSame(['foo' => 'bar'], $old);
- $this->assertSame(['bar' => 'baz'], $ar->getArrayCopy());
+ self::assertSame(['foo' => 'bar'], $old);
+ self::assertSame(['bar' => 'baz'], $ar->getArrayCopy());
}
public function testExchangeArrayTestAssetIterator()
@@ -165,7 +152,7 @@ public function testExchangeArrayTestAssetIterator()
$ar2 = new \ArrayObject();
$ar2->exchangeArray(new TestAsset\ArrayObjectIterator(['foo' => 'bar']));
- $this->assertEquals($ar2->getArrayCopy(), $ar->getArrayCopy());
+ self::assertEquals($ar2->getArrayCopy(), $ar->getArrayCopy());
}
public function testExchangeArrayArrayIterator()
@@ -173,7 +160,7 @@ public function testExchangeArrayArrayIterator()
$ar = new ArrayObject();
$ar->exchangeArray(new \ArrayIterator(['foo' => 'bar']));
- $this->assertEquals(['foo' => 'bar'], $ar->getArrayCopy());
+ self::assertEquals(['foo' => 'bar'], $ar->getArrayCopy());
}
public function testExchangeArrayStringArgumentFail()
@@ -186,20 +173,20 @@ public function testExchangeArrayStringArgumentFail()
public function testGetArrayCopy()
{
$ar = new ArrayObject(['foo' => 'bar']);
- $this->assertSame(['foo' => 'bar'], $ar->getArrayCopy());
+ self::assertSame(['foo' => 'bar'], $ar->getArrayCopy());
}
public function testFlags()
{
$ar = new ArrayObject();
- $this->assertEquals(ArrayObject::STD_PROP_LIST, $ar->getFlags());
+ self::assertEquals(ArrayObject::STD_PROP_LIST, $ar->getFlags());
$ar = new ArrayObject([], ArrayObject::ARRAY_AS_PROPS);
- $this->assertEquals(ArrayObject::ARRAY_AS_PROPS, $ar->getFlags());
+ self::assertEquals(ArrayObject::ARRAY_AS_PROPS, $ar->getFlags());
$ar->setFlags(ArrayObject::STD_PROP_LIST);
- $this->assertEquals(ArrayObject::STD_PROP_LIST, $ar->getFlags());
+ self::assertEquals(ArrayObject::STD_PROP_LIST, $ar->getFlags());
$ar->setFlags(ArrayObject::ARRAY_AS_PROPS);
- $this->assertEquals(ArrayObject::ARRAY_AS_PROPS, $ar->getFlags());
+ self::assertEquals(ArrayObject::ARRAY_AS_PROPS, $ar->getFlags());
}
public function testIterator()
@@ -207,19 +194,19 @@ public function testIterator()
$ar = new ArrayObject(['1' => 'one', '2' => 'two', '3' => 'three']);
$iterator = $ar->getIterator();
$iterator2 = new \ArrayIterator($ar->getArrayCopy());
- $this->assertEquals($iterator2->getArrayCopy(), $iterator->getArrayCopy());
+ self::assertEquals($iterator2->getArrayCopy(), $iterator->getArrayCopy());
}
public function testIteratorClass()
{
$ar = new ArrayObject([], ArrayObject::STD_PROP_LIST, 'RecursiveArrayIterator');
- $this->assertEquals('RecursiveArrayIterator', $ar->getIteratorClass());
+ self::assertEquals('RecursiveArrayIterator', $ar->getIteratorClass());
$ar = new ArrayObject([], ArrayObject::STD_PROP_LIST, 'ArrayIterator');
- $this->assertEquals('ArrayIterator', $ar->getIteratorClass());
+ self::assertEquals('ArrayIterator', $ar->getIteratorClass());
$ar->setIteratorClass('RecursiveArrayIterator');
- $this->assertEquals('RecursiveArrayIterator', $ar->getIteratorClass());
+ self::assertEquals('RecursiveArrayIterator', $ar->getIteratorClass());
$ar->setIteratorClass('ArrayIterator');
- $this->assertEquals('ArrayIterator', $ar->getIteratorClass());
+ self::assertEquals('ArrayIterator', $ar->getIteratorClass());
}
public function testInvalidIteratorClassThrowsInvalidArgumentException()
@@ -234,7 +221,7 @@ public function testKsort()
$sorted = $ar->getArrayCopy();
ksort($sorted);
$ar->ksort();
- $this->assertSame($sorted, $ar->getArrayCopy());
+ self::assertSame($sorted, $ar->getArrayCopy());
}
public function testNatcasesort()
@@ -243,7 +230,7 @@ public function testNatcasesort()
$sorted = $ar->getArrayCopy();
natcasesort($sorted);
$ar->natcasesort();
- $this->assertSame($sorted, $ar->getArrayCopy());
+ self::assertSame($sorted, $ar->getArrayCopy());
}
public function testNatsort()
@@ -252,7 +239,7 @@ public function testNatsort()
$sorted = $ar->getArrayCopy();
natsort($sorted);
$ar->natsort();
- $this->assertSame($sorted, $ar->getArrayCopy());
+ self::assertSame($sorted, $ar->getArrayCopy());
}
public function testOffsetExists()
@@ -261,10 +248,10 @@ public function testOffsetExists()
$ar['foo'] = 'bar';
$ar->bar = 'baz';
- $this->assertTrue($ar->offsetExists('foo'));
- $this->assertFalse($ar->offsetExists('bar'));
- $this->assertTrue(isset($ar->bar));
- $this->assertFalse(isset($ar->foo));
+ self::assertTrue($ar->offsetExists('foo'));
+ self::assertFalse($ar->offsetExists('bar'));
+ self::assertTrue(isset($ar->bar));
+ self::assertFalse(isset($ar->foo));
}
public function testOffsetExistsThrowsExceptionOnProtectedProperty()
@@ -280,10 +267,10 @@ public function testOffsetGetOffsetSet()
$ar['foo'] = 'bar';
$ar->bar = 'baz';
- $this->assertSame('bar', $ar['foo']);
- $this->assertSame('baz', $ar->bar);
- $this->assertFalse(isset($ar->unknown));
- $this->assertFalse(isset($ar['unknown']));
+ self::assertSame('bar', $ar['foo']);
+ self::assertSame('baz', $ar->bar);
+ self::assertFalse(isset($ar->unknown));
+ self::assertFalse(isset($ar['unknown']));
}
public function testOffsetGetThrowsExceptionOnProtectedProperty()
@@ -307,9 +294,9 @@ public function testOffsetUnset()
$ar->bar = 'foo';
unset($ar['foo']);
unset($ar->bar);
- $this->assertFalse(isset($ar['foo']));
- $this->assertFalse(isset($ar->bar));
- $this->assertSame([], $ar->getArrayCopy());
+ self::assertFalse(isset($ar['foo']));
+ self::assertFalse(isset($ar->bar));
+ self::assertSame([], $ar->getArrayCopy());
}
public function testOffsetUnsetMultidimensional()
@@ -318,7 +305,7 @@ public function testOffsetUnsetMultidimensional()
$ar['foo'] = ['bar' => ['baz' => 'boo']];
unset($ar['foo']['bar']['baz']);
- $this->assertArrayNotHasKey('baz', $ar['foo']['bar']);
+ self::assertArrayNotHasKey('baz', $ar['foo']['bar']);
}
public function testOffsetUnsetThrowsExceptionOnProtectedProperty()
@@ -338,8 +325,8 @@ public function testSerializeUnserialize()
$ar = new ArrayObject();
$ar->unserialize($serialized);
- $this->assertSame('bar', $ar->foo);
- $this->assertSame('foo', $ar['bar']);
+ self::assertSame('bar', $ar->foo);
+ self::assertSame('foo', $ar['bar']);
}
public function testUasort()
@@ -355,7 +342,7 @@ public function testUasort()
$sorted = $ar->getArrayCopy();
uasort($sorted, $function);
$ar->uasort($function);
- $this->assertSame($sorted, $ar->getArrayCopy());
+ self::assertSame($sorted, $ar->getArrayCopy());
}
public function testUksort()
@@ -371,7 +358,7 @@ public function testUksort()
$sorted = $ar->getArrayCopy();
uksort($sorted, $function);
$ar->uksort($function);
- $this->assertSame($sorted, $ar->getArrayCopy());
+ self::assertSame($sorted, $ar->getArrayCopy());
}
/**
@@ -383,6 +370,6 @@ public function testSerializationRestoresProperties()
$ar->foo = 'bar';
$ar['bar'] = 'foo';
- $this->assertEquals($ar, unserialize(serialize($ar)));
+ self::assertEquals($ar, unserialize(serialize($ar)));
}
}
diff --git a/test/ArrayUtilsTest.php b/test/ArrayUtilsTest.php
index f472b5ed..d53d2a55 100644
--- a/test/ArrayUtilsTest.php
+++ b/test/ArrayUtilsTest.php
@@ -291,8 +291,8 @@ public function testMergeReplaceKey()
'foo' => 'get',
]),
];
- $this->assertInstanceOf('Laminas\Stdlib\ArrayUtils\MergeReplaceKeyInterface', $b['car']);
- $this->assertEquals($expected, ArrayUtils::merge($a, $b));
+ self::assertInstanceOf('Laminas\Stdlib\ArrayUtils\MergeReplaceKeyInterface', $b['car']);
+ self::assertEquals($expected, ArrayUtils::merge($a, $b));
}
/**
@@ -311,7 +311,7 @@ public function testAllowsRemovingKeys()
$expected = [
'bar' => 'bat'
];
- $this->assertEquals($expected, ArrayUtils::merge($a, $b));
+ self::assertEquals($expected, ArrayUtils::merge($a, $b));
}
public static function validIterators()
@@ -356,7 +356,7 @@ public static function invalidIterators()
*/
public function testValidArraysWithStringKeys($test)
{
- $this->assertTrue(ArrayUtils::hasStringKeys($test));
+ self::assertTrue(ArrayUtils::hasStringKeys($test));
}
/**
@@ -364,7 +364,7 @@ public function testValidArraysWithStringKeys($test)
*/
public function testValidArraysWithIntegerKeys($test)
{
- $this->assertTrue(ArrayUtils::hasIntegerKeys($test));
+ self::assertTrue(ArrayUtils::hasIntegerKeys($test));
}
/**
@@ -372,7 +372,7 @@ public function testValidArraysWithIntegerKeys($test)
*/
public function testValidArraysWithNumericKeys($test)
{
- $this->assertTrue(ArrayUtils::hasNumericKeys($test));
+ self::assertTrue(ArrayUtils::hasNumericKeys($test));
}
/**
@@ -380,17 +380,17 @@ public function testValidArraysWithNumericKeys($test)
*/
public function testInvalidArraysAlwaysReturnFalse($test)
{
- $this->assertFalse(ArrayUtils::hasStringKeys($test, false));
- $this->assertFalse(ArrayUtils::hasIntegerKeys($test, false));
- $this->assertFalse(ArrayUtils::hasNumericKeys($test, false));
- $this->assertFalse(ArrayUtils::isList($test, false));
- $this->assertFalse(ArrayUtils::isHashTable($test, false));
-
- $this->assertFalse(ArrayUtils::hasStringKeys($test, false));
- $this->assertFalse(ArrayUtils::hasIntegerKeys($test, false));
- $this->assertFalse(ArrayUtils::hasNumericKeys($test, false));
- $this->assertFalse(ArrayUtils::isList($test, false));
- $this->assertFalse(ArrayUtils::isHashTable($test, false));
+ self::assertFalse(ArrayUtils::hasStringKeys($test, false));
+ self::assertFalse(ArrayUtils::hasIntegerKeys($test, false));
+ self::assertFalse(ArrayUtils::hasNumericKeys($test, false));
+ self::assertFalse(ArrayUtils::isList($test, false));
+ self::assertFalse(ArrayUtils::isHashTable($test, false));
+
+ self::assertFalse(ArrayUtils::hasStringKeys($test, false));
+ self::assertFalse(ArrayUtils::hasIntegerKeys($test, false));
+ self::assertFalse(ArrayUtils::hasNumericKeys($test, false));
+ self::assertFalse(ArrayUtils::isList($test, false));
+ self::assertFalse(ArrayUtils::isHashTable($test, false));
}
/**
@@ -398,11 +398,11 @@ public function testInvalidArraysAlwaysReturnFalse($test)
*/
public function testLists($test)
{
- $this->assertTrue(ArrayUtils::isList($test));
- $this->assertTrue(ArrayUtils::hasIntegerKeys($test));
- $this->assertTrue(ArrayUtils::hasNumericKeys($test));
- $this->assertFalse(ArrayUtils::hasStringKeys($test));
- $this->assertFalse(ArrayUtils::isHashTable($test));
+ self::assertTrue(ArrayUtils::isList($test));
+ self::assertTrue(ArrayUtils::hasIntegerKeys($test));
+ self::assertTrue(ArrayUtils::hasNumericKeys($test));
+ self::assertFalse(ArrayUtils::hasStringKeys($test));
+ self::assertFalse(ArrayUtils::isHashTable($test));
}
/**
@@ -410,28 +410,28 @@ public function testLists($test)
*/
public function testHashTables($test)
{
- $this->assertTrue(ArrayUtils::isHashTable($test));
- $this->assertFalse(ArrayUtils::isList($test));
+ self::assertTrue(ArrayUtils::isHashTable($test));
+ self::assertFalse(ArrayUtils::isList($test));
}
public function testEmptyArrayReturnsTrue()
{
$test = [];
- $this->assertTrue(ArrayUtils::hasStringKeys($test, true));
- $this->assertTrue(ArrayUtils::hasIntegerKeys($test, true));
- $this->assertTrue(ArrayUtils::hasNumericKeys($test, true));
- $this->assertTrue(ArrayUtils::isList($test, true));
- $this->assertTrue(ArrayUtils::isHashTable($test, true));
+ self::assertTrue(ArrayUtils::hasStringKeys($test, true));
+ self::assertTrue(ArrayUtils::hasIntegerKeys($test, true));
+ self::assertTrue(ArrayUtils::hasNumericKeys($test, true));
+ self::assertTrue(ArrayUtils::isList($test, true));
+ self::assertTrue(ArrayUtils::isHashTable($test, true));
}
public function testEmptyArrayReturnsFalse()
{
$test = [];
- $this->assertFalse(ArrayUtils::hasStringKeys($test, false));
- $this->assertFalse(ArrayUtils::hasIntegerKeys($test, false));
- $this->assertFalse(ArrayUtils::hasNumericKeys($test, false));
- $this->assertFalse(ArrayUtils::isList($test, false));
- $this->assertFalse(ArrayUtils::isHashTable($test, false));
+ self::assertFalse(ArrayUtils::hasStringKeys($test, false));
+ self::assertFalse(ArrayUtils::hasIntegerKeys($test, false));
+ self::assertFalse(ArrayUtils::hasNumericKeys($test, false));
+ self::assertFalse(ArrayUtils::isList($test, false));
+ self::assertFalse(ArrayUtils::isHashTable($test, false));
}
/**
@@ -439,7 +439,7 @@ public function testEmptyArrayReturnsFalse()
*/
public function testMerge($a, $b, $preserveNumericKeys, $expected)
{
- $this->assertEquals($expected, ArrayUtils::merge($a, $b, $preserveNumericKeys));
+ self::assertEquals($expected, ArrayUtils::merge($a, $b, $preserveNumericKeys));
}
/**
@@ -448,7 +448,7 @@ public function testMerge($a, $b, $preserveNumericKeys, $expected)
public function testValidIteratorsReturnArrayRepresentation($test, $expected)
{
$result = ArrayUtils::iteratorToArray($test);
- $this->assertEquals($expected, $result);
+ self::assertEquals($expected, $result);
}
/**
@@ -457,7 +457,7 @@ public function testValidIteratorsReturnArrayRepresentation($test, $expected)
public function testInvalidIteratorsRaiseInvalidArgumentException($test)
{
$this->expectException(InvalidArgumentException::class);
- $this->assertFalse(ArrayUtils::iteratorToArray($test));
+ self::assertFalse(ArrayUtils::iteratorToArray($test));
}
public function filterArrays()
@@ -509,7 +509,7 @@ function ($key) {
*/
public function testFiltersArray($data, $callback, $flag, $result)
{
- $this->assertEquals($result, ArrayUtils::filter($data, $callback, $flag));
+ self::assertEquals($result, ArrayUtils::filter($data, $callback, $flag));
}
public function testInvalidCallableRaiseInvalidArgumentException()
diff --git a/test/ConsoleHelperTest.php b/test/ConsoleHelperTest.php
index 0bb8662c..e621ef19 100644
--- a/test/ConsoleHelperTest.php
+++ b/test/ConsoleHelperTest.php
@@ -14,7 +14,7 @@
class ConsoleHelperTest extends TestCase
{
- public function setUp()
+ protected function setUp() : void
{
$this->helper = new ConsoleHelper();
}
@@ -63,7 +63,7 @@ public function testCanColorizeInfoString()
$this->enableColorSupport();
$colorized = $this->helper->colorize($string);
- $this->assertEquals(" \033[32m-h|--help\033[0m This help message", $colorized);
+ self::assertEquals(" \033[32m-h|--help\033[0m This help message", $colorized);
}
public function testCanColorizeErrorString()
@@ -72,7 +72,7 @@ public function testCanColorizeErrorString()
$this->enableColorSupport();
$colorized = $this->helper->colorize($string);
- $this->assertEquals("\033[31mNOT OK\033[0m An error occurred", $colorized);
+ self::assertEquals("\033[31mNOT OK\033[0m An error occurred", $colorized);
}
public function testCanColorizeMixedStrings()
@@ -81,8 +81,8 @@ public function testCanColorizeMixedStrings()
$string = "NOT OK\n\nUsage: foo";
$colorized = $this->helper->colorize($string);
- $this->assertContains("\033[31mNOT OK\033[0m", $colorized, 'Colorized error string not found');
- $this->assertContains("\033[32mUsage:\033[0m", $colorized, 'Colorized info string not found');
+ self::assertStringContainsString("\033[31mNOT OK\033[0m", $colorized, 'Colorized error string not found');
+ self::assertStringContainsString("\033[32mUsage:\033[0m", $colorized, 'Colorized info string not found');
}
public function testColorizationWillReplaceTagsWithEmptyStringsWhenColorSupportIsNotDetected()
@@ -91,11 +91,11 @@ public function testColorizationWillReplaceTagsWithEmptyStringsWhenColorSupportI
$string = "NOT OK\n\nUsage: foo";
$colorized = $this->helper->colorize($string);
- $this->assertNotContains("\033[31m", $colorized, 'Colorized error string discovered');
- $this->assertNotContains("\033[32m", $colorized, 'Colorized info string discovered');
- $this->assertNotContains("\033[0m", $colorized, 'Color reset sequence discovered');
- $this->assertNotRegexp("/<\/?error>/", $colorized, 'Error template string discovered');
- $this->assertNotRegexp("/<\/?info>/", $colorized, 'Info template string discovered');
+ self::assertStringNotContainsString("\033[31m", $colorized, 'Colorized error string discovered');
+ self::assertStringNotContainsString("\033[32m", $colorized, 'Colorized info string discovered');
+ self::assertStringNotContainsString("\033[0m", $colorized, 'Color reset sequence discovered');
+ self::assertDoesNotMatchRegularExpression("/<\/?error>/", $colorized, 'Error template string discovered');
+ self::assertDoesNotMatchRegularExpression("/<\/?info>/", $colorized, 'Info template string discovered');
}
public function testWriteFormatsLinesToPhpEolSequenceAndWritesToProvidedStream()
@@ -107,7 +107,7 @@ public function testWriteFormatsLinesToPhpEolSequenceAndWritesToProvidedStream()
$this->helper->write($string, false, $stream);
$contents = $this->retrieveStreamContents($stream);
- $this->assertContains("\r\n", $contents);
+ self::assertStringContainsString("\r\n", $contents);
}
public function testWriteWillColorizeOutputIfRequested()
@@ -119,7 +119,7 @@ public function testWriteWillColorizeOutputIfRequested()
$this->helper->write($string, true, $stream);
$contents = $this->retrieveStreamContents($stream);
- $this->assertContains("\033[32mbar\033[0m", $contents);
+ self::assertStringContainsString("\033[32mbar\033[0m", $contents);
}
public function testWriteLineAppendsPhpEolSequenceToString()
@@ -131,7 +131,7 @@ public function testWriteLineAppendsPhpEolSequenceToString()
$this->helper->writeLine($string, false, $stream);
$contents = $this->retrieveStreamContents($stream);
- $this->assertRegexp("/bar\r\n$/", $contents);
+ self::assertMatchesRegularExpression("/bar\r\n$/", $contents);
}
public function testWriteErrorMessageWritesColorizedOutputToStderr()
@@ -144,6 +144,6 @@ public function testWriteErrorMessageWritesColorizedOutputToStderr()
$this->helper->writeErrorMessage('an error occurred');
$contents = $this->retrieveStreamContents($stderr);
- $this->assertEquals("\033[31man error occurred\033[0m\r\n\r\n", $contents);
+ self::assertEquals("\033[31man error occurred\033[0m\r\n\r\n", $contents);
}
}
diff --git a/test/ErrorHandlerTest.php b/test/ErrorHandlerTest.php
index 95f08c8a..ef75b500 100644
--- a/test/ErrorHandlerTest.php
+++ b/test/ErrorHandlerTest.php
@@ -14,7 +14,7 @@
class ErrorHandlerTest extends TestCase
{
- public function tearDown()
+ protected function tearDown() : void
{
if (ErrorHandler::getNestedLevel()) {
ErrorHandler::clean();
@@ -23,42 +23,42 @@ public function tearDown()
public function testNestedLevel()
{
- $this->assertSame(0, ErrorHandler::getNestedLevel());
+ self::assertSame(0, ErrorHandler::getNestedLevel());
ErrorHandler::start();
- $this->assertSame(1, ErrorHandler::getNestedLevel());
+ self::assertSame(1, ErrorHandler::getNestedLevel());
ErrorHandler::start();
- $this->assertSame(2, ErrorHandler::getNestedLevel());
+ self::assertSame(2, ErrorHandler::getNestedLevel());
ErrorHandler::stop();
- $this->assertSame(1, ErrorHandler::getNestedLevel());
+ self::assertSame(1, ErrorHandler::getNestedLevel());
ErrorHandler::stop();
- $this->assertSame(0, ErrorHandler::getNestedLevel());
+ self::assertSame(0, ErrorHandler::getNestedLevel());
}
public function testClean()
{
ErrorHandler::start();
- $this->assertSame(1, ErrorHandler::getNestedLevel());
+ self::assertSame(1, ErrorHandler::getNestedLevel());
ErrorHandler::start();
- $this->assertSame(2, ErrorHandler::getNestedLevel());
+ self::assertSame(2, ErrorHandler::getNestedLevel());
ErrorHandler::clean();
- $this->assertSame(0, ErrorHandler::getNestedLevel());
+ self::assertSame(0, ErrorHandler::getNestedLevel());
}
public function testStarted()
{
- $this->assertFalse(ErrorHandler::started());
+ self::assertFalse(ErrorHandler::started());
ErrorHandler::start();
- $this->assertTrue(ErrorHandler::started());
+ self::assertTrue(ErrorHandler::started());
ErrorHandler::stop();
- $this->assertFalse(ErrorHandler::started());
+ self::assertFalse(ErrorHandler::started());
}
public function testReturnCatchedError()
@@ -67,7 +67,7 @@ public function testReturnCatchedError()
1 / 0; // Division by zero
$err = ErrorHandler::stop();
- $this->assertInstanceOf('ErrorException', $err);
+ self::assertInstanceOf('ErrorException', $err);
}
public function testThrowCatchedError()
@@ -86,19 +86,19 @@ public function testAddError()
ErrorHandler::addError(2, 'test-msg2', 'test-file2', 200);
$err = ErrorHandler::stop();
- $this->assertInstanceOf('ErrorException', $err);
- $this->assertEquals('test-file2', $err->getFile());
- $this->assertEquals('test-msg2', $err->getMessage());
- $this->assertEquals(200, $err->getLine());
- $this->assertEquals(0, $err->getCode());
- $this->assertEquals(2, $err->getSeverity());
+ self::assertInstanceOf('ErrorException', $err);
+ self::assertEquals('test-file2', $err->getFile());
+ self::assertEquals('test-msg2', $err->getMessage());
+ self::assertEquals(200, $err->getLine());
+ self::assertEquals(0, $err->getCode());
+ self::assertEquals(2, $err->getSeverity());
$previous = $err->getPrevious();
- $this->assertInstanceOf('ErrorException', $previous);
- $this->assertEquals('test-file1', $previous->getFile());
- $this->assertEquals('test-msg1', $previous->getMessage());
- $this->assertEquals(100, $previous->getLine());
- $this->assertEquals(0, $previous->getCode());
- $this->assertEquals(1, $previous->getSeverity());
+ self::assertInstanceOf('ErrorException', $previous);
+ self::assertEquals('test-file1', $previous->getFile());
+ self::assertEquals('test-msg1', $previous->getMessage());
+ self::assertEquals(100, $previous->getLine());
+ self::assertEquals(0, $previous->getCode());
+ self::assertEquals(1, $previous->getSeverity());
}
}
diff --git a/test/FastPriorityQueueTest.php b/test/FastPriorityQueueTest.php
index 3fe03589..0be21bac 100644
--- a/test/FastPriorityQueueTest.php
+++ b/test/FastPriorityQueueTest.php
@@ -27,7 +27,7 @@ class FastPriorityQueueTest extends TestCase
*/
protected $expected;
- public function setUp()
+ protected function setUp() : void
{
$this->queue = new FastPriorityQueue();
$this->insertDataQueue($this->queue);
@@ -67,22 +67,22 @@ protected function insertDataQueue(FastPriorityQueue $queue)
public function testInsertExtract()
{
foreach ($this->expected as $value) {
- $this->assertEquals($value, $this->queue->extract());
+ self::assertEquals($value, $this->queue->extract());
}
// We check that the elements are removed from the queue
- $this->assertTrue($this->queue->isEmpty());
+ self::assertTrue($this->queue->isEmpty());
}
public function testIteratePreserveElements()
{
$i = 0;
foreach ($this->queue as $value) {
- $this->assertEquals($this->expected[$i++], $value);
+ self::assertEquals($this->expected[$i++], $value);
}
// We check that the elements still exist in the queue
$i = 0;
foreach ($this->queue as $value) {
- $this->assertEquals($this->expected[$i++], $value);
+ self::assertEquals($this->expected[$i++], $value);
}
}
@@ -99,7 +99,7 @@ public function testMaintainsInsertOrderForDataOfEqualPriority()
foreach ($queue as $datum) {
$test[] = $datum;
}
- $this->assertEquals($expected, $test);
+ self::assertEquals($expected, $test);
}
public function testSerializationAndDeserializationShouldMaintainState()
@@ -107,7 +107,7 @@ public function testSerializationAndDeserializationShouldMaintainState()
$s = serialize($this->queue);
$unserialized = unserialize($s);
$count = count($this->queue);
- $this->assertSame(
+ self::assertSame(
$count,
count($unserialized),
'Expected count ' . $count . '; received ' . count($unserialized)
@@ -121,7 +121,7 @@ public function testSerializationAndDeserializationShouldMaintainState()
foreach ($unserialized as $item) {
$test[] = $item;
}
- $this->assertSame(
+ self::assertSame(
$expected,
$test,
'Expected: ' . var_export($expected, 1) . "\nReceived:" . var_export($test, 1)
@@ -131,36 +131,36 @@ public function testSerializationAndDeserializationShouldMaintainState()
public function testCanRetrieveQueueAsArray()
{
$test = $this->queue->toArray();
- $this->assertSame($this->expected, $test, var_export($test, 1));
+ self::assertSame($this->expected, $test, var_export($test, 1));
}
public function testIteratorFunctions()
{
- $this->assertEquals($this->expected, iterator_to_array($this->queue));
+ self::assertEquals($this->expected, iterator_to_array($this->queue));
}
public function testRewindOperation()
{
- $this->assertEquals(0, $this->queue->key());
+ self::assertEquals(0, $this->queue->key());
$this->queue->next();
- $this->assertEquals(1, $this->queue->key());
+ self::assertEquals(1, $this->queue->key());
$this->queue->rewind();
- $this->assertEquals(0, $this->queue->key());
+ self::assertEquals(0, $this->queue->key());
}
public function testSetExtractFlag()
{
$priorities = $this->getDataPriorityQueue();
$this->queue->setExtractFlags(FastPriorityQueue::EXTR_DATA);
- $this->assertEquals($this->expected[0], $this->queue->extract());
+ self::assertEquals($this->expected[0], $this->queue->extract());
$this->queue->setExtractFlags(FastPriorityQueue::EXTR_PRIORITY);
- $this->assertEquals($priorities[$this->expected[1]], $this->queue->extract());
+ self::assertEquals($priorities[$this->expected[1]], $this->queue->extract());
$this->queue->setExtractFlags(FastPriorityQueue::EXTR_BOTH);
$expected = [
'data' => $this->expected[2],
'priority' => $priorities[$this->expected[2]]
];
- $this->assertEquals($expected, $this->queue->extract());
+ self::assertEquals($expected, $this->queue->extract());
}
public function testSetInvalidExtractFlag()
@@ -173,41 +173,41 @@ public function testSetInvalidExtractFlag()
public function testIsEmpty()
{
$queue = new FastPriorityQueue();
- $this->assertTrue($queue->isEmpty());
+ self::assertTrue($queue->isEmpty());
$queue->insert('foo', 1);
- $this->assertFalse($queue->isEmpty());
+ self::assertFalse($queue->isEmpty());
$value = $queue->extract();
- $this->assertTrue($queue->isEmpty());
+ self::assertTrue($queue->isEmpty());
}
public function testContains()
{
foreach ($this->expected as $value) {
- $this->assertTrue($this->queue->contains($value));
+ self::assertTrue($this->queue->contains($value));
}
- $this->assertFalse($this->queue->contains('foo'));
+ self::assertFalse($this->queue->contains('foo'));
}
public function testHasPriority()
{
foreach ($this->getDataPriorityQueue() as $value => $priority) {
- $this->assertTrue($this->queue->hasPriority($priority));
+ self::assertTrue($this->queue->hasPriority($priority));
}
- $this->assertFalse($this->queue->hasPriority(10000));
+ self::assertFalse($this->queue->hasPriority(10000));
}
public function testCanRemoveItemFromQueue()
{
- $this->assertTrue($this->queue->remove('test5'));
+ self::assertTrue($this->queue->remove('test5'));
$tot = count($this->getDataPriorityQueue()) - 1;
- $this->assertEquals($this->queue->count(), $tot);
- $this->assertEquals(count($this->queue), $tot);
+ self::assertEquals($this->queue->count(), $tot);
+ self::assertEquals(count($this->queue), $tot);
$expected = ['test1', 'test2', 'test3', 'test4', 'test6'];
$test = [];
foreach ($this->queue as $item) {
$test[] = $item;
}
- $this->assertEquals($expected, $test);
+ self::assertEquals($expected, $test);
}
public function testRemoveOnlyTheFirstOccurenceFromQueue()
@@ -215,30 +215,30 @@ public function testRemoveOnlyTheFirstOccurenceFromQueue()
$data = $this->getDataPriorityQueue();
$this->queue->insert('test2', $data['test2']);
$tot = count($this->getDataPriorityQueue()) + 1;
- $this->assertEquals($this->queue->count(), $tot);
- $this->assertEquals(count($this->queue), $tot);
+ self::assertEquals($this->queue->count(), $tot);
+ self::assertEquals(count($this->queue), $tot);
$expected = ['test1', 'test2', 'test2', 'test3', 'test4', 'test5', 'test6'];
$test = [];
foreach ($this->queue as $item) {
$test[] = $item;
}
- $this->assertEquals($expected, $test);
+ self::assertEquals($expected, $test);
- $this->assertTrue($this->queue->remove('test2'));
- $this->assertEquals($this->queue->count(), $tot - 1);
- $this->assertEquals(count($this->queue), $tot - 1);
+ self::assertTrue($this->queue->remove('test2'));
+ self::assertEquals($this->queue->count(), $tot - 1);
+ self::assertEquals(count($this->queue), $tot - 1);
$test = [];
foreach ($this->queue as $item) {
$test[] = $item;
}
- $this->assertEquals($this->expected, $test);
+ self::assertEquals($this->expected, $test);
}
public function testRewindShouldNotRaiseErrorWhenQueueIsEmpty()
{
$queue = new FastPriorityQueue();
- $this->assertTrue($queue->isEmpty());
+ self::assertTrue($queue->isEmpty());
$queue->rewind();
}
@@ -249,7 +249,7 @@ public function testRemoveShouldFindItemEvenIfMultipleItemsAreInQueue()
};
$queue = new FastPriorityQueue();
- $this->assertTrue($queue->isEmpty());
+ self::assertTrue($queue->isEmpty());
$listeners = [];
for ($i = 0; $i < 5; $i += 1) {
@@ -260,9 +260,9 @@ public function testRemoveShouldFindItemEvenIfMultipleItemsAreInQueue()
$remove = array_rand(array_keys($listeners));
$listener = $listeners[$remove];
- $this->assertTrue($queue->contains($listener));
- $this->assertTrue($queue->remove($listener));
- $this->assertFalse($queue->contains($listener));
+ self::assertTrue($queue->contains($listener));
+ self::assertTrue($queue->remove($listener));
+ self::assertFalse($queue->contains($listener));
}
public function testIterativelyRemovingItemsShouldRemoveAllItems()
@@ -271,7 +271,7 @@ public function testIterativelyRemovingItemsShouldRemoveAllItems()
};
$queue = new FastPriorityQueue();
- $this->assertTrue($queue->isEmpty());
+ self::assertTrue($queue->isEmpty());
$listeners = [];
for ($i = 0; $i < 5; $i += 1) {
@@ -286,7 +286,7 @@ public function testIterativelyRemovingItemsShouldRemoveAllItems()
for ($i = 0; $i < 5; $i += 1) {
$listener = $listeners[$i];
- $this->assertFalse($queue->contains($listener), sprintf('Listener %s remained in queue', $i));
+ self::assertFalse($queue->contains($listener), sprintf('Listener %s remained in queue', $i));
}
}
@@ -303,8 +303,8 @@ public function testRemoveShouldNotAffectExtract()
while ($value = $queue->extract()) {
$test[] = $value;
}
- $this->assertEquals($expected, $test);
- $this->assertTrue($queue->isEmpty());
+ self::assertEquals($expected, $test);
+ self::assertTrue($queue->isEmpty());
// Removing an element in the middle of a set of elements with the same priority
$queue->insert('a1', 1);
@@ -316,8 +316,8 @@ public function testRemoveShouldNotAffectExtract()
while ($value = $queue->extract()) {
$test[] = $value;
}
- $this->assertEquals($expected, $test);
- $this->assertTrue($queue->isEmpty());
+ self::assertEquals($expected, $test);
+ self::assertTrue($queue->isEmpty());
// Removing an element with high priority
$queue->insert('a', 1);
@@ -328,8 +328,8 @@ public function testRemoveShouldNotAffectExtract()
while ($value = $queue->extract()) {
$test[] = $value;
}
- $this->assertEquals($expected, $test);
- $this->assertTrue($queue->isEmpty());
+ self::assertEquals($expected, $test);
+ self::assertTrue($queue->isEmpty());
}
public function testZeroPriority()
@@ -342,6 +342,6 @@ public function testZeroPriority()
foreach ($queue as $value) {
$test[] = $value;
}
- $this->assertEquals($expected, $test);
+ self::assertEquals($expected, $test);
}
}
diff --git a/test/GlobTest.php b/test/GlobTest.php
index 23a2da81..7b4ef5f1 100644
--- a/test/GlobTest.php
+++ b/test/GlobTest.php
@@ -20,7 +20,7 @@ public function testFallback()
$this->markTestSkipped('GLOB_BRACE not available');
}
- $this->assertEquals(
+ self::assertEquals(
glob(__DIR__ . '/_files/{alph,bet}a', GLOB_BRACE),
Glob::glob(__DIR__ . '/_files/{alph,bet}a', Glob::GLOB_BRACE, true)
);
@@ -29,7 +29,7 @@ public function testFallback()
public function testNonMatchingGlobReturnsArray()
{
$result = Glob::glob('/some/path/{,*.}{this,orthis}.php', Glob::GLOB_BRACE);
- $this->assertInternalType('array', $result);
+ self::assertIsArray($result);
}
public function testThrowExceptionOnError()
@@ -50,10 +50,10 @@ public function testPatterns($pattern, $expectedSequence)
{
$result = Glob::glob(__DIR__ . '/_files/' . $pattern, Glob::GLOB_BRACE);
- $this->assertCount(count($expectedSequence), $result);
+ self::assertCount(count($expectedSequence), $result);
foreach ($expectedSequence as $i => $expectedFileName) {
- $this->assertStringEndsWith($expectedFileName, $result[$i]);
+ self::assertStringEndsWith($expectedFileName, $result[$i]);
}
}
diff --git a/test/Guard/ArrayOrTraversableGuardTraitTest.php b/test/Guard/ArrayOrTraversableGuardTraitTest.php
index 7eb80045..d6d17dc8 100644
--- a/test/Guard/ArrayOrTraversableGuardTraitTest.php
+++ b/test/Guard/ArrayOrTraversableGuardTraitTest.php
@@ -14,7 +14,7 @@
use PHPUnit\Framework\TestCase;
/**
- * @covers Laminas\Stdlib\Guard\ArrayOrTraversableGuardTrait
+ * @covers \Laminas\Stdlib\Guard\ArrayOrTraversableGuardTrait
*/
class ArrayOrTraversableGuardTraitTest extends TestCase
{
@@ -29,13 +29,13 @@ public function testGuardForArrayOrTraversableThrowsException()
public function testGuardForArrayOrTraversableAllowsArray()
{
$object = new GuardedObject;
- $this->assertNull($object->setArrayOrTraversable([]));
+ self::assertNull($object->setArrayOrTraversable([]));
}
public function testGuardForArrayOrTraversableAllowsTraversable()
{
$object = new GuardedObject;
$traversable = new ArrayObject;
- $this->assertNull($object->setArrayOrTraversable($traversable));
+ self::assertNull($object->setArrayOrTraversable($traversable));
}
}
diff --git a/test/Guard/EmptyGuardTraitTest.php b/test/Guard/EmptyGuardTraitTest.php
index 29617394..8d6377c3 100644
--- a/test/Guard/EmptyGuardTraitTest.php
+++ b/test/Guard/EmptyGuardTraitTest.php
@@ -13,7 +13,7 @@
use PHPUnit\Framework\TestCase;
/**
- * @covers Laminas\Stdlib\Guard\EmptyGuardTrait
+ * @covers \Laminas\Stdlib\Guard\EmptyGuardTrait
*/
class EmptyGuardTraitTest extends TestCase
{
@@ -28,6 +28,6 @@ public function testGuardAgainstEmptyThrowsException()
public function testGuardAgainstEmptyAllowsNonEmptyString()
{
$object = new GuardedObject;
- $this->assertNull($object->setNotEmpty('foo'));
+ self::assertNull($object->setNotEmpty('foo'));
}
}
diff --git a/test/Guard/NullGuardTraitTest.php b/test/Guard/NullGuardTraitTest.php
index ad1c033b..c5635e6b 100644
--- a/test/Guard/NullGuardTraitTest.php
+++ b/test/Guard/NullGuardTraitTest.php
@@ -13,7 +13,7 @@
use PHPUnit\Framework\TestCase;
/**
- * @covers Laminas\Stdlib\Guard\NullGuardTrait
+ * @covers \Laminas\Stdlib\Guard\NullGuardTrait
*/
class NullGuardTraitTest extends TestCase
{
@@ -29,6 +29,6 @@ public function testGuardAgainstNullThrowsException()
public function testGuardAgainstNullAllowsNonNull()
{
$object = new GuardedObject;
- $this->assertNull($object->setNotNull('foo'));
+ self::assertNull($object->setNotNull('foo'));
}
}
diff --git a/test/MessageTest.php b/test/MessageTest.php
index 9e71ac6b..949cec23 100644
--- a/test/MessageTest.php
+++ b/test/MessageTest.php
@@ -18,31 +18,31 @@ public function testMessageCanSetAndGetContent()
{
$message = new Message();
$ret = $message->setContent('I can set content');
- $this->assertInstanceOf('Laminas\Stdlib\Message', $ret);
- $this->assertEquals('I can set content', $message->getContent());
+ self::assertInstanceOf('Laminas\Stdlib\Message', $ret);
+ self::assertEquals('I can set content', $message->getContent());
}
public function testMessageCanSetAndGetMetadataKeyAsString()
{
$message = new Message();
$ret = $message->setMetadata('foo', 'bar');
- $this->assertInstanceOf('Laminas\Stdlib\Message', $ret);
- $this->assertEquals('bar', $message->getMetadata('foo'));
- $this->assertEquals(['foo' => 'bar'], $message->getMetadata());
+ self::assertInstanceOf('Laminas\Stdlib\Message', $ret);
+ self::assertEquals('bar', $message->getMetadata('foo'));
+ self::assertEquals(['foo' => 'bar'], $message->getMetadata());
}
public function testMessageCanSetAndGetMetadataKeyAsArray()
{
$message = new Message();
$ret = $message->setMetadata(['foo' => 'bar']);
- $this->assertInstanceOf('Laminas\Stdlib\Message', $ret);
- $this->assertEquals('bar', $message->getMetadata('foo'));
+ self::assertInstanceOf('Laminas\Stdlib\Message', $ret);
+ self::assertEquals('bar', $message->getMetadata('foo'));
}
public function testMessageGetMetadataWillUseDefaultValueIfNoneExist()
{
$message = new Message();
- $this->assertEquals('bar', $message->getMetadata('foo', 'bar'));
+ self::assertEquals('bar', $message->getMetadata('foo', 'bar'));
}
public function testMessageThrowsExceptionOnInvalidKeyForMetadataSet()
@@ -67,6 +67,6 @@ public function testMessageToStringWorks()
$message->setMetadata(['Foo' => 'bar', 'One' => 'Two']);
$message->setContent('This is my content');
$expected = "Foo: bar\r\nOne: Two\r\n\r\nThis is my content";
- $this->assertEquals($expected, $message->toString());
+ self::assertEquals($expected, $message->toString());
}
}
diff --git a/test/OptionsTest.php b/test/OptionsTest.php
index b5141e0b..2c9b0b9e 100644
--- a/test/OptionsTest.php
+++ b/test/OptionsTest.php
@@ -24,7 +24,7 @@ public function testConstructionWithArray()
{
$options = new TestOptions(['test_field' => 1]);
- $this->assertEquals(1, $options->test_field);
+ self::assertEquals(1, $options->test_field);
}
public function testConstructionWithTraversable()
@@ -32,14 +32,14 @@ public function testConstructionWithTraversable()
$config = new ArrayObject(['test_field' => 1]);
$options = new TestOptions($config);
- $this->assertEquals(1, $options->test_field);
+ self::assertEquals(1, $options->test_field);
}
public function testConstructionWithOptions()
{
$options = new TestOptions(new TestOptions(['test_field' => 1]));
- $this->assertEquals(1, $options->test_field);
+ self::assertEquals(1, $options->test_field);
}
public function testInvalidFieldThrowsException()
@@ -51,7 +51,7 @@ public function testInvalidFieldThrowsException()
public function testNonStrictOptionsDoesNotThrowException()
{
- $this->assertInstanceOf(
+ self::assertInstanceOf(
'LaminasTest\Stdlib\TestAsset\TestOptionsNoStrict',
new TestOptionsNoStrict(['foo' => 'bar'])
);
@@ -59,16 +59,16 @@ public function testNonStrictOptionsDoesNotThrowException()
public function testConstructionWithNull()
{
- $this->assertInstanceOf('LaminasTest\Stdlib\TestAsset\TestOptions', new TestOptions(null));
+ self::assertInstanceOf('LaminasTest\Stdlib\TestAsset\TestOptions', new TestOptions(null));
}
public function testUnsetting()
{
$options = new TestOptions(['test_field' => 1]);
- $this->assertEquals(true, isset($options->test_field));
+ self::assertEquals(true, isset($options->test_field));
unset($options->testField);
- $this->assertEquals(false, isset($options->test_field));
+ self::assertEquals(false, isset($options->test_field));
}
public function testUnsetThrowsInvalidArgumentException()
@@ -94,8 +94,8 @@ public function testSetFromArrayAcceptsArray()
$array = ['test_field' => 3];
$options = new TestOptions();
- $this->assertSame($options, $options->setFromArray($array));
- $this->assertEquals(3, $options->test_field);
+ self::assertSame($options, $options->setFromArray($array));
+ self::assertEquals(3, $options->test_field);
}
public function testSetFromArrayThrowsInvalidArgumentException()
@@ -109,14 +109,14 @@ public function testParentPublicProperty()
{
$options = new TestOptionsDerived(['parent_public' => 1]);
- $this->assertEquals(1, $options->parent_public);
+ self::assertEquals(1, $options->parent_public);
}
public function testParentProtectedProperty()
{
$options = new TestOptionsDerived(['parent_protected' => 1]);
- $this->assertEquals(1, $options->parent_protected);
+ self::assertEquals(1, $options->parent_protected);
}
public function testParentPrivateProperty()
@@ -134,14 +134,14 @@ public function testDerivedPublicProperty()
{
$options = new TestOptionsDerived(['derived_public' => 1]);
- $this->assertEquals(1, $options->derived_public);
+ self::assertEquals(1, $options->derived_public);
}
public function testDerivedProtectedProperty()
{
$options = new TestOptionsDerived(['derived_protected' => 1]);
- $this->assertEquals(1, $options->derived_protected);
+ self::assertEquals(1, $options->derived_protected);
}
public function testDerivedPrivateProperty()
@@ -176,7 +176,7 @@ public function testIssetReturnsFalseWhenMatchingGetterDoesNotExist()
$options = new TestOptionsWithoutGetter([
'foo' => 'bar',
]);
- $this->assertFalse(isset($options->foo));
+ self::assertFalse(isset($options->foo));
}
/**
@@ -199,6 +199,6 @@ public function testIssetReturnsTrueWithValidDataWhenMatchingGetterDoesNotExist(
$options = new TestOptions([
'test_field' => 1,
]);
- $this->assertTrue(isset($options->testField));
+ self::assertTrue(isset($options->testField));
}
}
diff --git a/test/ParametersTest.php b/test/ParametersTest.php
index a888d20a..59d19f8a 100644
--- a/test/ParametersTest.php
+++ b/test/ParametersTest.php
@@ -16,47 +16,47 @@ class ParametersTest extends TestCase
public function testParametersConstructionAndClassStructure()
{
$parameters = new Parameters();
- $this->assertInstanceOf('Laminas\Stdlib\ParametersInterface', $parameters);
- $this->assertInstanceOf('ArrayObject', $parameters);
- $this->assertInstanceOf('ArrayAccess', $parameters);
- $this->assertInstanceOf('Countable', $parameters);
- $this->assertInstanceOf('Serializable', $parameters);
- $this->assertInstanceOf('Traversable', $parameters);
+ self::assertInstanceOf('Laminas\Stdlib\ParametersInterface', $parameters);
+ self::assertInstanceOf('ArrayObject', $parameters);
+ self::assertInstanceOf('ArrayAccess', $parameters);
+ self::assertInstanceOf('Countable', $parameters);
+ self::assertInstanceOf('Serializable', $parameters);
+ self::assertInstanceOf('Traversable', $parameters);
}
public function testParametersPersistNameAndValues()
{
$parameters = new Parameters(['foo' => 'bar']);
- $this->assertEquals('bar', $parameters['foo']);
- $this->assertEquals('bar', $parameters->foo);
+ self::assertEquals('bar', $parameters['foo']);
+ self::assertEquals('bar', $parameters->foo);
$parameters->offsetSet('baz', 5);
- $this->assertEquals(5, $parameters->baz);
+ self::assertEquals(5, $parameters->baz);
$parameters->fromArray(['bar' => 'foo']);
- $this->assertEquals('foo', $parameters->bar);
+ self::assertEquals('foo', $parameters->bar);
$parameters->fromString('bar=foo&five=5');
- $this->assertEquals('foo', $parameters->bar);
- $this->assertEquals('5', $parameters->five);
- $this->assertEquals(['bar' => 'foo', 'five' => '5'], $parameters->toArray());
- $this->assertEquals('bar=foo&five=5', $parameters->toString());
+ self::assertEquals('foo', $parameters->bar);
+ self::assertEquals('5', $parameters->five);
+ self::assertEquals(['bar' => 'foo', 'five' => '5'], $parameters->toArray());
+ self::assertEquals('bar=foo&five=5', $parameters->toString());
$parameters->fromArray([]);
$parameters->set('foof', 'barf');
- $this->assertEquals('barf', $parameters->get('foof'));
- $this->assertEquals('barf', $parameters->foof);
+ self::assertEquals('barf', $parameters->get('foof'));
+ self::assertEquals('barf', $parameters->foof);
}
public function testParametersOffsetgetReturnsNullIfNonexistentKeyIsProvided()
{
$parameters = new Parameters;
- $this->assertNull($parameters->foo);
+ self::assertNull($parameters->foo);
}
public function testParametersGetReturnsDefaultValueIfNonExistent()
{
$parameters = new Parameters();
- $this->assertEquals(5, $parameters->get('nonExistentProp', 5));
+ self::assertEquals(5, $parameters->get('nonExistentProp', 5));
}
}
diff --git a/test/PriorityListTest.php b/test/PriorityListTest.php
index cffa33b8..eb59a879 100644
--- a/test/PriorityListTest.php
+++ b/test/PriorityListTest.php
@@ -18,7 +18,7 @@ class PriorityListTest extends TestCase
*/
protected $list;
- public function setUp()
+ protected function setUp() : void
{
$this->list = new PriorityList();
}
@@ -27,10 +27,10 @@ public function testInsert()
{
$this->list->insert('foo', new \stdClass(), 0);
- $this->assertEquals(1, count($this->list));
+ self::assertEquals(1, count($this->list));
foreach ($this->list as $key => $value) {
- $this->assertEquals('foo', $key);
+ self::assertEquals('foo', $key);
}
}
@@ -39,17 +39,17 @@ public function testInsertDuplicates()
$this->list->insert('foo', new \stdClass());
$this->list->insert('bar', new \stdClass());
- $this->assertEquals(2, count($this->list));
+ self::assertEquals(2, count($this->list));
$this->list->insert('foo', new \stdClass());
$this->list->insert('foo', new \stdClass());
$this->list->insert('bar', new \stdClass());
- $this->assertEquals(2, count($this->list));
+ self::assertEquals(2, count($this->list));
$this->list->remove('foo');
- $this->assertEquals(1, count($this->list));
+ self::assertEquals(1, count($this->list));
}
public function testRemove()
@@ -57,18 +57,18 @@ public function testRemove()
$this->list->insert('foo', new \stdClass(), 0);
$this->list->insert('bar', new \stdClass(), 0);
- $this->assertEquals(2, count($this->list));
+ self::assertEquals(2, count($this->list));
$this->list->remove('foo');
- $this->assertEquals(1, count($this->list));
+ self::assertEquals(1, count($this->list));
}
public function testRemovingNonExistentRouteDoesNotYieldError()
{
$this->list->remove('foo');
- $this->assertEmpty($this->list);
+ self::assertEmpty($this->list);
}
public function testClear()
@@ -76,12 +76,12 @@ public function testClear()
$this->list->insert('foo', new \stdClass(), 0);
$this->list->insert('bar', new \stdClass(), 0);
- $this->assertEquals(2, count($this->list));
+ self::assertEquals(2, count($this->list));
$this->list->clear();
- $this->assertEquals(0, count($this->list));
- $this->assertSame(false, $this->list->current());
+ self::assertEquals(0, count($this->list));
+ self::assertSame(false, $this->list->current());
}
public function testGet()
@@ -90,8 +90,8 @@ public function testGet()
$this->list->insert('foo', $route, 0);
- $this->assertEquals($route, $this->list->get('foo'));
- $this->assertNull($this->list->get('bar'));
+ self::assertEquals($route, $this->list->get('foo'));
+ self::assertNull($this->list->get('bar'));
}
public function testLIFOOnly()
@@ -104,7 +104,7 @@ public function testLIFOOnly()
$orders = array_keys(iterator_to_array($this->list));
- $this->assertEquals(['barbaz', 'foobar', 'baz', 'bar', 'foo'], $orders);
+ self::assertEquals(['barbaz', 'foobar', 'baz', 'bar', 'foo'], $orders);
}
public function testPriorityOnly()
@@ -115,7 +115,7 @@ public function testPriorityOnly()
$orders = array_keys(iterator_to_array($this->list));
- $this->assertEquals(['baz', 'foo', 'bar'], $orders);
+ self::assertEquals(['baz', 'foo', 'bar'], $orders);
}
public function testLIFOWithPriority()
@@ -126,7 +126,7 @@ public function testLIFOWithPriority()
$orders = array_keys(iterator_to_array($this->list));
- $this->assertEquals(['baz', 'bar', 'foo'], $orders);
+ self::assertEquals(['baz', 'bar', 'foo'], $orders);
}
public function testFIFOWithPriority()
@@ -138,7 +138,7 @@ public function testFIFOWithPriority()
$orders = array_keys(iterator_to_array($this->list));
- $this->assertEquals(['baz', 'foo', 'bar'], $orders);
+ self::assertEquals(['baz', 'foo', 'bar'], $orders);
}
public function testFIFOOnly()
@@ -152,7 +152,7 @@ public function testFIFOOnly()
$orders = array_keys(iterator_to_array($this->list));
- $this->assertEquals(['foo', 'bar', 'baz', 'foobar', 'barbaz'], $orders);
+ self::assertEquals(['foo', 'bar', 'baz', 'foobar', 'barbaz'], $orders);
}
public function testPriorityWithNegativesAndNull()
@@ -163,7 +163,7 @@ public function testPriorityWithNegativesAndNull()
$orders = array_keys(iterator_to_array($this->list));
- $this->assertEquals(['bar', 'foo', 'baz'], $orders);
+ self::assertEquals(['bar', 'foo', 'baz'], $orders);
}
public function testCurrent()
@@ -172,18 +172,18 @@ public function testCurrent()
$this->list->insert('bar', 'bar_value', 1);
$this->list->insert('baz', 'baz_value', -1);
- $this->assertEquals('bar', $this->list->key());
- $this->assertEquals('bar_value', $this->list->current());
+ self::assertEquals('bar', $this->list->key());
+ self::assertEquals('bar_value', $this->list->current());
}
public function testIterator()
{
$this->list->insert('foo', 'foo_value');
$iterator = $this->list->getIterator();
- $this->assertEquals($iterator, $this->list);
+ self::assertEquals($iterator, $this->list);
$this->list->insert('bar', 'bar_value');
- $this->assertNotEquals($iterator, $this->list);
+ self::assertNotEquals($iterator, $this->list);
}
public function testToArray()
@@ -192,7 +192,7 @@ public function testToArray()
$this->list->insert('bar', 'bar_value', 1);
$this->list->insert('baz', 'baz_value', -1);
- $this->assertEquals(
+ self::assertEquals(
[
'bar' => 'bar_value',
'foo' => 'foo_value',
@@ -201,7 +201,7 @@ public function testToArray()
$this->list->toArray()
);
- $this->assertEquals(
+ self::assertEquals(
[
'bar' => ['data' => 'bar_value', 'priority' => 1, 'serial' => 1],
'foo' => ['data' => 'foo_value', 'priority' => 0, 'serial' => 0],
@@ -229,8 +229,8 @@ public function testBooleanValuesAreValid()
$orders1[$this->list->key()] = $this->list->current();
$orders2[$key] = $value;
}
- $this->assertEquals($orders1, $orders2);
- $this->assertEquals(
+ self::assertEquals($orders1, $orders2);
+ self::assertEquals(
[
'null' => null,
'false' => false,
diff --git a/test/PriorityQueueTest.php b/test/PriorityQueueTest.php
index f3aaa8e8..fa41d865 100644
--- a/test/PriorityQueueTest.php
+++ b/test/PriorityQueueTest.php
@@ -21,7 +21,7 @@ class PriorityQueueTest extends TestCase
*/
protected $queue;
- public function setUp()
+ protected function setUp() : void
{
$this->queue = new PriorityQueue();
$this->queue->insert('foo', 3);
@@ -35,7 +35,7 @@ public function testSerializationAndDeserializationShouldMaintainState()
$s = serialize($this->queue);
$unserialized = unserialize($s);
$count = count($this->queue);
- $this->assertSame(
+ self::assertSame(
$count,
count($unserialized),
'Expected count ' . $count . '; received ' . count($unserialized)
@@ -43,7 +43,7 @@ public function testSerializationAndDeserializationShouldMaintainState()
$expected = iterator_to_array($this->queue);
$test = iterator_to_array($unserialized);
- $this->assertSame(
+ self::assertSame(
$expected,
$test,
'Expected: ' . var_export($expected, 1) . "\nReceived:" . var_export($test, 1)
@@ -59,7 +59,7 @@ public function testRetrievingQueueAsArrayReturnsDataOnlyByDefault()
'bat',
];
$test = $this->queue->toArray();
- $this->assertSame($expected, $test, var_export($test, 1));
+ self::assertSame($expected, $test, var_export($test, 1));
}
public function testCanCastToArrayOfPrioritiesOnly()
@@ -71,7 +71,7 @@ public function testCanCastToArrayOfPrioritiesOnly()
1,
];
$test = $this->queue->toArray(PriorityQueue::EXTR_PRIORITY);
- $this->assertSame($expected, $test, var_export($test, 1));
+ self::assertSame($expected, $test, var_export($test, 1));
}
public function testCanCastToArrayOfDataPriorityPairs()
@@ -83,7 +83,7 @@ public function testCanCastToArrayOfDataPriorityPairs()
['data' => 'bat', 'priority' => 1],
];
$test = $this->queue->toArray(PriorityQueue::EXTR_BOTH);
- $this->assertSame($expected, $test, var_export($test, 1));
+ self::assertSame($expected, $test, var_export($test, 1));
}
public function testCanIterateMultipleTimesAndReceiveSameResults()
@@ -95,7 +95,7 @@ public function testCanIterateMultipleTimesAndReceiveSameResults()
foreach ($this->queue as $item) {
$test[] = $item;
}
- $this->assertEquals($expected, $test, 'Failed at iteration ' . $i);
+ self::assertEquals($expected, $test, 'Failed at iteration ' . $i);
}
}
@@ -104,19 +104,19 @@ public function testCanRemoveItemFromQueue()
$this->queue->remove('baz');
$expected = ['bar', 'foo', 'bat'];
$test = array_values(iterator_to_array($this->queue));
- $this->assertEquals($expected, $test);
+ self::assertEquals($expected, $test);
}
public function testCanTestForExistenceOfItemInQueue()
{
- $this->assertTrue($this->queue->contains('foo'));
- $this->assertFalse($this->queue->contains('foobar'));
+ self::assertTrue($this->queue->contains('foo'));
+ self::assertFalse($this->queue->contains('foobar'));
}
public function testCanTestForExistenceOfPriorityInQueue()
{
- $this->assertTrue($this->queue->hasPriority(3));
- $this->assertFalse($this->queue->hasPriority(1000));
+ self::assertTrue($this->queue->hasPriority(3));
+ self::assertFalse($this->queue->hasPriority(1000));
}
public function testCloningAlsoClonesQueue()
@@ -131,20 +131,20 @@ public function testCloningAlsoClonesQueue()
$queueClone = clone $queue;
while (! $queue->isEmpty()) {
- $this->assertSame($foo, $queue->top());
+ self::assertSame($foo, $queue->top());
$queue->remove($queue->top());
}
- $this->assertTrue($queue->isEmpty());
- $this->assertFalse($queueClone->isEmpty());
- $this->assertEquals(2, $queueClone->count());
+ self::assertTrue($queue->isEmpty());
+ self::assertFalse($queueClone->isEmpty());
+ self::assertEquals(2, $queueClone->count());
while (! $queueClone->isEmpty()) {
- $this->assertSame($foo, $queueClone->top());
+ self::assertSame($foo, $queueClone->top());
$queueClone->remove($queueClone->top());
}
- $this->assertTrue($queueClone->isEmpty());
+ self::assertTrue($queueClone->isEmpty());
}
public function testQueueRevertsToInitialStateWhenEmpty()
@@ -158,6 +158,6 @@ public function testQueueRevertsToInitialStateWhenEmpty()
$testQueue->remove('foo');
$testQueue->remove('bar');
- $this->assertEquals($queue, $testQueue);
+ self::assertEquals($queue, $testQueue);
}
}
diff --git a/test/SplPriorityQueueTest.php b/test/SplPriorityQueueTest.php
index e0e49f93..ebf0bc33 100644
--- a/test/SplPriorityQueueTest.php
+++ b/test/SplPriorityQueueTest.php
@@ -21,7 +21,7 @@ class SplPriorityQueueTest extends TestCase
*/
protected $queue;
- public function setUp()
+ protected function setUp() : void
{
$this->queue = new SplPriorityQueue();
$this->queue->insert('foo', 3);
@@ -40,7 +40,7 @@ public function testMaintainsInsertOrderForDataOfEqualPriority()
$expected = ['foo', 'bar', 'baz', 'bat'];
$test = array_values(iterator_to_array($queue));
- $this->assertEquals($expected, $test);
+ self::assertEquals($expected, $test);
}
public function testSerializationAndDeserializationShouldMaintainState()
@@ -49,13 +49,13 @@ public function testSerializationAndDeserializationShouldMaintainState()
$unserialized = unserialize($s);
// assert same size
- $this->assertSameSize($this->queue, $unserialized);
+ self::assertSameSize($this->queue, $unserialized);
// assert same values
- $this->assertSame(iterator_to_array($this->queue), iterator_to_array($unserialized));
+ self::assertSame(iterator_to_array($this->queue), iterator_to_array($unserialized));
// assert equal
- $this->assertEquals($this->queue, $unserialized);
+ self::assertEquals($this->queue, $unserialized);
}
public function testCanRetrieveQueueAsArray()
@@ -67,6 +67,6 @@ public function testCanRetrieveQueueAsArray()
'bat',
];
$test = $this->queue->toArray();
- $this->assertSame($expected, $test, var_export($test, 1));
+ self::assertSame($expected, $test, var_export($test, 1));
}
}
diff --git a/test/SplQueueTest.php b/test/SplQueueTest.php
index 703a7daf..f23fc0ac 100644
--- a/test/SplQueueTest.php
+++ b/test/SplQueueTest.php
@@ -21,7 +21,7 @@ class SplQueueTest extends TestCase
*/
protected $queue;
- public function setUp()
+ protected function setUp() : void
{
$this->queue = new SplQueue();
$this->queue->push('foo');
@@ -34,16 +34,16 @@ public function testSerializationAndDeserializationShouldMaintainState()
$s = serialize($this->queue);
$unserialized = unserialize($s);
$count = count($this->queue);
- $this->assertSame($count, count($unserialized));
+ self::assertSame($count, count($unserialized));
$expected = iterator_to_array($this->queue);
$test = iterator_to_array($unserialized);
- $this->assertSame($expected, $test);
+ self::assertSame($expected, $test);
}
public function testCanRetrieveQueueAsArray()
{
$expected = ['foo', 'bar', 'baz'];
- $this->assertSame($expected, $this->queue->toArray());
+ self::assertSame($expected, $this->queue->toArray());
}
}
diff --git a/test/SplStackTest.php b/test/SplStackTest.php
index 308fc822..b42c7541 100644
--- a/test/SplStackTest.php
+++ b/test/SplStackTest.php
@@ -21,7 +21,7 @@ class SplStackTest extends TestCase
*/
protected $stack;
- public function setUp()
+ protected function setUp() : void
{
$this->stack = new SplStack();
$this->stack->push('foo');
@@ -35,17 +35,17 @@ public function testSerializationAndDeserializationShouldMaintainState()
$s = serialize($this->stack);
$unserialized = unserialize($s);
$count = count($this->stack);
- $this->assertSame($count, count($unserialized));
+ self::assertSame($count, count($unserialized));
$expected = iterator_to_array($this->stack);
$test = iterator_to_array($unserialized);
- $this->assertSame($expected, $test);
+ self::assertSame($expected, $test);
}
public function testCanRetrieveQueueAsArray()
{
$expected = ['bat', 'baz', 'bar', 'foo'];
$test = $this->stack->toArray();
- $this->assertSame($expected, $test, var_export($test, 1));
+ self::assertSame($expected, $test, var_export($test, 1));
}
}
diff --git a/test/StringUtilsTest.php b/test/StringUtilsTest.php
index 8fbdfd89..346d774e 100644
--- a/test/StringUtilsTest.php
+++ b/test/StringUtilsTest.php
@@ -15,7 +15,7 @@
class StringUtilsTest extends TestCase
{
- public function tearDown()
+ protected function tearDown() : void
{
StringUtils::resetRegisteredWrappers();
}
@@ -51,7 +51,7 @@ public function getSingleByEncodings()
*/
public function testIsSingleByteEncodingReturnsTrue($encoding)
{
- $this->assertTrue(StringUtils::isSingleByteEncoding($encoding));
+ self::assertTrue(StringUtils::isSingleByteEncoding($encoding));
}
public function getNonSingleByteEncodings()
@@ -70,28 +70,28 @@ public function getNonSingleByteEncodings()
*/
public function testIsSingleByteEncodingReturnsFalse($encoding)
{
- $this->assertFalse(StringUtils::isSingleByteEncoding($encoding));
+ self::assertFalse(StringUtils::isSingleByteEncoding($encoding));
}
public function testGetWrapper()
{
$wrapper = StringUtils::getWrapper('ISO-8859-1');
if (extension_loaded('mbstring')) {
- $this->assertInstanceOf('Laminas\Stdlib\StringWrapper\MbString', $wrapper);
+ self::assertInstanceOf('Laminas\Stdlib\StringWrapper\MbString', $wrapper);
} elseif (extension_loaded('iconv')) {
- $this->assertInstanceOf('Laminas\Stdlib\StringWrapper\Iconv', $wrapper);
+ self::assertInstanceOf('Laminas\Stdlib\StringWrapper\Iconv', $wrapper);
} else {
- $this->assertInstanceOf('Laminas\Stdlib\StringWrapper\Native', $wrapper);
+ self::assertInstanceOf('Laminas\Stdlib\StringWrapper\Native', $wrapper);
}
try {
$wrapper = StringUtils::getWrapper('UTF-8');
if (extension_loaded('intl')) {
- $this->assertInstanceOf('Laminas\Stdlib\StringWrapper\Intl', $wrapper);
+ self::assertInstanceOf('Laminas\Stdlib\StringWrapper\Intl', $wrapper);
} elseif (extension_loaded('mbstring')) {
- $this->assertInstanceOf('Laminas\Stdlib\StringWrapper\MbString', $wrapper);
+ self::assertInstanceOf('Laminas\Stdlib\StringWrapper\MbString', $wrapper);
} elseif (extension_loaded('iconv')) {
- $this->assertInstanceOf('Laminas\Stdlib\StringWrapper\Iconv', $wrapper);
+ self::assertInstanceOf('Laminas\Stdlib\StringWrapper\Iconv', $wrapper);
}
} catch (Exception $e) {
if (extension_loaded('intl')
@@ -105,9 +105,9 @@ public function testGetWrapper()
try {
$wrapper = StringUtils::getWrapper('UTF-8', 'ISO-8859-1');
if (extension_loaded('mbstring')) {
- $this->assertInstanceOf('Laminas\Stdlib\StringWrapper\MbString', $wrapper);
+ self::assertInstanceOf('Laminas\Stdlib\StringWrapper\MbString', $wrapper);
} elseif (extension_loaded('iconv')) {
- $this->assertInstanceOf('Laminas\Stdlib\StringWrapper\Iconv', $wrapper);
+ self::assertInstanceOf('Laminas\Stdlib\StringWrapper\Iconv', $wrapper);
}
} catch (Exception $e) {
if (extension_loaded('mbstring') || extension_loaded('iconv')) {
@@ -145,7 +145,7 @@ public function getUtf8StringValidity()
*/
public function testIsValidUtf8($str, $valid)
{
- $this->assertSame($valid, StringUtils::isValidUtf8($str));
+ self::assertSame($valid, StringUtils::isValidUtf8($str));
}
public function testHasPcreUnicodeSupport()
@@ -154,6 +154,6 @@ public function testHasPcreUnicodeSupport()
$expected = defined('PREG_BAD_UTF8_OFFSET_ERROR') && preg_match('/\pL/u', 'a') == 1;
ErrorHandler::stop();
- $this->assertSame($expected, StringUtils::hasPcreUnicodeSupport());
+ self::assertSame($expected, StringUtils::hasPcreUnicodeSupport());
}
}
diff --git a/test/StringWrapper/CommonStringWrapperTest.php b/test/StringWrapper/CommonStringWrapperTest.php
index 384c02ff..9a07d72e 100644
--- a/test/StringWrapper/CommonStringWrapperTest.php
+++ b/test/StringWrapper/CommonStringWrapperTest.php
@@ -43,7 +43,7 @@ public function testStrlen($encoding, $str, $expected)
}
$result = $wrapper->strlen($str);
- $this->assertSame($expected, $result);
+ self::assertSame($expected, $result);
}
public function substrProvider()
@@ -72,7 +72,7 @@ public function testSubstr($encoding, $str, $offset, $length, $expected)
}
$result = $wrapper->substr($str, $offset, $length);
- $this->assertSame($expected, $result);
+ self::assertSame($expected, $result);
}
public function strposProvider()
@@ -101,7 +101,7 @@ public function testStrpos($encoding, $haystack, $needle, $offset, $expected)
}
$result = $wrapper->strpos($haystack, $needle, $offset);
- $this->assertSame($expected, $result);
+ self::assertSame($expected, $result);
}
public function convertProvider()
@@ -131,11 +131,11 @@ public function testConvert($encoding, $convertEncoding, $str, $expected)
}
$result = $wrapper->convert($str);
- $this->assertSame($expected, $result);
+ self::assertSame($expected, $result);
// backword
$result = $wrapper->convert($expected, true);
- $this->assertSame($str, $result);
+ self::assertSame($str, $result);
}
public function wordWrapProvider()
@@ -202,7 +202,7 @@ public function testWordWrap($encoding, $string, $width, $break, $cut, $expected
}
$result = $wrapper->wordWrap($string, $width, $break, $cut);
- $this->assertSame($expected, $result);
+ self::assertSame($expected, $result);
}
public function testWordWrapInvalidArgument()
@@ -258,6 +258,6 @@ public function testStrPad($encoding, $input, $padLength, $padString, $padType,
}
$result = $wrapper->strPad($input, $padLength, $padString, $padType);
- $this->assertSame($expected, $result);
+ self::assertSame($expected, $result);
}
}
diff --git a/test/StringWrapper/IconvTest.php b/test/StringWrapper/IconvTest.php
index f3190627..4c0ae7de 100644
--- a/test/StringWrapper/IconvTest.php
+++ b/test/StringWrapper/IconvTest.php
@@ -13,7 +13,7 @@
class IconvTest extends CommonStringWrapperTest
{
- public function setUp()
+ protected function setUp() : void
{
if (! extension_loaded('iconv')) {
try {
diff --git a/test/StringWrapper/IntlTest.php b/test/StringWrapper/IntlTest.php
index ddbccbe6..28930864 100644
--- a/test/StringWrapper/IntlTest.php
+++ b/test/StringWrapper/IntlTest.php
@@ -13,7 +13,7 @@
class IntlTest extends CommonStringWrapperTest
{
- public function setUp()
+ protected function setUp() : void
{
if (! extension_loaded('intl')) {
try {
diff --git a/test/StringWrapper/MbStringTest.php b/test/StringWrapper/MbStringTest.php
index 7275d247..a140d9fa 100644
--- a/test/StringWrapper/MbStringTest.php
+++ b/test/StringWrapper/MbStringTest.php
@@ -13,7 +13,7 @@
class MbStringTest extends CommonStringWrapperTest
{
- public function setUp()
+ protected function setUp() : void
{
if (! extension_loaded('mbstring')) {
try {