diff options
author | Arnold Daniels <arnold@jasny.net> | 2016-10-13 20:50:08 +0200 |
---|---|---|
committer | minstel <minstel@yandex.ru> | 2016-10-17 22:13:50 +0300 |
commit | 3105e56e4e229aae428ccc236dad4ba1021f6db4 (patch) | |
tree | ab3ffcadb379787747298950e941ad3628cc5bea | |
parent | 46daa66a1d602463a979af3c0f1970cb7914628c (diff) | |
download | router-3105e56e4e229aae428ccc236dad4ba1021f6db4.zip router-3105e56e4e229aae428ccc236dad4ba1021f6db4.tar.gz router-3105e56e4e229aae428ccc236dad4ba1021f6db4.tar.bz2 |
Use phpunit 5's createMock rather than getMock
Minor fixes in tests and code
-rw-r--r-- | src/Router/Routes/Glob.php | 14 | ||||
-rw-r--r-- | tests/Router/Routes/GlobTest.php | 22 |
2 files changed, 18 insertions, 18 deletions
diff --git a/src/Router/Routes/Glob.php b/src/Router/Routes/Glob.php index 97483d8..cb1abf4 100644 --- a/src/Router/Routes/Glob.php +++ b/src/Router/Routes/Glob.php @@ -3,6 +3,7 @@ namespace Jasny\Router\Routes; use ArrayObject; +use ArrayIterator; use Jasny\Router\UrlParsing; use Jasny\Router\Routes; use Jasny\Router\Route; @@ -61,19 +62,6 @@ class Glob extends ArrayObject implements Routes } /** - * Class constructor - * - * @param Route[]|array|\Traversable $input - * @param type $flags - * @param type $iterator_class - */ - public function __construct($input = [], $flags = 0, $iterator_class = "ArrayIterator") - { - parent::__construct($input, $flags, $iterator_class); - } - - - /** * {@inheritdoc} */ public function append($route) diff --git a/tests/Router/Routes/GlobTest.php b/tests/Router/Routes/GlobTest.php index 565c51b..b20a267 100644 --- a/tests/Router/Routes/GlobTest.php +++ b/tests/Router/Routes/GlobTest.php @@ -1,9 +1,16 @@ <?php +namespace Jasny\Router\Routes; + use Jasny\Router\Routes\Glob; use Psr\Http\Message\ServerRequestInterface; -class GlobTest extends PHPUnit_Framework_TestCase +use ArrayObject; +use BadMethodCallException; +use InvalidArgumentException; +use AppendIterator; + +class GlobTest extends \PHPUnit_Framework_TestCase { /** * Test creating Glob object @@ -25,18 +32,22 @@ class GlobTest extends PHPUnit_Framework_TestCase } $this->assertEquals(0, $count); - + } + + public function testConstructorWithArguments() + { #Test with params $values = [ '/foo/bar' => ['controller' => 'value1'], '/foo/*' => ['fn' => 'value3'], '/foo/*/bar' => ['file' => 'value5'], ]; - $glob = new Glob($values, ArrayObject::ARRAY_AS_PROPS, 'AppendIterator'); + + $glob = new Glob($values, ArrayObject::ARRAY_AS_PROPS, AppendIterator::class); $this->assertEquals(count($values), $glob->count(), "Routes count is not match"); $this->assertEquals(ArrayObject::ARRAY_AS_PROPS, $glob->getFlags(), "Flags are not correct"); - $this->assertEquals('AppendIterator', $glob->getIteratorClass(), "Iterator class is not correct"); + $this->assertEquals(AppendIterator::class, $glob->getIteratorClass(), "Iterator class is not correct"); foreach ($values as $pattern => $options) { $this->assertTrue($glob->offsetExists($pattern), "Key '$pattern' is missing"); @@ -148,7 +159,8 @@ class GlobTest extends PHPUnit_Framework_TestCase { $glob = new Glob(); - $this->assertEquals($positive, $glob->fnmatch($pattern, $uri), "Pattern and uri should " . ($positive ? "" : "not") . " match"); + $this->assertEquals($positive, $glob->fnmatch($pattern, $uri), + "Pattern and uri should " . ($positive ? "" : "not") . " match"); } /** |