mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Updated unit tests
This commit is contained in:
parent
ea519c66f2
commit
a8a960d10b
|
|
@ -15,24 +15,24 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
/** @var Assets $assets */
|
||||
protected $assets;
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$grav = Fixtures::get('grav');
|
||||
$this->grav = $grav();
|
||||
$this->assets = $this->grav['assets'];
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testAddingAssets()
|
||||
public function testAddingAssets(): void
|
||||
{
|
||||
//test add()
|
||||
$this->assets->add('test.css');
|
||||
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
$array = $this->assets->getCss();
|
||||
|
||||
|
|
@ -57,11 +57,11 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query":""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
$this->assets->add('test.js');
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/test.js"></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/test.js"></script>' . PHP_EOL, $js);
|
||||
|
||||
$array = $this->assets->getJs();
|
||||
|
||||
|
|
@ -85,13 +85,13 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query":""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
//test addCss(). Test adding asset to a separate group
|
||||
$this->assets->reset();
|
||||
$this->assets->addCSS('test.css');
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
$array = $this->assets->getCss();
|
||||
/** @var Assets\BaseAsset $item */
|
||||
|
|
@ -115,13 +115,13 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query":""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
//test addCss(). Testing with remote URL
|
||||
$this->assets->reset();
|
||||
$this->assets->addCSS('http://www.somesite.com/test.css');
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="http://www.somesite.com/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="http://www.somesite.com/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
$array = $this->assets->getCss();
|
||||
/** @var Assets\BaseAsset $item */
|
||||
|
|
@ -144,19 +144,19 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query":""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
//test addCss() adding asset to a separate group, and with an alternate rel attribute
|
||||
$this->assets->reset();
|
||||
$this->assets->addCSS('test.css', ['group' => 'alternate', 'rel' => 'alternate']);
|
||||
$css = $this->assets->css('alternate');
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="alternate">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="alternate">' . PHP_EOL, $css);
|
||||
|
||||
//test addJs()
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('test.js');
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/test.js"></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/test.js"></script>' . PHP_EOL, $js);
|
||||
|
||||
$array = $this->assets->getJs();
|
||||
/** @var Assets\BaseAsset $item */
|
||||
|
|
@ -177,15 +177,15 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query":""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
//Test CSS Groups
|
||||
$this->assets->reset();
|
||||
$this->assets->addCSS('test.css', ['group' => 'footer']);
|
||||
$css = $this->assets->css();
|
||||
$this->assertEmpty($css);
|
||||
self::assertEmpty($css);
|
||||
$css = $this->assets->css('footer');
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
$array = $this->assets->getCss();
|
||||
/** @var Assets\BaseAsset $item */
|
||||
|
|
@ -210,15 +210,15 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
}
|
||||
}
|
||||
';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
//Test JS Groups
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('test.js', ['group' => 'footer']);
|
||||
$js = $this->assets->js();
|
||||
$this->assertEmpty($js);
|
||||
self::assertEmpty($js);
|
||||
$js = $this->assets->js('footer');
|
||||
$this->assertSame('<script src="/test.js"></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/test.js"></script>' . PHP_EOL, $js);
|
||||
|
||||
$array = $this->assets->getJs();
|
||||
/** @var Assets\BaseAsset $item */
|
||||
|
|
@ -239,13 +239,13 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query": ""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
//Test async / defer
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('test.js', ['loading' => 'async']);
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/test.js" async></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/test.js" async></script>' . PHP_EOL, $js);
|
||||
|
||||
$array = $this->assets->getJs();
|
||||
/** @var Assets\BaseAsset $item */
|
||||
|
|
@ -268,12 +268,12 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query": ""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('test.js', ['loading' => 'defer']);
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/test.js" defer></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/test.js" defer></script>' . PHP_EOL, $js);
|
||||
|
||||
$array = $this->assets->getJs();
|
||||
/** @var Assets\BaseAsset $item */
|
||||
|
|
@ -296,58 +296,58 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query": ""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
//Test inline
|
||||
$this->assets->reset();
|
||||
$this->assets->setJsPipeline(true);
|
||||
$this->assets->addJs('/system/assets/jquery/jquery-3.x.min.js');
|
||||
$js = $this->assets->js('head', ['loading' => 'inline']);
|
||||
$this->assertStringContainsString('"jquery",[],function()', $js);
|
||||
self::assertStringContainsString('"jquery",[],function()', $js);
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->setCssPipeline(true);
|
||||
$this->assets->addCss('/system/assets/debugger/phpdebugbar.css');
|
||||
$css = $this->assets->css('head', ['loading' => 'inline']);
|
||||
$this->assertStringContainsString('div.phpdebugbar', $css);
|
||||
self::assertStringContainsString('div.phpdebugbar', $css);
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->setCssPipeline(true);
|
||||
$this->assets->addCss('https://fonts.googleapis.com/css?family=Roboto');
|
||||
$css = $this->assets->css('head', ['loading' => 'inline']);
|
||||
$this->assertStringContainsString('font-family:\'Roboto\';', $css);
|
||||
self::assertStringContainsString('font-family:\'Roboto\';', $css);
|
||||
|
||||
//Test adding media queries
|
||||
$this->assets->reset();
|
||||
$this->assets->add('test.css', ['media' => 'only screen and (min-width: 640px)']);
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="stylesheet" media="only screen and (min-width: 640px)">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="stylesheet" media="only screen and (min-width: 640px)">' . PHP_EOL, $css);
|
||||
}
|
||||
|
||||
public function testAddingAssetPropertiesWithArray()
|
||||
public function testAddingAssetPropertiesWithArray(): void
|
||||
{
|
||||
//Test adding assets with object to define properties
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('test.js', ['loading' => 'async']);
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/test.js" async></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/test.js" async></script>' . PHP_EOL, $js);
|
||||
$this->assets->reset();
|
||||
}
|
||||
|
||||
public function testAddingJSAssetPropertiesWithArrayFromCollection()
|
||||
public function testAddingJSAssetPropertiesWithArrayFromCollection(): void
|
||||
{
|
||||
//Test adding properties with array
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('jquery', ['loading' => 'async']);
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" async></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" async></script>' . PHP_EOL, $js);
|
||||
|
||||
//Test priority too
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('jquery', ['loading' => 'async', 'priority' => 1]);
|
||||
$this->assets->addJs('test.js', ['loading' => 'async', 'priority' => 2]);
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/test.js" async></script>' . PHP_EOL .
|
||||
self::assertSame('<script src="/test.js" async></script>' . PHP_EOL .
|
||||
'<script src="/system/assets/jquery/jquery-2.x.min.js" async></script>' . PHP_EOL, $js);
|
||||
|
||||
//Test multiple groups
|
||||
|
|
@ -355,9 +355,9 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
$this->assets->addJs('jquery', ['loading' => 'async', 'priority' => 1, 'group' => 'footer']);
|
||||
$this->assets->addJs('test.js', ['loading' => 'async', 'priority' => 2]);
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/test.js" async></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/test.js" async></script>' . PHP_EOL, $js);
|
||||
$js = $this->assets->js('footer');
|
||||
$this->assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" async></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" async></script>' . PHP_EOL, $js);
|
||||
|
||||
//Test adding array of assets
|
||||
//Test priority too
|
||||
|
|
@ -365,18 +365,18 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
$this->assets->addJs(['jquery', 'test.js'], ['loading' => 'async']);
|
||||
$js = $this->assets->js();
|
||||
|
||||
$this->assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" async></script>' . PHP_EOL .
|
||||
self::assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" async></script>' . PHP_EOL .
|
||||
'<script src="/test.js" async></script>' . PHP_EOL, $js);
|
||||
}
|
||||
|
||||
public function testAddingLegacyFormat()
|
||||
public function testAddingLegacyFormat(): void
|
||||
{
|
||||
// regular CSS add
|
||||
//test addCss(). Test adding asset to a separate group
|
||||
$this->assets->reset();
|
||||
$this->assets->addCSS('test.css', 15, true, 'bottom', 'async');
|
||||
$css = $this->assets->css('bottom');
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="stylesheet" async>' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="stylesheet" async>' . PHP_EOL, $css);
|
||||
|
||||
$array = $this->assets->getCss();
|
||||
/** @var Assets\BaseAsset $item */
|
||||
|
|
@ -401,12 +401,12 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query":""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('test.js', 15, false, 'defer', 'bottom');
|
||||
$js = $this->assets->js('bottom');
|
||||
$this->assertSame('<script src="/test.js" defer></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/test.js" defer></script>' . PHP_EOL, $js);
|
||||
|
||||
$array = $this->assets->getJs();
|
||||
/** @var Assets\BaseAsset $item */
|
||||
|
|
@ -429,21 +429,21 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query": ""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->addInlineCss('body { color: black }', 15, 'bottom');
|
||||
$css = $this->assets->css('bottom');
|
||||
$this->assertSame('<style>' . PHP_EOL . 'body { color: black }' . PHP_EOL . '</style>' . PHP_EOL, $css);
|
||||
self::assertSame('<style>' . PHP_EOL . 'body { color: black }' . PHP_EOL . '</style>' . PHP_EOL, $css);
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->addInlineJs('alert("test")', 15, 'bottom', ['id' => 'foo']);
|
||||
$js = $this->assets->js('bottom');
|
||||
$this->assertSame('<script id="foo">' . PHP_EOL . 'alert("test")' . PHP_EOL . '</script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script id="foo">' . PHP_EOL . 'alert("test")' . PHP_EOL . '</script>' . PHP_EOL, $js);
|
||||
}
|
||||
|
||||
public function testAddingCSSAssetPropertiesWithArrayFromCollection()
|
||||
public function testAddingCSSAssetPropertiesWithArrayFromCollection(): void
|
||||
{
|
||||
$this->assets->registerCollection('test', ['/system/assets/whoops.css']);
|
||||
|
||||
|
|
@ -452,7 +452,7 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
$this->assets->addCss('test', ['priority' => 1]);
|
||||
$this->assets->addCss('test.css', ['priority' => 2]);
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL .
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL .
|
||||
'<link href="/system/assets/whoops.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
//Test multiple groups
|
||||
|
|
@ -460,27 +460,27 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
$this->assets->addCss('test', ['priority' => 1, 'group' => 'footer']);
|
||||
$this->assets->addCss('test.css', ['priority' => 2]);
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
$css = $this->assets->css('footer');
|
||||
$this->assertSame('<link href="/system/assets/whoops.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/system/assets/whoops.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
//Test adding array of assets
|
||||
//Test priority too
|
||||
$this->assets->reset();
|
||||
$this->assets->addCss(['test', 'test.css'], ['loading' => 'async']);
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/system/assets/whoops.css" type="text/css" rel="stylesheet" async>' . PHP_EOL .
|
||||
self::assertSame('<link href="/system/assets/whoops.css" type="text/css" rel="stylesheet" async>' . PHP_EOL .
|
||||
'<link href="/test.css" type="text/css" rel="stylesheet" async>' . PHP_EOL, $css);
|
||||
}
|
||||
|
||||
public function testPriorityOfAssets()
|
||||
public function testPriorityOfAssets(): void
|
||||
{
|
||||
$this->assets->reset();
|
||||
$this->assets->add('test.css');
|
||||
$this->assets->add('test-after.css');
|
||||
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL .
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL .
|
||||
'<link href="/test-after.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
//----------------
|
||||
|
|
@ -489,7 +489,7 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
$this->assets->add('test.css', 2);
|
||||
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL .
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL .
|
||||
'<link href="/test-after.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
//----------------
|
||||
|
|
@ -499,12 +499,12 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
$this->assets->add('test-before.css', 3);
|
||||
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test-before.css" type="text/css" rel="stylesheet">' . PHP_EOL .
|
||||
self::assertSame('<link href="/test-before.css" type="text/css" rel="stylesheet">' . PHP_EOL .
|
||||
'<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL .
|
||||
'<link href="/test-after.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
}
|
||||
|
||||
public function testPipeline()
|
||||
public function testPipeline(): void
|
||||
{
|
||||
$this->assets->reset();
|
||||
|
||||
|
|
@ -512,15 +512,15 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
$this->assets->add('test.css', null, true);
|
||||
$this->assets->setCssPipeline(true);
|
||||
$css = $this->assets->css();
|
||||
$this->assertRegExp('#<link href=\"\/assets\/(.*).css\" type=\"text\/css\" rel=\"stylesheet\">#', $css);
|
||||
self::assertRegExp('#<link href=\"\/assets\/(.*).css\" type=\"text\/css\" rel=\"stylesheet\">#', $css);
|
||||
|
||||
//Add a core Grav CSS file, which is found. Pipeline will now return a file
|
||||
$this->assets->add('/system/assets/debugger/phpdebugbar', null, true);
|
||||
$css = $this->assets->css();
|
||||
$this->assertRegExp('#<link href=\"\/assets\/(.*).css\" type=\"text\/css\" rel=\"stylesheet\">#', $css);
|
||||
self::assertRegExp('#<link href=\"\/assets\/(.*).css\" type=\"text\/css\" rel=\"stylesheet\">#', $css);
|
||||
}
|
||||
|
||||
public function testPipelineWithTimestamp()
|
||||
public function testPipelineWithTimestamp(): void
|
||||
{
|
||||
$this->assets->reset();
|
||||
$this->assets->setTimestamp('foo');
|
||||
|
|
@ -529,28 +529,28 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
//Add a core Grav CSS file, which is found. Pipeline will now return a file
|
||||
$this->assets->add('/system/assets/debugger.css', null, true);
|
||||
$css = $this->assets->css();
|
||||
$this->assertRegExp('#<link href=\"\/assets\/(.*).css\?foo\" type=\"text\/css\" rel=\"stylesheet\">#', $css);
|
||||
self::assertRegExp('#<link href=\"\/assets\/(.*).css\?foo\" type=\"text\/css\" rel=\"stylesheet\">#', $css);
|
||||
}
|
||||
|
||||
public function testInline()
|
||||
public function testInline(): void
|
||||
{
|
||||
$this->assets->reset();
|
||||
|
||||
//File not existing. Pipeline searches for that file without reaching it. Output is empty.
|
||||
$this->assets->add('test.css', ['loading' => 'inline']);
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame("<style>\n\n</style>\n", $css);
|
||||
self::assertSame("<style>\n\n</style>\n", $css);
|
||||
|
||||
$this->assets->reset();
|
||||
//Add a core Grav CSS file, which is found. Pipeline will now return its content.
|
||||
$this->assets->addCss('https://fonts.googleapis.com/css?family=Roboto', ['loading' => 'inline']);
|
||||
$this->assets->addCss('/system/assets/debugger/phpdebugbar.css', ['loading' => 'inline']);
|
||||
$css = $this->assets->css();
|
||||
$this->assertStringContainsString('font-family: \'Roboto\';', $css);
|
||||
$this->assertStringContainsString('div.phpdebugbar-header', $css);
|
||||
self::assertStringContainsString('font-family: \'Roboto\';', $css);
|
||||
self::assertStringContainsString('div.phpdebugbar-header', $css);
|
||||
}
|
||||
|
||||
public function testInlinePipeline()
|
||||
public function testInlinePipeline(): void
|
||||
{
|
||||
$this->assets->reset();
|
||||
$this->assets->setCssPipeline(true);
|
||||
|
|
@ -558,216 +558,216 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
//File not existing. Pipeline searches for that file without reaching it. Output is empty.
|
||||
$this->assets->add('test.css');
|
||||
$css = $this->assets->css('head', ['loading' => 'inline']);
|
||||
$this->assertSame("<style>\n\n</style>\n", $css);
|
||||
self::assertSame("<style>\n\n</style>\n", $css);
|
||||
|
||||
//Add a core Grav CSS file, which is found. Pipeline will now return its content.
|
||||
$this->assets->addCss('https://fonts.googleapis.com/css?family=Roboto', null, true);
|
||||
$this->assets->add('/system/assets/debugger/phpdebugbar.css', null, true);
|
||||
$css = $this->assets->css('head', ['loading' => 'inline']);
|
||||
$this->assertStringContainsString('font-family:\'Roboto\';', $css);
|
||||
$this->assertStringContainsString('div.phpdebugbar', $css);
|
||||
self::assertStringContainsString('font-family:\'Roboto\';', $css);
|
||||
self::assertStringContainsString('div.phpdebugbar', $css);
|
||||
}
|
||||
|
||||
public function testAddAsyncJs()
|
||||
public function testAddAsyncJs(): void
|
||||
{
|
||||
$this->assets->reset();
|
||||
$this->assets->addAsyncJs('jquery');
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" async></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" async></script>' . PHP_EOL, $js);
|
||||
}
|
||||
|
||||
public function testAddDeferJs()
|
||||
public function testAddDeferJs(): void
|
||||
{
|
||||
$this->assets->reset();
|
||||
$this->assets->addDeferJs('jquery');
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" defer></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" defer></script>' . PHP_EOL, $js);
|
||||
}
|
||||
|
||||
public function testTimestamps()
|
||||
public function testTimestamps(): void
|
||||
{
|
||||
// local CSS nothing extra
|
||||
$this->assets->reset();
|
||||
$this->assets->setTimestamp('foo');
|
||||
$this->assets->addCSS('test.css');
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test.css?foo" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/test.css?foo" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
// local CSS already with param
|
||||
$this->assets->reset();
|
||||
$this->assets->setTimestamp('foo');
|
||||
$this->assets->addCSS('test.css?bar');
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test.css?bar&foo" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/test.css?bar&foo" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
// external CSS already
|
||||
$this->assets->reset();
|
||||
$this->assets->setTimestamp('foo');
|
||||
$this->assets->addCSS('http://somesite.com/test.css');
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="http://somesite.com/test.css?foo" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="http://somesite.com/test.css?foo" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
// external CSS already with param
|
||||
$this->assets->reset();
|
||||
$this->assets->setTimestamp('foo');
|
||||
$this->assets->addCSS('http://somesite.com/test.css?bar');
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="http://somesite.com/test.css?bar&foo" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="http://somesite.com/test.css?bar&foo" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
// local JS nothing extra
|
||||
$this->assets->reset();
|
||||
$this->assets->setTimestamp('foo');
|
||||
$this->assets->addJs('test.js');
|
||||
$css = $this->assets->js();
|
||||
$this->assertSame('<script src="/test.js?foo"></script>' . PHP_EOL, $css);
|
||||
self::assertSame('<script src="/test.js?foo"></script>' . PHP_EOL, $css);
|
||||
|
||||
// local JS already with param
|
||||
$this->assets->reset();
|
||||
$this->assets->setTimestamp('foo');
|
||||
$this->assets->addJs('test.js?bar');
|
||||
$css = $this->assets->js();
|
||||
$this->assertSame('<script src="/test.js?bar&foo"></script>' . PHP_EOL, $css);
|
||||
self::assertSame('<script src="/test.js?bar&foo"></script>' . PHP_EOL, $css);
|
||||
|
||||
// external JS already
|
||||
$this->assets->reset();
|
||||
$this->assets->setTimestamp('foo');
|
||||
$this->assets->addJs('http://somesite.com/test.js');
|
||||
$css = $this->assets->js();
|
||||
$this->assertSame('<script src="http://somesite.com/test.js?foo"></script>' . PHP_EOL, $css);
|
||||
self::assertSame('<script src="http://somesite.com/test.js?foo"></script>' . PHP_EOL, $css);
|
||||
|
||||
// external JS already with param
|
||||
$this->assets->reset();
|
||||
$this->assets->setTimestamp('foo');
|
||||
$this->assets->addJs('http://somesite.com/test.js?bar');
|
||||
$css = $this->assets->js();
|
||||
$this->assertSame('<script src="http://somesite.com/test.js?bar&foo"></script>' . PHP_EOL, $css);
|
||||
self::assertSame('<script src="http://somesite.com/test.js?bar&foo"></script>' . PHP_EOL, $css);
|
||||
}
|
||||
|
||||
public function testAddInlineCss()
|
||||
public function testAddInlineCss(): void
|
||||
{
|
||||
$this->assets->reset();
|
||||
$this->assets->addInlineCss('body { color: black }');
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<style>' . PHP_EOL . 'body { color: black }' . PHP_EOL . '</style>' . PHP_EOL, $css);
|
||||
self::assertSame('<style>' . PHP_EOL . 'body { color: black }' . PHP_EOL . '</style>' . PHP_EOL, $css);
|
||||
}
|
||||
|
||||
public function testAddInlineJs()
|
||||
public function testAddInlineJs(): void
|
||||
{
|
||||
$this->assets->reset();
|
||||
$this->assets->addInlineJs('alert("test")');
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script>' . PHP_EOL . 'alert("test")' . PHP_EOL . '</script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script>' . PHP_EOL . 'alert("test")' . PHP_EOL . '</script>' . PHP_EOL, $js);
|
||||
}
|
||||
|
||||
public function testGetCollections()
|
||||
public function testGetCollections(): void
|
||||
{
|
||||
$this->assertIsArray($this->assets->getCollections());
|
||||
$this->assertContains('jquery', array_keys($this->assets->getCollections()));
|
||||
$this->assertContains('system://assets/jquery/jquery-2.x.min.js', $this->assets->getCollections());
|
||||
self::assertIsArray($this->assets->getCollections());
|
||||
self::assertContains('jquery', array_keys($this->assets->getCollections()));
|
||||
self::assertContains('system://assets/jquery/jquery-2.x.min.js', $this->assets->getCollections());
|
||||
}
|
||||
|
||||
public function testExists()
|
||||
public function testExists(): void
|
||||
{
|
||||
$this->assertTrue($this->assets->exists('jquery'));
|
||||
$this->assertFalse($this->assets->exists('another-unexisting-library'));
|
||||
self::assertTrue($this->assets->exists('jquery'));
|
||||
self::assertFalse($this->assets->exists('another-unexisting-library'));
|
||||
}
|
||||
|
||||
public function testRegisterCollection()
|
||||
public function testRegisterCollection(): void
|
||||
{
|
||||
$this->assets->registerCollection('debugger', ['/system/assets/debugger.css']);
|
||||
$this->assertTrue($this->assets->exists('debugger'));
|
||||
$this->assertContains('debugger', array_keys($this->assets->getCollections()));
|
||||
self::assertTrue($this->assets->exists('debugger'));
|
||||
self::assertContains('debugger', array_keys($this->assets->getCollections()));
|
||||
}
|
||||
|
||||
public function testReset()
|
||||
public function testReset(): void
|
||||
{
|
||||
$this->assets->addInlineJs('alert("test")');
|
||||
$this->assets->reset();
|
||||
$this->assertCount(0, (array) $this->assets->getJs());
|
||||
self::assertCount(0, (array) $this->assets->getJs());
|
||||
|
||||
$this->assets->addAsyncJs('jquery');
|
||||
$this->assets->reset();
|
||||
$this->assertCount(0, (array) $this->assets->getJs());
|
||||
self::assertCount(0, (array) $this->assets->getJs());
|
||||
|
||||
$this->assets->addInlineCss('body { color: black }');
|
||||
$this->assets->reset();
|
||||
$this->assertCount(0, (array) $this->assets->getCss());
|
||||
self::assertCount(0, (array) $this->assets->getCss());
|
||||
|
||||
$this->assets->add('/system/assets/debugger.css', null, true);
|
||||
$this->assets->reset();
|
||||
$this->assertCount(0, (array) $this->assets->getCss());
|
||||
self::assertCount(0, (array) $this->assets->getCss());
|
||||
}
|
||||
|
||||
public function testResetJs()
|
||||
public function testResetJs(): void
|
||||
{
|
||||
$this->assets->addInlineJs('alert("test")');
|
||||
$this->assets->resetJs();
|
||||
$this->assertCount(0, (array) $this->assets->getJs());
|
||||
self::assertCount(0, (array) $this->assets->getJs());
|
||||
|
||||
$this->assets->addAsyncJs('jquery');
|
||||
$this->assets->resetJs();
|
||||
$this->assertCount(0, (array) $this->assets->getJs());
|
||||
self::assertCount(0, (array) $this->assets->getJs());
|
||||
}
|
||||
|
||||
public function testResetCss()
|
||||
public function testResetCss(): void
|
||||
{
|
||||
$this->assets->addInlineCss('body { color: black }');
|
||||
$this->assets->resetCss();
|
||||
$this->assertCount(0, (array) $this->assets->getCss());
|
||||
self::assertCount(0, (array) $this->assets->getCss());
|
||||
|
||||
$this->assets->add('/system/assets/debugger.css', null, true);
|
||||
$this->assets->resetCss();
|
||||
$this->assertCount(0, (array) $this->assets->getCss());
|
||||
self::assertCount(0, (array) $this->assets->getCss());
|
||||
}
|
||||
|
||||
public function testAddDirCss()
|
||||
public function testAddDirCss(): void
|
||||
{
|
||||
$this->assets->addDirCss('/system');
|
||||
|
||||
$this->assertIsArray($this->assets->getCss());
|
||||
$this->assertGreaterThan(0, (array) $this->assets->getCss());
|
||||
$this->assertIsArray($this->assets->getJs());
|
||||
$this->assertCount(0, (array) $this->assets->getJs());
|
||||
self::assertIsArray($this->assets->getCss());
|
||||
self::assertGreaterThan(0, (array) $this->assets->getCss());
|
||||
self::assertIsArray($this->assets->getJs());
|
||||
self::assertCount(0, (array) $this->assets->getJs());
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->addDirCss('/system/assets');
|
||||
|
||||
$this->assertIsArray($this->assets->getCss());
|
||||
$this->assertGreaterThan(0, (array) $this->assets->getCss());
|
||||
$this->assertIsArray($this->assets->getJs());
|
||||
$this->assertCount(0, (array) $this->assets->getJs());
|
||||
self::assertIsArray($this->assets->getCss());
|
||||
self::assertGreaterThan(0, (array) $this->assets->getCss());
|
||||
self::assertIsArray($this->assets->getJs());
|
||||
self::assertCount(0, (array) $this->assets->getJs());
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->addDirJs('/system');
|
||||
|
||||
$this->assertIsArray($this->assets->getCss());
|
||||
$this->assertCount(0, (array) $this->assets->getCss());
|
||||
$this->assertIsArray($this->assets->getJs());
|
||||
$this->assertGreaterThan(0, (array) $this->assets->getJs());
|
||||
self::assertIsArray($this->assets->getCss());
|
||||
self::assertCount(0, (array) $this->assets->getCss());
|
||||
self::assertIsArray($this->assets->getJs());
|
||||
self::assertGreaterThan(0, (array) $this->assets->getJs());
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->addDirJs('/system/assets');
|
||||
|
||||
$this->assertIsArray($this->assets->getCss());
|
||||
$this->assertCount(0, (array) $this->assets->getCss());
|
||||
$this->assertIsArray($this->assets->getJs());
|
||||
$this->assertGreaterThan(0, (array) $this->assets->getJs());
|
||||
self::assertIsArray($this->assets->getCss());
|
||||
self::assertCount(0, (array) $this->assets->getCss());
|
||||
self::assertIsArray($this->assets->getJs());
|
||||
self::assertGreaterThan(0, (array) $this->assets->getJs());
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->addDir('/system/assets');
|
||||
|
||||
$this->assertIsArray($this->assets->getCss());
|
||||
$this->assertGreaterThan(0, (array) $this->assets->getCss());
|
||||
$this->assertIsArray($this->assets->getJs());
|
||||
$this->assertGreaterThan(0, (array) $this->assets->getJs());
|
||||
self::assertIsArray($this->assets->getCss());
|
||||
self::assertGreaterThan(0, (array) $this->assets->getCss());
|
||||
self::assertIsArray($this->assets->getJs());
|
||||
self::assertGreaterThan(0, (array) $this->assets->getJs());
|
||||
|
||||
//Use streams
|
||||
$this->assets->reset();
|
||||
$this->assets->addDir('system://assets');
|
||||
|
||||
$this->assertIsArray($this->assets->getCss());
|
||||
$this->assertGreaterThan(0, (array) $this->assets->getCss());
|
||||
$this->assertIsArray($this->assets->getJs());
|
||||
$this->assertGreaterThan(0, (array) $this->assets->getJs());
|
||||
self::assertIsArray($this->assets->getCss());
|
||||
self::assertGreaterThan(0, (array) $this->assets->getCss());
|
||||
self::assertIsArray($this->assets->getJs());
|
||||
self::assertGreaterThan(0, (array) $this->assets->getJs());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,41 +11,41 @@ class BrowserTest extends \Codeception\TestCase\Test
|
|||
/** @var Grav $grav */
|
||||
protected $grav;
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$grav = Fixtures::get('grav');
|
||||
$this->grav = $grav();
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testGetBrowser()
|
||||
public function testGetBrowser(): void
|
||||
{
|
||||
/* Already covered by PhpUserAgent tests */
|
||||
}
|
||||
|
||||
public function testGetPlatform()
|
||||
public function testGetPlatform(): void
|
||||
{
|
||||
/* Already covered by PhpUserAgent tests */
|
||||
}
|
||||
|
||||
public function testGetLongVersion()
|
||||
public function testGetLongVersion(): void
|
||||
{
|
||||
/* Already covered by PhpUserAgent tests */
|
||||
}
|
||||
|
||||
public function testGetVersion()
|
||||
public function testGetVersion(): void
|
||||
{
|
||||
/* Already covered by PhpUserAgent tests */
|
||||
}
|
||||
|
||||
public function testIsHuman()
|
||||
public function testIsHuman(): void
|
||||
{
|
||||
//Already Partially covered by PhpUserAgent tests
|
||||
|
||||
//Make sure it recognizes the test as not human
|
||||
$this->assertFalse($this->grav['browser']->isHuman());
|
||||
self::assertFalse($this->grav['browser']->isHuman());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,27 +5,27 @@ use Grav\Common\Composer;
|
|||
|
||||
class ComposerTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testGetComposerLocation()
|
||||
public function testGetComposerLocation(): void
|
||||
{
|
||||
$composerLocation = Composer::getComposerLocation();
|
||||
$this->assertIsString($composerLocation);
|
||||
$this->assertSame('/', $composerLocation[0]);
|
||||
self::assertIsString($composerLocation);
|
||||
self::assertSame('/', $composerLocation[0]);
|
||||
}
|
||||
|
||||
public function testGetComposerExecutor()
|
||||
public function testGetComposerExecutor(): void
|
||||
{
|
||||
$composerExecutor = Composer::getComposerExecutor();
|
||||
$this->assertIsString($composerExecutor);
|
||||
$this->assertSame('/', $composerExecutor[0]);
|
||||
$this->assertNotNull(strstr($composerExecutor, 'php'));
|
||||
$this->assertNotNull(strstr($composerExecutor, 'composer'));
|
||||
self::assertIsString($composerExecutor);
|
||||
self::assertSame('/', $composerExecutor[0]);
|
||||
self::assertNotNull(strstr($composerExecutor, 'php'));
|
||||
self::assertNotNull(strstr($composerExecutor, 'composer'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class BlueprintTest extends \Codeception\TestCase\Test
|
|||
{
|
||||
/**
|
||||
*/
|
||||
public function testValidateStrict()
|
||||
public function testValidateStrict(): void
|
||||
{
|
||||
$blueprint = $this->loadBlueprint('strict');
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ class BlueprintTest extends \Codeception\TestCase\Test
|
|||
/**
|
||||
* @depends testValidateStrict
|
||||
*/
|
||||
public function testValidateStrictRequired()
|
||||
public function testValidateStrictRequired(): void
|
||||
{
|
||||
$blueprint = $this->loadBlueprint('strict');
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ class BlueprintTest extends \Codeception\TestCase\Test
|
|||
/**
|
||||
* @depends testValidateStrict
|
||||
*/
|
||||
public function testValidateStrictExtra()
|
||||
public function testValidateStrictExtra(): void
|
||||
{
|
||||
$blueprint = $this->loadBlueprint('strict');
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ class BlueprintTest extends \Codeception\TestCase\Test
|
|||
/**
|
||||
* @depends testValidateStrict
|
||||
*/
|
||||
public function testValidateStrictExtraException()
|
||||
public function testValidateStrictExtraException(): void
|
||||
{
|
||||
$blueprint = $this->loadBlueprint('strict');
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ class BlueprintTest extends \Codeception\TestCase\Test
|
|||
* @param string $filename
|
||||
* @return Blueprint
|
||||
*/
|
||||
protected function loadBlueprint($filename)
|
||||
protected function loadBlueprint($filename): Blueprint
|
||||
{
|
||||
$blueprint = new Blueprint('strict');
|
||||
$blueprint->setContext(dirname(__DIR__, 3). '/data/blueprints');
|
||||
|
|
|
|||
|
|
@ -7,17 +7,25 @@ use Grav\Common\GPM\GPM;
|
|||
define('EXCEPTION_BAD_FORMAT', 1);
|
||||
define('EXCEPTION_INCOMPATIBLE_VERSIONS', 2);
|
||||
|
||||
/**
|
||||
* Class GpmStub
|
||||
*/
|
||||
class GpmStub extends GPM
|
||||
{
|
||||
/** @var array */
|
||||
public $data;
|
||||
|
||||
public function findPackage($packageName, $ignore_exception = false)
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function findPackage($search, $ignore_exception = false)
|
||||
{
|
||||
if (isset($this->data[$packageName])) {
|
||||
return $this->data[$packageName];
|
||||
}
|
||||
return $this->data[$search] ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function findPackages($searches = [])
|
||||
{
|
||||
return $this->data;
|
||||
|
|
@ -35,17 +43,17 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
/** @var GpmStub */
|
||||
protected $gpm;
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$this->grav = Fixtures::get('grav');
|
||||
$this->gpm = new GpmStub();
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testCalculateMergedDependenciesOfPackages()
|
||||
public function testCalculateMergedDependenciesOfPackages(): void
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// First working example
|
||||
|
|
@ -53,22 +61,22 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
$this->gpm->data = [
|
||||
'admin' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "grav", "version" => ">=1.0.10"],
|
||||
["name" => "form", "version" => "~2.0"],
|
||||
["name" => "login", "version" => ">=2.0"],
|
||||
["name" => "errors", "version" => "*"],
|
||||
["name" => "problems"],
|
||||
['name' => 'grav', 'version' => '>=1.0.10'],
|
||||
['name' => 'form', 'version' => '~2.0'],
|
||||
['name' => 'login', 'version' => '>=2.0'],
|
||||
['name' => 'errors', 'version' => '*'],
|
||||
['name' => 'problems'],
|
||||
]
|
||||
],
|
||||
'test' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "errors", "version" => ">=1.0"]
|
||||
['name' => 'errors', 'version' => '>=1.0']
|
||||
]
|
||||
],
|
||||
'grav',
|
||||
'form' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "errors", "version" => ">=3.2"]
|
||||
['name' => 'errors', 'version' => '>=3.2']
|
||||
]
|
||||
]
|
||||
|
||||
|
|
@ -79,12 +87,12 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
|
||||
$dependencies = $this->gpm->calculateMergedDependenciesOfPackages($packages);
|
||||
|
||||
$this->assertIsArray($dependencies);
|
||||
$this->assertCount(5, $dependencies);
|
||||
self::assertIsArray($dependencies);
|
||||
self::assertCount(5, $dependencies);
|
||||
|
||||
$this->assertSame('>=1.0.10', $dependencies['grav']);
|
||||
$this->assertArrayHasKey('errors', $dependencies);
|
||||
$this->assertArrayHasKey('problems', $dependencies);
|
||||
self::assertSame('>=1.0.10', $dependencies['grav']);
|
||||
self::assertArrayHasKey('errors', $dependencies);
|
||||
self::assertArrayHasKey('problems', $dependencies);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Second working example
|
||||
|
|
@ -92,9 +100,9 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
$packages = ['admin', 'form'];
|
||||
|
||||
$dependencies = $this->gpm->calculateMergedDependenciesOfPackages($packages);
|
||||
$this->assertIsArray($dependencies);
|
||||
$this->assertCount(5, $dependencies);
|
||||
$this->assertSame('>=3.2', $dependencies['errors']);
|
||||
self::assertIsArray($dependencies);
|
||||
self::assertCount(5, $dependencies);
|
||||
self::assertSame('>=3.2', $dependencies['errors']);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Third working example
|
||||
|
|
@ -103,17 +111,17 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
|
||||
'admin' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "errors", "version" => ">=4.0"],
|
||||
['name' => 'errors', 'version' => '>=4.0'],
|
||||
]
|
||||
],
|
||||
'test' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "errors", "version" => ">=1.0"]
|
||||
['name' => 'errors', 'version' => '>=1.0']
|
||||
]
|
||||
],
|
||||
'another' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "errors", "version" => ">=3.2"]
|
||||
['name' => 'errors', 'version' => '>=3.2']
|
||||
]
|
||||
]
|
||||
|
||||
|
|
@ -123,9 +131,9 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
|
||||
|
||||
$dependencies = $this->gpm->calculateMergedDependenciesOfPackages($packages);
|
||||
$this->assertIsArray($dependencies);
|
||||
$this->assertCount(1, $dependencies);
|
||||
$this->assertSame('>=4.0', $dependencies['errors']);
|
||||
self::assertIsArray($dependencies);
|
||||
self::assertCount(1, $dependencies);
|
||||
self::assertSame('>=4.0', $dependencies['errors']);
|
||||
|
||||
|
||||
|
||||
|
|
@ -135,23 +143,23 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
$this->gpm->data = [
|
||||
'admin' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "package1", "version" => ">=4.0.0-rc1"],
|
||||
["name" => "package4", "version" => ">=3.2.0"],
|
||||
['name' => 'package1', 'version' => '>=4.0.0-rc1'],
|
||||
['name' => 'package4', 'version' => '>=3.2.0'],
|
||||
]
|
||||
],
|
||||
'test' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "package1", "version" => ">=4.0.0-rc2"],
|
||||
["name" => "package2", "version" => ">=3.2.0-alpha"],
|
||||
["name" => "package3", "version" => ">=3.2.0-alpha.2"],
|
||||
["name" => "package4", "version" => ">=3.2.0-alpha"],
|
||||
['name' => 'package1', 'version' => '>=4.0.0-rc2'],
|
||||
['name' => 'package2', 'version' => '>=3.2.0-alpha'],
|
||||
['name' => 'package3', 'version' => '>=3.2.0-alpha.2'],
|
||||
['name' => 'package4', 'version' => '>=3.2.0-alpha'],
|
||||
]
|
||||
],
|
||||
'another' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "package2", "version" => ">=3.2.0-beta.11"],
|
||||
["name" => "package3", "version" => ">=3.2.0-alpha.1"],
|
||||
["name" => "package4", "version" => ">=3.2.0-beta"],
|
||||
['name' => 'package2', 'version' => '>=3.2.0-beta.11'],
|
||||
['name' => 'package3', 'version' => '>=3.2.0-alpha.1'],
|
||||
['name' => 'package4', 'version' => '>=3.2.0-beta'],
|
||||
]
|
||||
]
|
||||
];
|
||||
|
|
@ -160,10 +168,10 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
|
||||
|
||||
$dependencies = $this->gpm->calculateMergedDependenciesOfPackages($packages);
|
||||
$this->assertSame('>=4.0.0-rc2', $dependencies['package1']);
|
||||
$this->assertSame('>=3.2.0-beta.11', $dependencies['package2']);
|
||||
$this->assertSame('>=3.2.0-alpha.2', $dependencies['package3']);
|
||||
$this->assertSame('>=3.2.0', $dependencies['package4']);
|
||||
self::assertSame('>=4.0.0-rc2', $dependencies['package1']);
|
||||
self::assertSame('>=3.2.0-beta.11', $dependencies['package2']);
|
||||
self::assertSame('>=3.2.0-alpha.2', $dependencies['package3']);
|
||||
self::assertSame('>=3.2.0', $dependencies['package4']);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -173,12 +181,12 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
|
||||
'admin' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "errors", "version" => ">=4.0"],
|
||||
['name' => 'errors', 'version' => '>=4.0'],
|
||||
]
|
||||
],
|
||||
'test' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "errors", "version" => ">="]
|
||||
['name' => 'errors', 'version' => '>=']
|
||||
]
|
||||
],
|
||||
|
||||
|
|
@ -188,10 +196,10 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
|
||||
try {
|
||||
$this->gpm->calculateMergedDependenciesOfPackages($packages);
|
||||
$this->fail("Expected Exception not thrown");
|
||||
self::fail('Expected Exception not thrown');
|
||||
} catch (Exception $e) {
|
||||
$this->assertEquals(EXCEPTION_BAD_FORMAT, $e->getCode());
|
||||
$this->assertStringStartsWith("Bad format for version of dependency", $e->getMessage());
|
||||
self::assertEquals(EXCEPTION_BAD_FORMAT, $e->getCode());
|
||||
self::assertStringStartsWith('Bad format for version of dependency', $e->getMessage());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -200,12 +208,12 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
$this->gpm->data = [
|
||||
'admin' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "errors", "version" => "~4.0"],
|
||||
['name' => 'errors', 'version' => '~4.0'],
|
||||
]
|
||||
],
|
||||
'test' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "errors", "version" => "~3.0"]
|
||||
['name' => 'errors', 'version' => '~3.0']
|
||||
]
|
||||
],
|
||||
];
|
||||
|
|
@ -214,10 +222,10 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
|
||||
try {
|
||||
$this->gpm->calculateMergedDependenciesOfPackages($packages);
|
||||
$this->fail("Expected Exception not thrown");
|
||||
self::fail('Expected Exception not thrown');
|
||||
} catch (Exception $e) {
|
||||
$this->assertEquals(EXCEPTION_INCOMPATIBLE_VERSIONS, $e->getCode());
|
||||
$this->assertStringEndsWith("required in two incompatible versions", $e->getMessage());
|
||||
self::assertEquals(EXCEPTION_INCOMPATIBLE_VERSIONS, $e->getCode());
|
||||
self::assertStringEndsWith('required in two incompatible versions', $e->getMessage());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -226,22 +234,22 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
$this->gpm->data = [
|
||||
'admin' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "grav", "version" => ">=1.0.10"],
|
||||
["name" => "form", "version" => "~2.0"],
|
||||
["name" => "login", "version" => ">=2.0"],
|
||||
["name" => "errors", "version" => "*"],
|
||||
["name" => "problems"],
|
||||
['name' => 'grav', 'version' => '>=1.0.10'],
|
||||
['name' => 'form', 'version' => '~2.0'],
|
||||
['name' => 'login', 'version' => '>=2.0'],
|
||||
['name' => 'errors', 'version' => '*'],
|
||||
['name' => 'problems'],
|
||||
]
|
||||
],
|
||||
'login' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "antimatter", "version" => ">=1.0"]
|
||||
['name' => 'antimatter', 'version' => '>=1.0']
|
||||
]
|
||||
],
|
||||
'grav',
|
||||
'antimatter' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "something", "version" => ">=3.2"]
|
||||
['name' => 'something', 'version' => '>=3.2']
|
||||
]
|
||||
]
|
||||
|
||||
|
|
@ -252,71 +260,70 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
|
||||
$dependencies = $this->gpm->calculateMergedDependenciesOfPackages($packages);
|
||||
|
||||
$this->assertIsArray($dependencies);
|
||||
$this->assertCount(7, $dependencies);
|
||||
self::assertIsArray($dependencies);
|
||||
self::assertCount(7, $dependencies);
|
||||
|
||||
$this->assertSame('>=1.0.10', $dependencies['grav']);
|
||||
$this->assertArrayHasKey('errors', $dependencies);
|
||||
$this->assertArrayHasKey('problems', $dependencies);
|
||||
$this->assertArrayHasKey('antimatter', $dependencies);
|
||||
$this->assertArrayHasKey('something', $dependencies);
|
||||
$this->assertSame('>=3.2', $dependencies['something']);
|
||||
self::assertSame('>=1.0.10', $dependencies['grav']);
|
||||
self::assertArrayHasKey('errors', $dependencies);
|
||||
self::assertArrayHasKey('problems', $dependencies);
|
||||
self::assertArrayHasKey('antimatter', $dependencies);
|
||||
self::assertArrayHasKey('something', $dependencies);
|
||||
self::assertSame('>=3.2', $dependencies['something']);
|
||||
}
|
||||
|
||||
public function testVersionFormatIsNextSignificantRelease()
|
||||
public function testVersionFormatIsNextSignificantRelease(): void
|
||||
{
|
||||
$this->assertFalse($this->gpm->versionFormatIsNextSignificantRelease('>=1.0'));
|
||||
$this->assertFalse($this->gpm->versionFormatIsNextSignificantRelease('>=2.3.4'));
|
||||
$this->assertFalse($this->gpm->versionFormatIsNextSignificantRelease('>=2.3.x'));
|
||||
$this->assertFalse($this->gpm->versionFormatIsNextSignificantRelease('1.0'));
|
||||
$this->assertTrue($this->gpm->versionFormatIsNextSignificantRelease('~2.3.x'));
|
||||
$this->assertTrue($this->gpm->versionFormatIsNextSignificantRelease('~2.0'));
|
||||
self::assertFalse($this->gpm->versionFormatIsNextSignificantRelease('>=1.0'));
|
||||
self::assertFalse($this->gpm->versionFormatIsNextSignificantRelease('>=2.3.4'));
|
||||
self::assertFalse($this->gpm->versionFormatIsNextSignificantRelease('>=2.3.x'));
|
||||
self::assertFalse($this->gpm->versionFormatIsNextSignificantRelease('1.0'));
|
||||
self::assertTrue($this->gpm->versionFormatIsNextSignificantRelease('~2.3.x'));
|
||||
self::assertTrue($this->gpm->versionFormatIsNextSignificantRelease('~2.0'));
|
||||
}
|
||||
|
||||
public function testVersionFormatIsEqualOrHigher()
|
||||
public function testVersionFormatIsEqualOrHigher(): void
|
||||
{
|
||||
$this->assertTrue($this->gpm->versionFormatIsEqualOrHigher('>=1.0'));
|
||||
$this->assertTrue($this->gpm->versionFormatIsEqualOrHigher('>=2.3.4'));
|
||||
$this->assertTrue($this->gpm->versionFormatIsEqualOrHigher('>=2.3.x'));
|
||||
$this->assertFalse($this->gpm->versionFormatIsEqualOrHigher('~2.3.x'));
|
||||
$this->assertFalse($this->gpm->versionFormatIsEqualOrHigher('1.0'));
|
||||
self::assertTrue($this->gpm->versionFormatIsEqualOrHigher('>=1.0'));
|
||||
self::assertTrue($this->gpm->versionFormatIsEqualOrHigher('>=2.3.4'));
|
||||
self::assertTrue($this->gpm->versionFormatIsEqualOrHigher('>=2.3.x'));
|
||||
self::assertFalse($this->gpm->versionFormatIsEqualOrHigher('~2.3.x'));
|
||||
self::assertFalse($this->gpm->versionFormatIsEqualOrHigher('1.0'));
|
||||
}
|
||||
|
||||
public function testCheckNextSignificantReleasesAreCompatible()
|
||||
public function testCheckNextSignificantReleasesAreCompatible(): void
|
||||
{
|
||||
/*
|
||||
* ~1.0 is equivalent to >=1.0 < 2.0.0
|
||||
* ~1.2 is equivalent to >=1.2 <2.0.0
|
||||
* ~1.2.3 is equivalent to >=1.2.3 <1.3.0
|
||||
*/
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '1.2'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.2', '1.0'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '1.0.10'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.1', '1.1.10'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('30.0', '30.10'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '1.1.10'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '1.8'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0.1', '1.1'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('2.0.0-beta', '2.0'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('2.0.0-rc.1', '2.0'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('2.0', '2.0.0-alpha'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '1.2'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.2', '1.0'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '1.0.10'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.1', '1.1.10'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('30.0', '30.10'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '1.1.10'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '1.8'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0.1', '1.1'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('2.0.0-beta', '2.0'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('2.0.0-rc.1', '2.0'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('2.0', '2.0.0-alpha'));
|
||||
|
||||
$this->assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '2.2'));
|
||||
$this->assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('1.0.0-beta.1', '2.0'));
|
||||
$this->assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('0.9.99', '1.0.0'));
|
||||
$this->assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('0.9.99', '1.0.10'));
|
||||
$this->assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('0.9.99', '1.0.10.2'));
|
||||
self::assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '2.2'));
|
||||
self::assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('1.0.0-beta.1', '2.0'));
|
||||
self::assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('0.9.99', '1.0.0'));
|
||||
self::assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('0.9.99', '1.0.10'));
|
||||
self::assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('0.9.99', '1.0.10.2'));
|
||||
}
|
||||
|
||||
|
||||
public function testCalculateVersionNumberFromDependencyVersion()
|
||||
public function testCalculateVersionNumberFromDependencyVersion(): void
|
||||
{
|
||||
$this->assertSame('2.0', $this->gpm->calculateVersionNumberFromDependencyVersion('>=2.0'));
|
||||
$this->assertSame('2.0.2', $this->gpm->calculateVersionNumberFromDependencyVersion('>=2.0.2'));
|
||||
$this->assertSame('2.0.2', $this->gpm->calculateVersionNumberFromDependencyVersion('~2.0.2'));
|
||||
$this->assertSame('1', $this->gpm->calculateVersionNumberFromDependencyVersion('~1'));
|
||||
$this->assertNull($this->gpm->calculateVersionNumberFromDependencyVersion(''));
|
||||
$this->assertNull($this->gpm->calculateVersionNumberFromDependencyVersion('*'));
|
||||
$this->assertSame('2.0.2', $this->gpm->calculateVersionNumberFromDependencyVersion('2.0.2'));
|
||||
self::assertSame('2.0', $this->gpm->calculateVersionNumberFromDependencyVersion('>=2.0'));
|
||||
self::assertSame('2.0.2', $this->gpm->calculateVersionNumberFromDependencyVersion('>=2.0.2'));
|
||||
self::assertSame('2.0.2', $this->gpm->calculateVersionNumberFromDependencyVersion('~2.0.2'));
|
||||
self::assertSame('1', $this->gpm->calculateVersionNumberFromDependencyVersion('~1'));
|
||||
self::assertNull($this->gpm->calculateVersionNumberFromDependencyVersion(''));
|
||||
self::assertNull($this->gpm->calculateVersionNumberFromDependencyVersion('*'));
|
||||
self::assertSame('2.0.2', $this->gpm->calculateVersionNumberFromDependencyVersion('2.0.2'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class ExcerptsTest extends \Codeception\TestCase\Test
|
|||
|
||||
protected $old_home;
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$grav = Fixtures::get('grav');
|
||||
$this->grav = $grav();
|
||||
|
|
@ -70,49 +70,49 @@ class ExcerptsTest extends \Codeception\TestCase\Test
|
|||
$this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
$this->config->set('system.home.alias', $this->old_home);
|
||||
}
|
||||
|
||||
|
||||
public function testProcessImageHtml()
|
||||
public function testProcessImageHtml(): void
|
||||
{
|
||||
$this->assertRegexp(
|
||||
self::assertRegexp(
|
||||
'|<img alt="Sample Image" src="\/images\/.*-sample-image.jpe?g\" data-src="sample-image\.jpg\?cropZoom=300,300" \/>|',
|
||||
Excerpts::processImageHtml('<img src="sample-image.jpg?cropZoom=300,300" alt="Sample Image" />', $this->page)
|
||||
);
|
||||
$this->assertRegexp(
|
||||
self::assertRegexp(
|
||||
'|<img alt="Sample Image" class="foo" src="\/images\/.*-sample-image.jpe?g\" data-src="sample-image\.jpg\?classes=foo" \/>|',
|
||||
Excerpts::processImageHtml('<img src="sample-image.jpg?classes=foo" alt="Sample Image" />', $this->page)
|
||||
);
|
||||
}
|
||||
|
||||
public function testNoProcess()
|
||||
public function testNoProcess(): void
|
||||
{
|
||||
$this->assertStringStartsWith(
|
||||
self::assertStringStartsWith(
|
||||
'<a href="https://play.google.com/store/apps/details?hl=de" id="org.jitsi.meet" target="_blank"',
|
||||
Excerpts::processLinkHtml('<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de&target=_blank">regular process</a>')
|
||||
);
|
||||
|
||||
$this->assertStringStartsWith(
|
||||
self::assertStringStartsWith(
|
||||
'<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de&target=_blank"',
|
||||
Excerpts::processLinkHtml('<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de&target=_blank&noprocess">noprocess</a>')
|
||||
);
|
||||
|
||||
$this->assertStringStartsWith(
|
||||
self::assertStringStartsWith(
|
||||
'<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de" target="_blank"',
|
||||
Excerpts::processLinkHtml('<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de&target=_blank&noprocess=id">noprocess=id</a>')
|
||||
);
|
||||
}
|
||||
|
||||
public function testTarget()
|
||||
public function testTarget(): void
|
||||
{
|
||||
$this->assertStringStartsWith(
|
||||
self::assertStringStartsWith(
|
||||
'<a href="https://play.google.com/store/apps/details" target="_blank"',
|
||||
Excerpts::processLinkHtml('<a href="https://play.google.com/store/apps/details?target=_blank">only target</a>')
|
||||
);
|
||||
$this->assertStringStartsWith(
|
||||
self::assertStringStartsWith(
|
||||
'<a href="https://meet.weikamp.biz/Support" rel="nofollow" target="_blank"',
|
||||
Excerpts::processLinkHtml('<a href="https://meet.weikamp.biz/Support?rel=nofollow&target=_blank">target and rel</a>')
|
||||
);
|
||||
|
|
|
|||
|
|
@ -16,130 +16,130 @@ class InflectorTest extends \Codeception\TestCase\Test
|
|||
/** @var Inflector $uri */
|
||||
protected $inflector;
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$grav = Fixtures::get('grav');
|
||||
$this->grav = $grav();
|
||||
$this->inflector = $this->grav['inflector'];
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testPluralize()
|
||||
public function testPluralize(): void
|
||||
{
|
||||
$this->assertSame('words', $this->inflector->pluralize('word'));
|
||||
$this->assertSame('kisses', $this->inflector->pluralize('kiss'));
|
||||
$this->assertSame('volcanoes', $this->inflector->pluralize('volcanoe'));
|
||||
$this->assertSame('cherries', $this->inflector->pluralize('cherry'));
|
||||
$this->assertSame('days', $this->inflector->pluralize('day'));
|
||||
$this->assertSame('knives', $this->inflector->pluralize('knife'));
|
||||
self::assertSame('words', $this->inflector->pluralize('word'));
|
||||
self::assertSame('kisses', $this->inflector->pluralize('kiss'));
|
||||
self::assertSame('volcanoes', $this->inflector->pluralize('volcanoe'));
|
||||
self::assertSame('cherries', $this->inflector->pluralize('cherry'));
|
||||
self::assertSame('days', $this->inflector->pluralize('day'));
|
||||
self::assertSame('knives', $this->inflector->pluralize('knife'));
|
||||
}
|
||||
|
||||
public function testSingularize()
|
||||
public function testSingularize(): void
|
||||
{
|
||||
$this->assertSame('word', $this->inflector->singularize('words'));
|
||||
$this->assertSame('kiss', $this->inflector->singularize('kisses'));
|
||||
$this->assertSame('volcanoe', $this->inflector->singularize('volcanoe'));
|
||||
$this->assertSame('cherry', $this->inflector->singularize('cherries'));
|
||||
$this->assertSame('day', $this->inflector->singularize('days'));
|
||||
$this->assertSame('knife', $this->inflector->singularize('knives'));
|
||||
self::assertSame('word', $this->inflector->singularize('words'));
|
||||
self::assertSame('kiss', $this->inflector->singularize('kisses'));
|
||||
self::assertSame('volcanoe', $this->inflector->singularize('volcanoe'));
|
||||
self::assertSame('cherry', $this->inflector->singularize('cherries'));
|
||||
self::assertSame('day', $this->inflector->singularize('days'));
|
||||
self::assertSame('knife', $this->inflector->singularize('knives'));
|
||||
}
|
||||
|
||||
public function testTitleize()
|
||||
public function testTitleize(): void
|
||||
{
|
||||
$this->assertSame('This String Is Titleized', $this->inflector->titleize('ThisStringIsTitleized'));
|
||||
$this->assertSame('This String Is Titleized', $this->inflector->titleize('this string is titleized'));
|
||||
$this->assertSame('This String Is Titleized', $this->inflector->titleize('this_string_is_titleized'));
|
||||
$this->assertSame('This String Is Titleized', $this->inflector->titleize('this-string-is-titleized'));
|
||||
self::assertSame('This String Is Titleized', $this->inflector->titleize('ThisStringIsTitleized'));
|
||||
self::assertSame('This String Is Titleized', $this->inflector->titleize('this string is titleized'));
|
||||
self::assertSame('This String Is Titleized', $this->inflector->titleize('this_string_is_titleized'));
|
||||
self::assertSame('This String Is Titleized', $this->inflector->titleize('this-string-is-titleized'));
|
||||
|
||||
$this->assertSame('This string is titleized', $this->inflector->titleize('ThisStringIsTitleized', 'first'));
|
||||
$this->assertSame('This string is titleized', $this->inflector->titleize('this string is titleized', 'first'));
|
||||
$this->assertSame('This string is titleized', $this->inflector->titleize('this_string_is_titleized', 'first'));
|
||||
$this->assertSame('This string is titleized', $this->inflector->titleize('this-string-is-titleized', 'first'));
|
||||
self::assertSame('This string is titleized', $this->inflector->titleize('ThisStringIsTitleized', 'first'));
|
||||
self::assertSame('This string is titleized', $this->inflector->titleize('this string is titleized', 'first'));
|
||||
self::assertSame('This string is titleized', $this->inflector->titleize('this_string_is_titleized', 'first'));
|
||||
self::assertSame('This string is titleized', $this->inflector->titleize('this-string-is-titleized', 'first'));
|
||||
}
|
||||
|
||||
public function testCamelize()
|
||||
public function testCamelize(): void
|
||||
{
|
||||
$this->assertSame('ThisStringIsCamelized', $this->inflector->camelize('This String Is Camelized'));
|
||||
$this->assertSame('ThisStringIsCamelized', $this->inflector->camelize('thisStringIsCamelized'));
|
||||
$this->assertSame('ThisStringIsCamelized', $this->inflector->camelize('This_String_Is_Camelized'));
|
||||
$this->assertSame('ThisStringIsCamelized', $this->inflector->camelize('this string is camelized'));
|
||||
$this->assertSame('GravSPrettyCoolMy1', $this->inflector->camelize("Grav's Pretty Cool. My #1!"));
|
||||
self::assertSame('ThisStringIsCamelized', $this->inflector->camelize('This String Is Camelized'));
|
||||
self::assertSame('ThisStringIsCamelized', $this->inflector->camelize('thisStringIsCamelized'));
|
||||
self::assertSame('ThisStringIsCamelized', $this->inflector->camelize('This_String_Is_Camelized'));
|
||||
self::assertSame('ThisStringIsCamelized', $this->inflector->camelize('this string is camelized'));
|
||||
self::assertSame('GravSPrettyCoolMy1', $this->inflector->camelize("Grav's Pretty Cool. My #1!"));
|
||||
}
|
||||
|
||||
public function testUnderscorize()
|
||||
public function testUnderscorize(): void
|
||||
{
|
||||
$this->assertSame('this_string_is_underscorized', $this->inflector->underscorize('This String Is Underscorized'));
|
||||
$this->assertSame('this_string_is_underscorized', $this->inflector->underscorize('ThisStringIsUnderscorized'));
|
||||
$this->assertSame('this_string_is_underscorized', $this->inflector->underscorize('This_String_Is_Underscorized'));
|
||||
$this->assertSame('this_string_is_underscorized', $this->inflector->underscorize('This-String-Is-Underscorized'));
|
||||
self::assertSame('this_string_is_underscorized', $this->inflector->underscorize('This String Is Underscorized'));
|
||||
self::assertSame('this_string_is_underscorized', $this->inflector->underscorize('ThisStringIsUnderscorized'));
|
||||
self::assertSame('this_string_is_underscorized', $this->inflector->underscorize('This_String_Is_Underscorized'));
|
||||
self::assertSame('this_string_is_underscorized', $this->inflector->underscorize('This-String-Is-Underscorized'));
|
||||
}
|
||||
|
||||
public function testHyphenize()
|
||||
public function testHyphenize(): void
|
||||
{
|
||||
$this->assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('This String Is Hyphenized'));
|
||||
$this->assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('ThisStringIsHyphenized'));
|
||||
$this->assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('This-String-Is-Hyphenized'));
|
||||
$this->assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('This_String_Is_Hyphenized'));
|
||||
self::assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('This String Is Hyphenized'));
|
||||
self::assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('ThisStringIsHyphenized'));
|
||||
self::assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('This-String-Is-Hyphenized'));
|
||||
self::assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('This_String_Is_Hyphenized'));
|
||||
}
|
||||
|
||||
public function testHumanize()
|
||||
public function testHumanize(): void
|
||||
{
|
||||
//$this->assertSame('This string is humanized', $this->inflector->humanize('ThisStringIsHumanized'));
|
||||
$this->assertSame('This string is humanized', $this->inflector->humanize('this_string_is_humanized'));
|
||||
//$this->assertSame('This string is humanized', $this->inflector->humanize('this-string-is-humanized'));
|
||||
//self::assertSame('This string is humanized', $this->inflector->humanize('ThisStringIsHumanized'));
|
||||
self::assertSame('This string is humanized', $this->inflector->humanize('this_string_is_humanized'));
|
||||
//self::assertSame('This string is humanized', $this->inflector->humanize('this-string-is-humanized'));
|
||||
|
||||
$this->assertSame('This String Is Humanized', $this->inflector->humanize('this_string_is_humanized', 'all'));
|
||||
//$this->assertSame('This String Is Humanized', $this->inflector->humanize('this-string-is-humanized'), 'all');
|
||||
self::assertSame('This String Is Humanized', $this->inflector->humanize('this_string_is_humanized', 'all'));
|
||||
//self::assertSame('This String Is Humanized', $this->inflector->humanize('this-string-is-humanized'), 'all');
|
||||
}
|
||||
|
||||
public function testVariablize()
|
||||
public function testVariablize(): void
|
||||
{
|
||||
$this->assertSame('thisStringIsVariablized', $this->inflector->variablize('This String Is Variablized'));
|
||||
$this->assertSame('thisStringIsVariablized', $this->inflector->variablize('ThisStringIsVariablized'));
|
||||
$this->assertSame('thisStringIsVariablized', $this->inflector->variablize('This_String_Is_Variablized'));
|
||||
$this->assertSame('thisStringIsVariablized', $this->inflector->variablize('this string is variablized'));
|
||||
$this->assertSame('gravSPrettyCoolMy1', $this->inflector->variablize("Grav's Pretty Cool. My #1!"));
|
||||
self::assertSame('thisStringIsVariablized', $this->inflector->variablize('This String Is Variablized'));
|
||||
self::assertSame('thisStringIsVariablized', $this->inflector->variablize('ThisStringIsVariablized'));
|
||||
self::assertSame('thisStringIsVariablized', $this->inflector->variablize('This_String_Is_Variablized'));
|
||||
self::assertSame('thisStringIsVariablized', $this->inflector->variablize('this string is variablized'));
|
||||
self::assertSame('gravSPrettyCoolMy1', $this->inflector->variablize("Grav's Pretty Cool. My #1!"));
|
||||
}
|
||||
|
||||
public function testTableize()
|
||||
public function testTableize(): void
|
||||
{
|
||||
$this->assertSame('people', $this->inflector->tableize('Person'));
|
||||
$this->assertSame('pages', $this->inflector->tableize('Page'));
|
||||
$this->assertSame('blog_pages', $this->inflector->tableize('BlogPage'));
|
||||
$this->assertSame('admin_dependencies', $this->inflector->tableize('adminDependency'));
|
||||
$this->assertSame('admin_dependencies', $this->inflector->tableize('admin-dependency'));
|
||||
$this->assertSame('admin_dependencies', $this->inflector->tableize('admin_dependency'));
|
||||
self::assertSame('people', $this->inflector->tableize('Person'));
|
||||
self::assertSame('pages', $this->inflector->tableize('Page'));
|
||||
self::assertSame('blog_pages', $this->inflector->tableize('BlogPage'));
|
||||
self::assertSame('admin_dependencies', $this->inflector->tableize('adminDependency'));
|
||||
self::assertSame('admin_dependencies', $this->inflector->tableize('admin-dependency'));
|
||||
self::assertSame('admin_dependencies', $this->inflector->tableize('admin_dependency'));
|
||||
}
|
||||
|
||||
public function testClassify()
|
||||
public function testClassify(): void
|
||||
{
|
||||
$this->assertSame('Person', $this->inflector->classify('people'));
|
||||
$this->assertSame('Page', $this->inflector->classify('pages'));
|
||||
$this->assertSame('BlogPage', $this->inflector->classify('blog_pages'));
|
||||
$this->assertSame('AdminDependency', $this->inflector->classify('admin_dependencies'));
|
||||
self::assertSame('Person', $this->inflector->classify('people'));
|
||||
self::assertSame('Page', $this->inflector->classify('pages'));
|
||||
self::assertSame('BlogPage', $this->inflector->classify('blog_pages'));
|
||||
self::assertSame('AdminDependency', $this->inflector->classify('admin_dependencies'));
|
||||
}
|
||||
|
||||
public function testOrdinalize()
|
||||
public function testOrdinalize(): void
|
||||
{
|
||||
$this->assertSame('1st', $this->inflector->ordinalize(1));
|
||||
$this->assertSame('2nd', $this->inflector->ordinalize(2));
|
||||
$this->assertSame('3rd', $this->inflector->ordinalize(3));
|
||||
$this->assertSame('4th', $this->inflector->ordinalize(4));
|
||||
$this->assertSame('5th', $this->inflector->ordinalize(5));
|
||||
$this->assertSame('16th', $this->inflector->ordinalize(16));
|
||||
$this->assertSame('51st', $this->inflector->ordinalize(51));
|
||||
$this->assertSame('111th', $this->inflector->ordinalize(111));
|
||||
$this->assertSame('123rd', $this->inflector->ordinalize(123));
|
||||
self::assertSame('1st', $this->inflector->ordinalize(1));
|
||||
self::assertSame('2nd', $this->inflector->ordinalize(2));
|
||||
self::assertSame('3rd', $this->inflector->ordinalize(3));
|
||||
self::assertSame('4th', $this->inflector->ordinalize(4));
|
||||
self::assertSame('5th', $this->inflector->ordinalize(5));
|
||||
self::assertSame('16th', $this->inflector->ordinalize(16));
|
||||
self::assertSame('51st', $this->inflector->ordinalize(51));
|
||||
self::assertSame('111th', $this->inflector->ordinalize(111));
|
||||
self::assertSame('123rd', $this->inflector->ordinalize(123));
|
||||
}
|
||||
|
||||
public function testMonthize()
|
||||
public function testMonthize(): void
|
||||
{
|
||||
$this->assertSame(0, $this->inflector->monthize(10));
|
||||
$this->assertSame(1, $this->inflector->monthize(33));
|
||||
$this->assertSame(1, $this->inflector->monthize(41));
|
||||
$this->assertSame(11, $this->inflector->monthize(364));
|
||||
self::assertSame(0, $this->inflector->monthize(10));
|
||||
self::assertSame(1, $this->inflector->monthize(33));
|
||||
self::assertSame(1, $this->inflector->monthize(41));
|
||||
self::assertSame(11, $this->inflector->monthize(364));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,21 +7,21 @@ use Grav\Common\Language\LanguageCodes;
|
|||
*/
|
||||
class LanguageCodesTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
public function testRtl()
|
||||
public function testRtl(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
self::assertSame(
|
||||
'ltr',
|
||||
LanguageCodes::getOrientation('en')
|
||||
);
|
||||
$this->assertSame(
|
||||
self::assertSame(
|
||||
'rtl',
|
||||
LanguageCodes::getOrientation('ar')
|
||||
);
|
||||
$this->assertSame(
|
||||
self::assertSame(
|
||||
'rtl',
|
||||
LanguageCodes::getOrientation('he')
|
||||
);
|
||||
$this->assertTrue(LanguageCodes::isRtl('ar'));
|
||||
$this->assertFalse(LanguageCodes::isRtl('fr'));
|
||||
self::assertTrue(LanguageCodes::isRtl('ar'));
|
||||
self::assertFalse(LanguageCodes::isRtl('fr'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -21,7 +21,7 @@ class PagesTest extends \Codeception\TestCase\Test
|
|||
/** @var PageInterface $root_page */
|
||||
protected $root_page;
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$grav = Fixtures::get('grav');
|
||||
$this->grav = $grav();
|
||||
|
|
@ -35,46 +35,46 @@ class PagesTest extends \Codeception\TestCase\Test
|
|||
$this->pages->init();
|
||||
}
|
||||
|
||||
public function testBase()
|
||||
public function testBase(): void
|
||||
{
|
||||
$this->assertSame('', $this->pages->base());
|
||||
self::assertSame('', $this->pages->base());
|
||||
$this->pages->base('/test');
|
||||
$this->assertSame('/test', $this->pages->base());
|
||||
self::assertSame('/test', $this->pages->base());
|
||||
$this->pages->base('');
|
||||
$this->assertSame($this->pages->base(), '');
|
||||
self::assertSame($this->pages->base(), '');
|
||||
}
|
||||
|
||||
public function testLastModified()
|
||||
public function testLastModified(): void
|
||||
{
|
||||
$this->assertNull($this->pages->lastModified());
|
||||
self::assertNull($this->pages->lastModified());
|
||||
$this->pages->lastModified('test');
|
||||
$this->assertSame('test', $this->pages->lastModified());
|
||||
self::assertSame('test', $this->pages->lastModified());
|
||||
}
|
||||
|
||||
public function testInstances()
|
||||
public function testInstances(): void
|
||||
{
|
||||
$this->assertIsArray($this->pages->instances());
|
||||
self::assertIsArray($this->pages->instances());
|
||||
foreach ($this->pages->instances() as $instance) {
|
||||
$this->assertInstanceOf(PageInterface::class, $instance);
|
||||
self::assertInstanceOf(PageInterface::class, $instance);
|
||||
}
|
||||
}
|
||||
|
||||
public function testRoutes()
|
||||
public function testRoutes(): void
|
||||
{
|
||||
/** @var UniformResourceLocator $locator */
|
||||
$locator = $this->grav['locator'];
|
||||
$folder = $locator->findResource('tests://');
|
||||
|
||||
$this->assertIsArray($this->pages->routes());
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/01.home', $this->pages->routes()['/']);
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/01.home', $this->pages->routes()['/home']);
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog', $this->pages->routes()['/blog']);
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', $this->pages->routes()['/blog/post-one']);
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', $this->pages->routes()['/blog/post-two']);
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/03.about', $this->pages->routes()['/about']);
|
||||
self::assertIsArray($this->pages->routes());
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/01.home', $this->pages->routes()['/']);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/01.home', $this->pages->routes()['/home']);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog', $this->pages->routes()['/blog']);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', $this->pages->routes()['/blog/post-one']);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', $this->pages->routes()['/blog/post-two']);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/03.about', $this->pages->routes()['/about']);
|
||||
}
|
||||
|
||||
public function testAddPage()
|
||||
public function testAddPage(): void
|
||||
{
|
||||
/** @var UniformResourceLocator $locator */
|
||||
$locator = $this->grav['locator'];
|
||||
|
|
@ -86,11 +86,11 @@ class PagesTest extends \Codeception\TestCase\Test
|
|||
|
||||
$this->pages->addPage($aPage, '/new-page');
|
||||
|
||||
$this->assertContains('/new-page', array_keys($this->pages->routes()));
|
||||
$this->assertSame($folder . '/fake/single-pages/01.simple-page', $this->pages->routes()['/new-page']);
|
||||
self::assertContains('/new-page', array_keys($this->pages->routes()));
|
||||
self::assertSame($folder . '/fake/single-pages/01.simple-page', $this->pages->routes()['/new-page']);
|
||||
}
|
||||
|
||||
public function testSort()
|
||||
public function testSort(): void
|
||||
{
|
||||
/** @var UniformResourceLocator $locator */
|
||||
$locator = $this->grav['locator'];
|
||||
|
|
@ -99,34 +99,34 @@ class PagesTest extends \Codeception\TestCase\Test
|
|||
$aPage = $this->pages->find('/blog');
|
||||
$subPagesSorted = $this->pages->sort($aPage);
|
||||
|
||||
$this->assertIsArray($subPagesSorted);
|
||||
$this->assertCount(2, $subPagesSorted);
|
||||
self::assertIsArray($subPagesSorted);
|
||||
self::assertCount(2, $subPagesSorted);
|
||||
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted)[0]);
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted)[1]);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted)[0]);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted)[1]);
|
||||
|
||||
$this->assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted));
|
||||
$this->assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted));
|
||||
self::assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted));
|
||||
self::assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted));
|
||||
|
||||
$this->assertSame(['slug' => 'post-one'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-one']);
|
||||
$this->assertSame(['slug' => 'post-two'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-two']);
|
||||
self::assertSame(['slug' => 'post-one'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-one']);
|
||||
self::assertSame(['slug' => 'post-two'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-two']);
|
||||
|
||||
$subPagesSorted = $this->pages->sort($aPage, null, 'desc');
|
||||
|
||||
$this->assertIsArray($subPagesSorted);
|
||||
$this->assertCount(2, $subPagesSorted);
|
||||
self::assertIsArray($subPagesSorted);
|
||||
self::assertCount(2, $subPagesSorted);
|
||||
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted)[0]);
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted)[1]);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted)[0]);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted)[1]);
|
||||
|
||||
$this->assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted));
|
||||
$this->assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted));
|
||||
self::assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted));
|
||||
self::assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted));
|
||||
|
||||
$this->assertSame(['slug' => 'post-one'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-one']);
|
||||
$this->assertSame(['slug' => 'post-two'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-two']);
|
||||
self::assertSame(['slug' => 'post-one'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-one']);
|
||||
self::assertSame(['slug' => 'post-two'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-two']);
|
||||
}
|
||||
|
||||
public function testSortCollection()
|
||||
public function testSortCollection(): void
|
||||
{
|
||||
/** @var UniformResourceLocator $locator */
|
||||
$locator = $this->grav['locator'];
|
||||
|
|
@ -135,34 +135,34 @@ class PagesTest extends \Codeception\TestCase\Test
|
|||
$aPage = $this->pages->find('/blog');
|
||||
$subPagesSorted = $this->pages->sortCollection($aPage->children(), $aPage->orderBy());
|
||||
|
||||
$this->assertIsArray($subPagesSorted);
|
||||
$this->assertCount(2, $subPagesSorted);
|
||||
self::assertIsArray($subPagesSorted);
|
||||
self::assertCount(2, $subPagesSorted);
|
||||
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted)[0]);
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted)[1]);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted)[0]);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted)[1]);
|
||||
|
||||
$this->assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted));
|
||||
$this->assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted));
|
||||
self::assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted));
|
||||
self::assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted));
|
||||
|
||||
$this->assertSame(['slug' => 'post-one'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-one']);
|
||||
$this->assertSame(['slug' => 'post-two'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-two']);
|
||||
self::assertSame(['slug' => 'post-one'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-one']);
|
||||
self::assertSame(['slug' => 'post-two'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-two']);
|
||||
|
||||
$subPagesSorted = $this->pages->sortCollection($aPage->children(), $aPage->orderBy(), 'desc');
|
||||
|
||||
$this->assertIsArray($subPagesSorted);
|
||||
$this->assertCount(2, $subPagesSorted);
|
||||
self::assertIsArray($subPagesSorted);
|
||||
self::assertCount(2, $subPagesSorted);
|
||||
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted)[0]);
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted)[1]);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted)[0]);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted)[1]);
|
||||
|
||||
$this->assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted));
|
||||
$this->assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted));
|
||||
self::assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted));
|
||||
self::assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted));
|
||||
|
||||
$this->assertSame(['slug' => 'post-one'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-one']);
|
||||
$this->assertSame(['slug' => 'post-two'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-two']);
|
||||
self::assertSame(['slug' => 'post-one'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-one']);
|
||||
self::assertSame(['slug' => 'post-two'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-two']);
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
public function testGet(): void
|
||||
{
|
||||
/** @var UniformResourceLocator $locator */
|
||||
$locator = $this->grav['locator'];
|
||||
|
|
@ -170,14 +170,14 @@ class PagesTest extends \Codeception\TestCase\Test
|
|||
|
||||
//Page existing
|
||||
$aPage = $this->pages->get($folder . '/fake/simple-site/user/pages/03.about');
|
||||
$this->assertInstanceOf(PageInterface::class, $aPage);
|
||||
self::assertInstanceOf(PageInterface::class, $aPage);
|
||||
|
||||
//Page not existing
|
||||
$anotherPage = $this->pages->get($folder . '/fake/simple-site/user/pages/03.non-existing');
|
||||
$this->assertNull($anotherPage);
|
||||
self::assertNull($anotherPage);
|
||||
}
|
||||
|
||||
public function testChildren()
|
||||
public function testChildren(): void
|
||||
{
|
||||
/** @var UniformResourceLocator $locator */
|
||||
$locator = $this->grav['locator'];
|
||||
|
|
@ -185,90 +185,90 @@ class PagesTest extends \Codeception\TestCase\Test
|
|||
|
||||
//Page existing
|
||||
$children = $this->pages->children($folder . '/fake/simple-site/user/pages/02.blog');
|
||||
$this->assertInstanceOf('Grav\Common\Page\Collection', $children);
|
||||
self::assertInstanceOf('Grav\Common\Page\Collection', $children);
|
||||
|
||||
//Page not existing
|
||||
$children = $this->pages->children($folder . '/fake/whatever/non-existing');
|
||||
$this->assertSame([], $children->toArray());
|
||||
self::assertSame([], $children->toArray());
|
||||
}
|
||||
|
||||
public function testDispatch()
|
||||
public function testDispatch(): void
|
||||
{
|
||||
$aPage = $this->pages->dispatch('/blog');
|
||||
$this->assertInstanceOf(PageInterface::class, $aPage);
|
||||
self::assertInstanceOf(PageInterface::class, $aPage);
|
||||
|
||||
$aPage = $this->pages->dispatch('/about');
|
||||
$this->assertInstanceOf(PageInterface::class, $aPage);
|
||||
self::assertInstanceOf(PageInterface::class, $aPage);
|
||||
|
||||
$aPage = $this->pages->dispatch('/blog/post-one');
|
||||
$this->assertInstanceOf(PageInterface::class, $aPage);
|
||||
self::assertInstanceOf(PageInterface::class, $aPage);
|
||||
|
||||
//Page not existing
|
||||
$aPage = $this->pages->dispatch('/non-existing');
|
||||
$this->assertNull($aPage);
|
||||
self::assertNull($aPage);
|
||||
}
|
||||
|
||||
public function testRoot()
|
||||
public function testRoot(): void
|
||||
{
|
||||
$root = $this->pages->root();
|
||||
$this->assertInstanceOf(PageInterface::class, $root);
|
||||
$this->assertSame('pages', $root->folder());
|
||||
self::assertInstanceOf(PageInterface::class, $root);
|
||||
self::assertSame('pages', $root->folder());
|
||||
}
|
||||
|
||||
public function testBlueprints()
|
||||
public function testBlueprints(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testAll()
|
||||
{
|
||||
$this->assertIsObject($this->pages->all());
|
||||
$this->assertIsArray($this->pages->all()->toArray());
|
||||
self::assertIsObject($this->pages->all());
|
||||
self::assertIsArray($this->pages->all()->toArray());
|
||||
foreach ($this->pages->all() as $page) {
|
||||
$this->assertInstanceOf(PageInterface::class, $page);
|
||||
self::assertInstanceOf(PageInterface::class, $page);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetList()
|
||||
public function testGetList(): void
|
||||
{
|
||||
$list = $this->pages->getList();
|
||||
$this->assertIsArray($list);
|
||||
$this->assertSame('—-▸ Home', $list['/']);
|
||||
$this->assertSame('—-▸ Blog', $list['/blog']);
|
||||
self::assertIsArray($list);
|
||||
self::assertSame('—-▸ Home', $list['/']);
|
||||
self::assertSame('—-▸ Blog', $list['/blog']);
|
||||
}
|
||||
|
||||
public function testGetTypes()
|
||||
public function testGetTypes(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testTypes()
|
||||
public function testTypes(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testModularTypes()
|
||||
public function testModularTypes(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testPageTypes()
|
||||
public function testPageTypes(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testAccessLevels()
|
||||
public function testAccessLevels(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testParents()
|
||||
public function testParents(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testParentsRawRoutes()
|
||||
public function testParentsRawRoutes(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testGetHomeRoute()
|
||||
public function testGetHomeRoute(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testResetPages()
|
||||
public function testResetPages(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,44 +15,44 @@ class TwigExtensionTest extends \Codeception\TestCase\Test
|
|||
/** @var TwigExtension $twig_ext */
|
||||
protected $twig_ext;
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$this->grav = Fixtures::get('grav');
|
||||
$this->twig_ext = new TwigExtension();
|
||||
}
|
||||
|
||||
public function testInflectorFilter()
|
||||
public function testInflectorFilter(): void
|
||||
{
|
||||
$this->assertSame('people', $this->twig_ext->inflectorFilter('plural', 'person'));
|
||||
$this->assertSame('shoe', $this->twig_ext->inflectorFilter('singular', 'shoes'));
|
||||
$this->assertSame('Welcome Page', $this->twig_ext->inflectorFilter('title', 'welcome page'));
|
||||
$this->assertSame('SendEmail', $this->twig_ext->inflectorFilter('camel', 'send_email'));
|
||||
$this->assertSame('camel_cased', $this->twig_ext->inflectorFilter('underscor', 'CamelCased'));
|
||||
$this->assertSame('something-text', $this->twig_ext->inflectorFilter('hyphen', 'Something Text'));
|
||||
$this->assertSame('Something text to read', $this->twig_ext->inflectorFilter('human', 'something_text_to_read'));
|
||||
$this->assertSame(5, $this->twig_ext->inflectorFilter('month', '175'));
|
||||
$this->assertSame('10th', $this->twig_ext->inflectorFilter('ordinal', '10'));
|
||||
self::assertSame('people', $this->twig_ext->inflectorFilter('plural', 'person'));
|
||||
self::assertSame('shoe', $this->twig_ext->inflectorFilter('singular', 'shoes'));
|
||||
self::assertSame('Welcome Page', $this->twig_ext->inflectorFilter('title', 'welcome page'));
|
||||
self::assertSame('SendEmail', $this->twig_ext->inflectorFilter('camel', 'send_email'));
|
||||
self::assertSame('camel_cased', $this->twig_ext->inflectorFilter('underscor', 'CamelCased'));
|
||||
self::assertSame('something-text', $this->twig_ext->inflectorFilter('hyphen', 'Something Text'));
|
||||
self::assertSame('Something text to read', $this->twig_ext->inflectorFilter('human', 'something_text_to_read'));
|
||||
self::assertSame(5, $this->twig_ext->inflectorFilter('month', '175'));
|
||||
self::assertSame('10th', $this->twig_ext->inflectorFilter('ordinal', '10'));
|
||||
}
|
||||
|
||||
public function testMd5Filter()
|
||||
public function testMd5Filter(): void
|
||||
{
|
||||
$this->assertSame(md5('grav'), $this->twig_ext->md5Filter('grav'));
|
||||
$this->assertSame(md5('devs@getgrav.org'), $this->twig_ext->md5Filter('devs@getgrav.org'));
|
||||
self::assertSame(md5('grav'), $this->twig_ext->md5Filter('grav'));
|
||||
self::assertSame(md5('devs@getgrav.org'), $this->twig_ext->md5Filter('devs@getgrav.org'));
|
||||
}
|
||||
|
||||
public function testKsortFilter()
|
||||
public function testKsortFilter(): void
|
||||
{
|
||||
$object = array("name"=>"Bob","age"=>8,"colour"=>"red");
|
||||
$this->assertSame(array("age"=>8,"colour"=>"red","name"=>"Bob"), $this->twig_ext->ksortFilter($object));
|
||||
self::assertSame(array("age"=>8,"colour"=>"red","name"=>"Bob"), $this->twig_ext->ksortFilter($object));
|
||||
}
|
||||
|
||||
public function testContainsFilter()
|
||||
public function testContainsFilter(): void
|
||||
{
|
||||
$this->assertTrue($this->twig_ext->containsFilter('grav', 'grav'));
|
||||
$this->assertTrue($this->twig_ext->containsFilter('So, I found this new cms, called grav, and it\'s pretty awesome guys', 'grav'));
|
||||
self::assertTrue($this->twig_ext->containsFilter('grav', 'grav'));
|
||||
self::assertTrue($this->twig_ext->containsFilter('So, I found this new cms, called grav, and it\'s pretty awesome guys', 'grav'));
|
||||
}
|
||||
|
||||
public function testNicetimeFilter()
|
||||
public function testNicetimeFilter(): void
|
||||
{
|
||||
$now = time();
|
||||
$threeMinutes = time() - (60*3);
|
||||
|
|
@ -62,121 +62,121 @@ class TwigExtensionTest extends \Codeception\TestCase\Test
|
|||
$threeYears = time() - (60*60*24*365*3);
|
||||
$measures = ['minutes','hours','days','months','years'];
|
||||
|
||||
$this->assertSame('No date provided', $this->twig_ext->nicetimeFunc(null));
|
||||
self::assertSame('No date provided', $this->twig_ext->nicetimeFunc(null));
|
||||
|
||||
for ($i=0; $i<count($measures); $i++) {
|
||||
$time = 'three' . ucfirst($measures[$i]);
|
||||
$this->assertSame('3 ' . $measures[$i] . ' ago', $this->twig_ext->nicetimeFunc($$time));
|
||||
self::assertSame('3 ' . $measures[$i] . ' ago', $this->twig_ext->nicetimeFunc($$time));
|
||||
}
|
||||
}
|
||||
|
||||
public function testRandomizeFilter()
|
||||
public function testRandomizeFilter(): void
|
||||
{
|
||||
$array = [1,2,3,4,5];
|
||||
$this->assertContains(2, $this->twig_ext->randomizeFilter($array));
|
||||
$this->assertSame($array, $this->twig_ext->randomizeFilter($array, 5));
|
||||
$this->assertSame($array[0], $this->twig_ext->randomizeFilter($array, 1)[0]);
|
||||
$this->assertSame($array[3], $this->twig_ext->randomizeFilter($array, 4)[3]);
|
||||
$this->assertSame($array[1], $this->twig_ext->randomizeFilter($array, 4)[1]);
|
||||
self::assertContains(2, $this->twig_ext->randomizeFilter($array));
|
||||
self::assertSame($array, $this->twig_ext->randomizeFilter($array, 5));
|
||||
self::assertSame($array[0], $this->twig_ext->randomizeFilter($array, 1)[0]);
|
||||
self::assertSame($array[3], $this->twig_ext->randomizeFilter($array, 4)[3]);
|
||||
self::assertSame($array[1], $this->twig_ext->randomizeFilter($array, 4)[1]);
|
||||
}
|
||||
|
||||
public function testModulusFilter()
|
||||
public function testModulusFilter(): void
|
||||
{
|
||||
$this->assertSame(3, $this->twig_ext->modulusFilter(3, 4));
|
||||
$this->assertSame(1, $this->twig_ext->modulusFilter(11, 2));
|
||||
$this->assertSame(0, $this->twig_ext->modulusFilter(10, 2));
|
||||
$this->assertSame(2, $this->twig_ext->modulusFilter(10, 4));
|
||||
self::assertSame(3, $this->twig_ext->modulusFilter(3, 4));
|
||||
self::assertSame(1, $this->twig_ext->modulusFilter(11, 2));
|
||||
self::assertSame(0, $this->twig_ext->modulusFilter(10, 2));
|
||||
self::assertSame(2, $this->twig_ext->modulusFilter(10, 4));
|
||||
}
|
||||
|
||||
public function testAbsoluteUrlFilter()
|
||||
public function testAbsoluteUrlFilter(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testMarkdownFilter()
|
||||
public function testMarkdownFilter(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testStartsWithFilter()
|
||||
public function testStartsWithFilter(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testEndsWithFilter()
|
||||
public function testEndsWithFilter(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testDefinedDefaultFilter()
|
||||
public function testDefinedDefaultFilter(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testRtrimFilter()
|
||||
public function testRtrimFilter(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testLtrimFilter()
|
||||
public function testLtrimFilter(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testRepeatFunc()
|
||||
public function testRepeatFunc(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testRegexReplace()
|
||||
public function testRegexReplace(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testUrlFunc()
|
||||
public function testUrlFunc(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testEvaluateFunc()
|
||||
public function testEvaluateFunc(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testDump()
|
||||
public function testDump(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testGistFunc()
|
||||
public function testGistFunc(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testRandomStringFunc()
|
||||
public function testRandomStringFunc(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testPadFilter()
|
||||
public function testPadFilter(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testArrayFunc()
|
||||
public function testArrayFunc(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
self::assertSame(
|
||||
'this is my text',
|
||||
$this->twig_ext->regexReplace('<p>this is my text</p>', '(<\/?p>)', '')
|
||||
);
|
||||
$this->assertSame(
|
||||
self::assertSame(
|
||||
'<i>this is my text</i>',
|
||||
$this->twig_ext->regexReplace('<p>this is my text</p>', ['(<p>)','(<\/p>)'], ['<i>','</i>'])
|
||||
);
|
||||
}
|
||||
|
||||
public function testArrayKeyValue()
|
||||
public function testArrayKeyValue(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
self::assertSame(
|
||||
['meat' => 'steak'],
|
||||
$this->twig_ext->arrayKeyValueFunc('meat', 'steak')
|
||||
);
|
||||
$this->assertSame(
|
||||
self::assertSame(
|
||||
['fruit' => 'apple', 'meat' => 'steak'],
|
||||
$this->twig_ext->arrayKeyValueFunc('meat', 'steak', ['fruit' => 'apple'])
|
||||
);
|
||||
}
|
||||
|
||||
public function stringFunc()
|
||||
public function stringFunc(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testRangeFunc()
|
||||
public function testRangeFunc(): void
|
||||
{
|
||||
$hundred = [];
|
||||
for ($i = 0; $i <= 100; $i++) {
|
||||
|
|
@ -184,19 +184,19 @@ class TwigExtensionTest extends \Codeception\TestCase\Test
|
|||
}
|
||||
|
||||
|
||||
$this->assertSame([0], $this->twig_ext->rangeFunc(0, 0));
|
||||
$this->assertSame([0, 1, 2], $this->twig_ext->rangeFunc(0, 2));
|
||||
self::assertSame([0], $this->twig_ext->rangeFunc(0, 0));
|
||||
self::assertSame([0, 1, 2], $this->twig_ext->rangeFunc(0, 2));
|
||||
|
||||
$this->assertSame([0, 5, 10, 15], $this->twig_ext->rangeFunc(0, 16, 5));
|
||||
self::assertSame([0, 5, 10, 15], $this->twig_ext->rangeFunc(0, 16, 5));
|
||||
|
||||
// default (min 0, max 100, step 1)
|
||||
$this->assertSame($hundred, $this->twig_ext->rangeFunc());
|
||||
self::assertSame($hundred, $this->twig_ext->rangeFunc());
|
||||
|
||||
// 95 items, starting from 5, (min 5, max 100, step 1)
|
||||
$this->assertSame(array_slice($hundred, 5), $this->twig_ext->rangeFunc(5));
|
||||
self::assertSame(array_slice($hundred, 5), $this->twig_ext->rangeFunc(5));
|
||||
|
||||
// reversed range
|
||||
$this->assertSame(array_reverse($hundred), $this->twig_ext->rangeFunc(100, 0));
|
||||
$this->assertSame([4, 2, 0], $this->twig_ext->rangeFunc(4, 0, 2));
|
||||
self::assertSame(array_reverse($hundred), $this->twig_ext->rangeFunc(100, 0));
|
||||
self::assertSame([4, 2, 0], $this->twig_ext->rangeFunc(4, 0, 2));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -854,18 +854,18 @@ class UriTest extends \Codeception\TestCase\Test
|
|||
],
|
||||
];
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$grav = Fixtures::get('grav');
|
||||
$this->grav = $grav();
|
||||
$this->uri = $this->grav['uri'];
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
}
|
||||
|
||||
protected function runTestSet(array $tests, $method, $params = [])
|
||||
protected function runTestSet(array $tests, $method, $params = []): void
|
||||
{
|
||||
foreach ($tests as $url => $candidates) {
|
||||
if (!array_key_exists($method, $candidates) && $method !== 'toOriginalString') {
|
||||
|
|
@ -875,7 +875,7 @@ class UriTest extends \Codeception\TestCase\Test
|
|||
$nonce = Utils::getNonce('test-action');
|
||||
$expected = str_replace('{{nonce}}', $nonce, $candidates[$method]);
|
||||
|
||||
$this->assertSame($expected, Uri::addNonce($url, 'test-action'));
|
||||
self::assertSame($expected, Uri::addNonce($url, 'test-action'));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
|
@ -893,213 +893,213 @@ class UriTest extends \Codeception\TestCase\Test
|
|||
$result = $this->uri->{$method}();
|
||||
}
|
||||
|
||||
$this->assertSame($expected, $result, "Test \$url->{$method}() for {$url}");
|
||||
self::assertSame($expected, $result, "Test \$url->{$method}() for {$url}");
|
||||
// Deal with $url->query($key)
|
||||
if ($method === 'query') {
|
||||
parse_str($expected, $queryParams);
|
||||
foreach ($queryParams as $key => $value) {
|
||||
$this->assertSame($value, $this->uri->{$method}($key), "Test \$url->{$method}('{$key}') for {$url}");
|
||||
self::assertSame($value, $this->uri->{$method}($key), "Test \$url->{$method}('{$key}') for {$url}");
|
||||
}
|
||||
$this->assertNull($this->uri->{$method}('non-existing'), "Test \$url->{$method}('non-existing') for {$url}");
|
||||
self::assertNull($this->uri->{$method}('non-existing'), "Test \$url->{$method}('non-existing') for {$url}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testValidatingHostname()
|
||||
public function testValidatingHostname(): void
|
||||
{
|
||||
$this->assertTrue($this->uri->validateHostname('localhost'));
|
||||
$this->assertTrue($this->uri->validateHostname('google.com'));
|
||||
$this->assertTrue($this->uri->validateHostname('google.it'));
|
||||
$this->assertTrue($this->uri->validateHostname('goog.le'));
|
||||
$this->assertTrue($this->uri->validateHostname('goog.wine'));
|
||||
$this->assertTrue($this->uri->validateHostname('goog.localhost'));
|
||||
self::assertTrue($this->uri->validateHostname('localhost'));
|
||||
self::assertTrue($this->uri->validateHostname('google.com'));
|
||||
self::assertTrue($this->uri->validateHostname('google.it'));
|
||||
self::assertTrue($this->uri->validateHostname('goog.le'));
|
||||
self::assertTrue($this->uri->validateHostname('goog.wine'));
|
||||
self::assertTrue($this->uri->validateHostname('goog.localhost'));
|
||||
|
||||
$this->assertFalse($this->uri->validateHostname('localhost:80'));
|
||||
$this->assertFalse($this->uri->validateHostname('http://localhost'));
|
||||
$this->assertFalse($this->uri->validateHostname('localhost!'));
|
||||
self::assertFalse($this->uri->validateHostname('localhost:80'));
|
||||
self::assertFalse($this->uri->validateHostname('http://localhost'));
|
||||
self::assertFalse($this->uri->validateHostname('localhost!'));
|
||||
}
|
||||
|
||||
public function testToString()
|
||||
public function testToString(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'toOriginalString');
|
||||
}
|
||||
|
||||
public function testScheme()
|
||||
public function testScheme(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'scheme');
|
||||
}
|
||||
|
||||
public function testUser()
|
||||
public function testUser(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'user');
|
||||
}
|
||||
|
||||
public function testPassword()
|
||||
public function testPassword(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'password');
|
||||
}
|
||||
|
||||
public function testHost()
|
||||
public function testHost(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'host');
|
||||
}
|
||||
|
||||
public function testPort()
|
||||
public function testPort(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'port');
|
||||
}
|
||||
|
||||
public function testPath()
|
||||
public function testPath(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'path');
|
||||
}
|
||||
|
||||
public function testQuery()
|
||||
public function testQuery(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'query');
|
||||
}
|
||||
|
||||
public function testFragment()
|
||||
public function testFragment(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'fragment');
|
||||
|
||||
$this->uri->fragment('something-new');
|
||||
$this->assertSame('something-new', $this->uri->fragment());
|
||||
self::assertSame('something-new', $this->uri->fragment());
|
||||
}
|
||||
|
||||
public function testPaths()
|
||||
public function testPaths(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'paths');
|
||||
}
|
||||
|
||||
public function testRoute()
|
||||
public function testRoute(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'route');
|
||||
}
|
||||
|
||||
public function testParams()
|
||||
public function testParams(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'params');
|
||||
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame('/ueper:xxx', $this->uri->params('ueper'));
|
||||
self::assertSame('/ueper:xxx', $this->uri->params('ueper'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init();
|
||||
$this->assertSame('/ueper:xxx', $this->uri->params('ueper'));
|
||||
$this->assertSame('/test:yyy', $this->uri->params('test'));
|
||||
self::assertSame('/ueper:xxx', $this->uri->params('ueper'));
|
||||
self::assertSame('/test:yyy', $this->uri->params('test'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx++/test:yyy')->init();
|
||||
$this->assertSame('/ueper:xxx++/test:yyy', $this->uri->params());
|
||||
$this->assertSame('/ueper:xxx++', $this->uri->params('ueper'));
|
||||
$this->assertSame('/test:yyy', $this->uri->params('test'));
|
||||
self::assertSame('/ueper:xxx++/test:yyy', $this->uri->params());
|
||||
self::assertSame('/ueper:xxx++', $this->uri->params('ueper'));
|
||||
self::assertSame('/test:yyy', $this->uri->params('test'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx++/test:yyy#something')->init();
|
||||
$this->assertSame('/ueper:xxx++/test:yyy', $this->uri->params());
|
||||
$this->assertSame('/ueper:xxx++', $this->uri->params('ueper'));
|
||||
$this->assertSame('/test:yyy', $this->uri->params('test'));
|
||||
self::assertSame('/ueper:xxx++/test:yyy', $this->uri->params());
|
||||
self::assertSame('/ueper:xxx++', $this->uri->params('ueper'));
|
||||
self::assertSame('/test:yyy', $this->uri->params('test'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx++/test:yyy?foo=bar')->init();
|
||||
$this->assertSame('/ueper:xxx++/test:yyy', $this->uri->params());
|
||||
$this->assertSame('/ueper:xxx++', $this->uri->params('ueper'));
|
||||
$this->assertSame('/test:yyy', $this->uri->params('test'));
|
||||
self::assertSame('/ueper:xxx++/test:yyy', $this->uri->params());
|
||||
self::assertSame('/ueper:xxx++', $this->uri->params('ueper'));
|
||||
self::assertSame('/test:yyy', $this->uri->params('test'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init();
|
||||
$this->assertNull($this->uri->params());
|
||||
$this->assertNull($this->uri->params('ueper'));
|
||||
self::assertNull($this->uri->params());
|
||||
self::assertNull($this->uri->params('ueper'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init();
|
||||
$this->assertNull($this->uri->params());
|
||||
$this->assertNull($this->uri->params('ueper'));
|
||||
self::assertNull($this->uri->params());
|
||||
self::assertNull($this->uri->params('ueper'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init();
|
||||
$this->assertNull($this->uri->params());
|
||||
$this->assertNull($this->uri->params('ueper'));
|
||||
self::assertNull($this->uri->params());
|
||||
self::assertNull($this->uri->params('ueper'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init();
|
||||
$this->assertNull($this->uri->params());
|
||||
$this->assertNull($this->uri->params('ueper'));
|
||||
self::assertNull($this->uri->params());
|
||||
self::assertNull($this->uri->params('ueper'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init();
|
||||
$this->assertNull($this->uri->params());
|
||||
$this->assertNull($this->uri->params('ueper'));
|
||||
self::assertNull($this->uri->params());
|
||||
self::assertNull($this->uri->params('ueper'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f')->init();
|
||||
$this->assertNull($this->uri->params());
|
||||
$this->assertNull($this->uri->params('ueper'));
|
||||
self::assertNull($this->uri->params());
|
||||
self::assertNull($this->uri->params('ueper'));
|
||||
}
|
||||
|
||||
public function testParam()
|
||||
public function testParam(): void
|
||||
{
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame('xxx', $this->uri->param('ueper'));
|
||||
self::assertSame('xxx', $this->uri->param('ueper'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init();
|
||||
$this->assertSame('xxx', $this->uri->param('ueper'));
|
||||
$this->assertSame('yyy', $this->uri->param('test'));
|
||||
self::assertSame('xxx', $this->uri->param('ueper'));
|
||||
self::assertSame('yyy', $this->uri->param('test'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx++/test:yy%20y/foo:bar_baz-bank')->init();
|
||||
$this->assertSame('xxx++', $this->uri->param('ueper'));
|
||||
$this->assertSame('yy y', $this->uri->param('test'));
|
||||
$this->assertSame('bar_baz-bank', $this->uri->param('foo'));
|
||||
self::assertSame('xxx++', $this->uri->param('ueper'));
|
||||
self::assertSame('yy y', $this->uri->param('test'));
|
||||
self::assertSame('bar_baz-bank', $this->uri->param('foo'));
|
||||
}
|
||||
|
||||
public function testUrl()
|
||||
public function testUrl(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'url');
|
||||
}
|
||||
|
||||
public function testExtension()
|
||||
public function testExtension(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'extension');
|
||||
|
||||
$this->uri->initializeWithURL('http://localhost/a-page')->init();
|
||||
$this->assertSame('x', $this->uri->extension('x'));
|
||||
self::assertSame('x', $this->uri->extension('x'));
|
||||
}
|
||||
|
||||
public function testEnvironment()
|
||||
public function testEnvironment(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'environment');
|
||||
}
|
||||
|
||||
public function testBasename()
|
||||
public function testBasename(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'basename');
|
||||
}
|
||||
|
||||
public function testBase()
|
||||
public function testBase(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'base');
|
||||
}
|
||||
|
||||
public function testRootUrl()
|
||||
public function testRootUrl(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'rootUrl', [true]);
|
||||
|
||||
$this->uri->initializeWithUrlAndRootPath('https://localhost/grav/page-foo', '/grav')->init();
|
||||
$this->assertSame('/grav', $this->uri->rootUrl());
|
||||
$this->assertSame('https://localhost/grav', $this->uri->rootUrl(true));
|
||||
self::assertSame('/grav', $this->uri->rootUrl());
|
||||
self::assertSame('https://localhost/grav', $this->uri->rootUrl(true));
|
||||
}
|
||||
|
||||
public function testCurrentPage()
|
||||
public function testCurrentPage(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'currentPage');
|
||||
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a-page/page:2')->init();
|
||||
$this->assertSame(2, $this->uri->currentPage());
|
||||
self::assertSame(2, $this->uri->currentPage());
|
||||
}
|
||||
|
||||
public function testReferrer()
|
||||
public function testReferrer(): void
|
||||
{
|
||||
$this->uri->initializeWithURL('http://localhost/foo/page:test')->init();
|
||||
$this->assertSame('/foo', $this->uri->referrer());
|
||||
self::assertSame('/foo', $this->uri->referrer());
|
||||
$this->uri->initializeWithURL('http://localhost/foo/bar/page:test')->init();
|
||||
$this->assertSame('/foo/bar', $this->uri->referrer());
|
||||
self::assertSame('/foo/bar', $this->uri->referrer());
|
||||
}
|
||||
|
||||
public function testIp()
|
||||
public function testIp(): void
|
||||
{
|
||||
$this->uri->initializeWithURL('http://localhost/foo/page:test')->init();
|
||||
$this->assertSame('UNKNOWN', Uri::ip());
|
||||
self::assertSame('UNKNOWN', Uri::ip());
|
||||
}
|
||||
|
||||
public function testIsExternal()
|
||||
public function testIsExternal(): void
|
||||
{
|
||||
$this->uri->initializeWithURL('http://localhost/')->init();
|
||||
$this->assertFalse(Uri::isExternal('/test'));
|
||||
$this->assertFalse(Uri::isExternal('/foo/bar'));
|
||||
$this->assertTrue(Uri::isExternal('http://localhost/test'));
|
||||
$this->assertTrue(Uri::isExternal('http://google.it/test'));
|
||||
self::assertFalse(Uri::isExternal('/test'));
|
||||
self::assertFalse(Uri::isExternal('/foo/bar'));
|
||||
self::assertTrue(Uri::isExternal('http://localhost/test'));
|
||||
self::assertTrue(Uri::isExternal('http://google.it/test'));
|
||||
}
|
||||
|
||||
public function testBuildUrl()
|
||||
public function testBuildUrl(): void
|
||||
{
|
||||
$parsed_url = [
|
||||
'scheme' => 'http',
|
||||
|
|
@ -1107,7 +1107,7 @@ class UriTest extends \Codeception\TestCase\Test
|
|||
'port' => 8080,
|
||||
];
|
||||
|
||||
$this->assertSame('http://localhost:8080', Uri::buildUrl($parsed_url));
|
||||
self::assertSame('http://localhost:8080', Uri::buildUrl($parsed_url));
|
||||
|
||||
$parsed_url = [
|
||||
'scheme' => 'http',
|
||||
|
|
@ -1120,32 +1120,32 @@ class UriTest extends \Codeception\TestCase\Test
|
|||
'fragment' => 'xxx',
|
||||
];
|
||||
|
||||
$this->assertSame('http://foo:bar@localhost:8080/test?x=2#xxx', Uri::buildUrl($parsed_url));
|
||||
self::assertSame('http://foo:bar@localhost:8080/test?x=2#xxx', Uri::buildUrl($parsed_url));
|
||||
|
||||
/** @var Uri $uri */
|
||||
$uri = Grav::instance()['uri'];
|
||||
|
||||
$uri->initializeWithUrlAndRootPath('https://testing.dev/subdir/path1/path2/file.html', '/subdir')->init();
|
||||
$this->assertSame('https://testing.dev/subdir/path1/path2/file.html', Uri::buildUrl($uri->toArray(true)));
|
||||
self::assertSame('https://testing.dev/subdir/path1/path2/file.html', Uri::buildUrl($uri->toArray(true)));
|
||||
|
||||
$uri->initializeWithUrlAndRootPath('https://testing.dev/subdir/path1/path2/file.foo', '/subdir')->init();
|
||||
$this->assertSame('https://testing.dev/subdir/path1/path2/file.foo', Uri::buildUrl($uri->toArray(true)));
|
||||
self::assertSame('https://testing.dev/subdir/path1/path2/file.foo', Uri::buildUrl($uri->toArray(true)));
|
||||
|
||||
$uri->initializeWithUrlAndRootPath('https://testing.dev/subdir/path1/path2/file.html', '/subdir/path1')->init();
|
||||
$this->assertSame('https://testing.dev/subdir/path1/path2/file.html', Uri::buildUrl($uri->toArray(true)));
|
||||
self::assertSame('https://testing.dev/subdir/path1/path2/file.html', Uri::buildUrl($uri->toArray(true)));
|
||||
|
||||
$uri->initializeWithUrlAndRootPath('https://testing.dev/subdir/path1/path2/file.html/foo:blah/bang:boom', '/subdir')->init();
|
||||
$this->assertSame('https://testing.dev/subdir/path1/path2/file.html/foo:blah/bang:boom', Uri::buildUrl($uri->toArray(true)));
|
||||
self::assertSame('https://testing.dev/subdir/path1/path2/file.html/foo:blah/bang:boom', Uri::buildUrl($uri->toArray(true)));
|
||||
|
||||
$uri->initializeWithUrlAndRootPath('https://testing.dev/subdir/path1/path2/file.html/foo:blah/bang:boom?fig=something', '/subdir')->init();
|
||||
$this->assertSame('https://testing.dev/subdir/path1/path2/file.html/foo:blah/bang:boom?fig=something', Uri::buildUrl($uri->toArray(true)));
|
||||
self::assertSame('https://testing.dev/subdir/path1/path2/file.html/foo:blah/bang:boom?fig=something', Uri::buildUrl($uri->toArray(true)));
|
||||
}
|
||||
|
||||
public function testConvertUrl()
|
||||
public function testConvertUrl(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testAddNonce()
|
||||
public function testAddNonce(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'addNonce');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,113 +16,113 @@ class UtilsTest extends \Codeception\TestCase\Test
|
|||
/** @var Uri $uri */
|
||||
protected $uri;
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$grav = Fixtures::get('grav');
|
||||
$this->grav = $grav();
|
||||
$this->uri = $this->grav['uri'];
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testStartsWith()
|
||||
public function testStartsWith(): void
|
||||
{
|
||||
$this->assertTrue(Utils::startsWith('english', 'en'));
|
||||
$this->assertTrue(Utils::startsWith('English', 'En'));
|
||||
$this->assertTrue(Utils::startsWith('ENGLISH', 'EN'));
|
||||
$this->assertTrue(Utils::startsWith(
|
||||
self::assertTrue(Utils::startsWith('english', 'en'));
|
||||
self::assertTrue(Utils::startsWith('English', 'En'));
|
||||
self::assertTrue(Utils::startsWith('ENGLISH', 'EN'));
|
||||
self::assertTrue(Utils::startsWith(
|
||||
'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'EN'
|
||||
));
|
||||
|
||||
$this->assertFalse(Utils::startsWith('english', 'En'));
|
||||
$this->assertFalse(Utils::startsWith('English', 'EN'));
|
||||
$this->assertFalse(Utils::startsWith('ENGLISH', 'en'));
|
||||
$this->assertFalse(Utils::startsWith(
|
||||
self::assertFalse(Utils::startsWith('english', 'En'));
|
||||
self::assertFalse(Utils::startsWith('English', 'EN'));
|
||||
self::assertFalse(Utils::startsWith('ENGLISH', 'en'));
|
||||
self::assertFalse(Utils::startsWith(
|
||||
'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'e'
|
||||
));
|
||||
|
||||
$this->assertTrue(Utils::startsWith('english', 'En', false));
|
||||
$this->assertTrue(Utils::startsWith('English', 'EN', false));
|
||||
$this->assertTrue(Utils::startsWith('ENGLISH', 'en', false));
|
||||
$this->assertTrue(Utils::startsWith(
|
||||
self::assertTrue(Utils::startsWith('english', 'En', false));
|
||||
self::assertTrue(Utils::startsWith('English', 'EN', false));
|
||||
self::assertTrue(Utils::startsWith('ENGLISH', 'en', false));
|
||||
self::assertTrue(Utils::startsWith(
|
||||
'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'e',
|
||||
false
|
||||
));
|
||||
}
|
||||
|
||||
public function testEndsWith()
|
||||
public function testEndsWith(): void
|
||||
{
|
||||
$this->assertTrue(Utils::endsWith('english', 'sh'));
|
||||
$this->assertTrue(Utils::endsWith('EngliSh', 'Sh'));
|
||||
$this->assertTrue(Utils::endsWith('ENGLISH', 'SH'));
|
||||
$this->assertTrue(Utils::endsWith(
|
||||
self::assertTrue(Utils::endsWith('english', 'sh'));
|
||||
self::assertTrue(Utils::endsWith('EngliSh', 'Sh'));
|
||||
self::assertTrue(Utils::endsWith('ENGLISH', 'SH'));
|
||||
self::assertTrue(Utils::endsWith(
|
||||
'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'ENGLISH'
|
||||
));
|
||||
|
||||
$this->assertFalse(Utils::endsWith('english', 'de'));
|
||||
$this->assertFalse(Utils::endsWith('EngliSh', 'sh'));
|
||||
$this->assertFalse(Utils::endsWith('ENGLISH', 'Sh'));
|
||||
$this->assertFalse(Utils::endsWith(
|
||||
self::assertFalse(Utils::endsWith('english', 'de'));
|
||||
self::assertFalse(Utils::endsWith('EngliSh', 'sh'));
|
||||
self::assertFalse(Utils::endsWith('ENGLISH', 'Sh'));
|
||||
self::assertFalse(Utils::endsWith(
|
||||
'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'DEUSTCH'
|
||||
));
|
||||
|
||||
$this->assertTrue(Utils::endsWith('english', 'SH', false));
|
||||
$this->assertTrue(Utils::endsWith('EngliSh', 'sH', false));
|
||||
$this->assertTrue(Utils::endsWith('ENGLISH', 'sh', false));
|
||||
$this->assertTrue(Utils::endsWith(
|
||||
self::assertTrue(Utils::endsWith('english', 'SH', false));
|
||||
self::assertTrue(Utils::endsWith('EngliSh', 'sH', false));
|
||||
self::assertTrue(Utils::endsWith('ENGLISH', 'sh', false));
|
||||
self::assertTrue(Utils::endsWith(
|
||||
'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'english',
|
||||
false
|
||||
));
|
||||
}
|
||||
|
||||
public function testContains()
|
||||
public function testContains(): void
|
||||
{
|
||||
$this->assertTrue(Utils::contains('english', 'nglis'));
|
||||
$this->assertTrue(Utils::contains('EngliSh', 'gliSh'));
|
||||
$this->assertTrue(Utils::contains('ENGLISH', 'ENGLI'));
|
||||
$this->assertTrue(Utils::contains(
|
||||
self::assertTrue(Utils::contains('english', 'nglis'));
|
||||
self::assertTrue(Utils::contains('EngliSh', 'gliSh'));
|
||||
self::assertTrue(Utils::contains('ENGLISH', 'ENGLI'));
|
||||
self::assertTrue(Utils::contains(
|
||||
'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'ENGLISH'
|
||||
));
|
||||
|
||||
$this->assertFalse(Utils::contains('EngliSh', 'GLI'));
|
||||
$this->assertFalse(Utils::contains('EngliSh', 'English'));
|
||||
$this->assertFalse(Utils::contains('ENGLISH', 'SCH'));
|
||||
$this->assertFalse(Utils::contains(
|
||||
self::assertFalse(Utils::contains('EngliSh', 'GLI'));
|
||||
self::assertFalse(Utils::contains('EngliSh', 'English'));
|
||||
self::assertFalse(Utils::contains('ENGLISH', 'SCH'));
|
||||
self::assertFalse(Utils::contains(
|
||||
'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'DEUSTCH'
|
||||
));
|
||||
|
||||
$this->assertTrue(Utils::contains('EngliSh', 'GLI', false));
|
||||
$this->assertTrue(Utils::contains('EngliSh', 'ENGLISH', false));
|
||||
$this->assertTrue(Utils::contains('ENGLISH', 'ish', false));
|
||||
$this->assertTrue(Utils::contains(
|
||||
self::assertTrue(Utils::contains('EngliSh', 'GLI', false));
|
||||
self::assertTrue(Utils::contains('EngliSh', 'ENGLISH', false));
|
||||
self::assertTrue(Utils::contains('ENGLISH', 'ish', false));
|
||||
self::assertTrue(Utils::contains(
|
||||
'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'english',
|
||||
false
|
||||
));
|
||||
}
|
||||
|
||||
public function testSubstrToString()
|
||||
public function testSubstrToString(): void
|
||||
{
|
||||
$this->assertEquals('en', Utils::substrToString('english', 'glish'));
|
||||
$this->assertEquals('english', Utils::substrToString('english', 'test'));
|
||||
$this->assertNotEquals('en', Utils::substrToString('english', 'lish'));
|
||||
self::assertEquals('en', Utils::substrToString('english', 'glish'));
|
||||
self::assertEquals('english', Utils::substrToString('english', 'test'));
|
||||
self::assertNotEquals('en', Utils::substrToString('english', 'lish'));
|
||||
|
||||
$this->assertEquals('en', Utils::substrToString('english', 'GLISH', false));
|
||||
$this->assertEquals('english', Utils::substrToString('english', 'TEST', false));
|
||||
$this->assertNotEquals('en', Utils::substrToString('english', 'LISH', false));
|
||||
self::assertEquals('en', Utils::substrToString('english', 'GLISH', false));
|
||||
self::assertEquals('english', Utils::substrToString('english', 'TEST', false));
|
||||
self::assertNotEquals('en', Utils::substrToString('english', 'LISH', false));
|
||||
}
|
||||
|
||||
public function testMergeObjects()
|
||||
public function testMergeObjects(): void
|
||||
{
|
||||
$obj1 = new stdClass();
|
||||
$obj1->test1 = 'x';
|
||||
|
|
@ -131,150 +131,150 @@ class UtilsTest extends \Codeception\TestCase\Test
|
|||
|
||||
$objMerged = Utils::mergeObjects($obj1, $obj2);
|
||||
|
||||
$this->assertObjectHasAttribute('test1', $objMerged);
|
||||
$this->assertObjectHasAttribute('test2', $objMerged);
|
||||
self::assertObjectHasAttribute('test1', $objMerged);
|
||||
self::assertObjectHasAttribute('test2', $objMerged);
|
||||
}
|
||||
|
||||
public function testDateFormats()
|
||||
public function testDateFormats(): void
|
||||
{
|
||||
$dateFormats = Utils::dateFormats();
|
||||
$this->assertIsArray($dateFormats);
|
||||
$this->assertContainsOnly('string', $dateFormats);
|
||||
self::assertIsArray($dateFormats);
|
||||
self::assertContainsOnly('string', $dateFormats);
|
||||
|
||||
$default_format = $this->grav['config']->get('system.pages.dateformat.default');
|
||||
|
||||
if ($default_format !== null) {
|
||||
$this->assertArrayHasKey($default_format, $dateFormats);
|
||||
self::assertArrayHasKey($default_format, $dateFormats);
|
||||
}
|
||||
}
|
||||
|
||||
public function testTruncate()
|
||||
public function testTruncate(): void
|
||||
{
|
||||
$this->assertEquals('engli' . '…', Utils::truncate('english', 5));
|
||||
$this->assertEquals('english', Utils::truncate('english'));
|
||||
$this->assertEquals('This is a string to truncate', Utils::truncate('This is a string to truncate'));
|
||||
$this->assertEquals('Th' . '…', Utils::truncate('This is a string to truncate', 2));
|
||||
$this->assertEquals('engli' . '...', Utils::truncate('english', 5, true, " ", "..."));
|
||||
$this->assertEquals('english', Utils::truncate('english'));
|
||||
$this->assertEquals('This is a string to truncate', Utils::truncate('This is a string to truncate'));
|
||||
$this->assertEquals('This' . '…', Utils::truncate('This is a string to truncate', 3, true));
|
||||
$this->assertEquals('<input' . '…', Utils::truncate('<input type="file" id="file" multiple />', 6, true));
|
||||
self::assertEquals('engli' . '…', Utils::truncate('english', 5));
|
||||
self::assertEquals('english', Utils::truncate('english'));
|
||||
self::assertEquals('This is a string to truncate', Utils::truncate('This is a string to truncate'));
|
||||
self::assertEquals('Th' . '…', Utils::truncate('This is a string to truncate', 2));
|
||||
self::assertEquals('engli' . '...', Utils::truncate('english', 5, true, " ", "..."));
|
||||
self::assertEquals('english', Utils::truncate('english'));
|
||||
self::assertEquals('This is a string to truncate', Utils::truncate('This is a string to truncate'));
|
||||
self::assertEquals('This' . '…', Utils::truncate('This is a string to truncate', 3, true));
|
||||
self::assertEquals('<input' . '…', Utils::truncate('<input type="file" id="file" multiple />', 6, true));
|
||||
}
|
||||
|
||||
public function testSafeTruncate()
|
||||
public function testSafeTruncate(): void
|
||||
{
|
||||
$this->assertEquals('This' . '…', Utils::safeTruncate('This is a string to truncate', 1));
|
||||
$this->assertEquals('This' . '…', Utils::safeTruncate('This is a string to truncate', 4));
|
||||
$this->assertEquals('This is' . '…', Utils::safeTruncate('This is a string to truncate', 5));
|
||||
self::assertEquals('This' . '…', Utils::safeTruncate('This is a string to truncate', 1));
|
||||
self::assertEquals('This' . '…', Utils::safeTruncate('This is a string to truncate', 4));
|
||||
self::assertEquals('This is' . '…', Utils::safeTruncate('This is a string to truncate', 5));
|
||||
}
|
||||
|
||||
public function testTruncateHtml()
|
||||
public function testTruncateHtml(): void
|
||||
{
|
||||
$this->assertEquals('T...', Utils::truncateHtml('This is a string to truncate', 1));
|
||||
$this->assertEquals('This is...', Utils::truncateHtml('This is a string to truncate', 7));
|
||||
$this->assertEquals('<p>T...</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 1));
|
||||
$this->assertEquals('<p>This...</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 4));
|
||||
$this->assertEquals('<p>This is a...</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 10));
|
||||
$this->assertEquals('<p>This is a string to truncate</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 100));
|
||||
$this->assertEquals('<input type="file" id="file" multiple />', Utils::truncateHtml('<input type="file" id="file" multiple />', 6));
|
||||
$this->assertEquals('<ol><li>item 1 <i>so...</i></li></ol>', Utils::truncateHtml('<ol><li>item 1 <i>something</i></li><li>item 2 <strong>bold</strong></li></ol>', 10));
|
||||
$this->assertEquals("<p>This is a string.</p>\n<p>It splits two lines.</p>", Utils::truncateHtml("<p>This is a string.</p>\n<p>It splits two lines.</p>", 100));
|
||||
self::assertEquals('T...', Utils::truncateHtml('This is a string to truncate', 1));
|
||||
self::assertEquals('This is...', Utils::truncateHtml('This is a string to truncate', 7));
|
||||
self::assertEquals('<p>T...</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 1));
|
||||
self::assertEquals('<p>This...</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 4));
|
||||
self::assertEquals('<p>This is a...</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 10));
|
||||
self::assertEquals('<p>This is a string to truncate</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 100));
|
||||
self::assertEquals('<input type="file" id="file" multiple />', Utils::truncateHtml('<input type="file" id="file" multiple />', 6));
|
||||
self::assertEquals('<ol><li>item 1 <i>so...</i></li></ol>', Utils::truncateHtml('<ol><li>item 1 <i>something</i></li><li>item 2 <strong>bold</strong></li></ol>', 10));
|
||||
self::assertEquals("<p>This is a string.</p>\n<p>It splits two lines.</p>", Utils::truncateHtml("<p>This is a string.</p>\n<p>It splits two lines.</p>", 100));
|
||||
}
|
||||
|
||||
public function testSafeTruncateHtml()
|
||||
public function testSafeTruncateHtml(): void
|
||||
{
|
||||
$this->assertEquals('This...', Utils::safeTruncateHtml('This is a string to truncate', 1));
|
||||
$this->assertEquals('This is a...', Utils::safeTruncateHtml('This is a string to truncate', 3));
|
||||
$this->assertEquals('<p>This...</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 1));
|
||||
$this->assertEquals('<p>This is...</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 2));
|
||||
$this->assertEquals('<p>This is a string to...</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 5));
|
||||
$this->assertEquals('<p>This is a string to truncate</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 20));
|
||||
$this->assertEquals('<input type="file" id="file" multiple />', Utils::safeTruncateHtml('<input type="file" id="file" multiple />', 6));
|
||||
$this->assertEquals('<ol><li>item 1 <i>something</i></li><li>item 2...</li></ol>', Utils::safeTruncateHtml('<ol><li>item 1 <i>something</i></li><li>item 2 <strong>bold</strong></li></ol>', 5));
|
||||
self::assertEquals('This...', Utils::safeTruncateHtml('This is a string to truncate', 1));
|
||||
self::assertEquals('This is a...', Utils::safeTruncateHtml('This is a string to truncate', 3));
|
||||
self::assertEquals('<p>This...</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 1));
|
||||
self::assertEquals('<p>This is...</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 2));
|
||||
self::assertEquals('<p>This is a string to...</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 5));
|
||||
self::assertEquals('<p>This is a string to truncate</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 20));
|
||||
self::assertEquals('<input type="file" id="file" multiple />', Utils::safeTruncateHtml('<input type="file" id="file" multiple />', 6));
|
||||
self::assertEquals('<ol><li>item 1 <i>something</i></li><li>item 2...</li></ol>', Utils::safeTruncateHtml('<ol><li>item 1 <i>something</i></li><li>item 2 <strong>bold</strong></li></ol>', 5));
|
||||
}
|
||||
|
||||
public function testGenerateRandomString()
|
||||
public function testGenerateRandomString(): void
|
||||
{
|
||||
$this->assertNotEquals(Utils::generateRandomString(), Utils::generateRandomString());
|
||||
$this->assertNotEquals(Utils::generateRandomString(20), Utils::generateRandomString(20));
|
||||
self::assertNotEquals(Utils::generateRandomString(), Utils::generateRandomString());
|
||||
self::assertNotEquals(Utils::generateRandomString(20), Utils::generateRandomString(20));
|
||||
}
|
||||
|
||||
public function download()
|
||||
public function download(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testGetMimeByExtension()
|
||||
public function testGetMimeByExtension(): void
|
||||
{
|
||||
$this->assertEquals('application/octet-stream', Utils::getMimeByExtension(''));
|
||||
$this->assertEquals('text/html', Utils::getMimeByExtension('html'));
|
||||
$this->assertEquals('application/json', Utils::getMimeByExtension('json'));
|
||||
$this->assertEquals('application/atom+xml', Utils::getMimeByExtension('atom'));
|
||||
$this->assertEquals('application/rss+xml', Utils::getMimeByExtension('rss'));
|
||||
$this->assertEquals('image/jpeg', Utils::getMimeByExtension('jpg'));
|
||||
$this->assertEquals('image/png', Utils::getMimeByExtension('png'));
|
||||
$this->assertEquals('text/plain', Utils::getMimeByExtension('txt'));
|
||||
$this->assertEquals('application/msword', Utils::getMimeByExtension('doc'));
|
||||
$this->assertEquals('application/octet-stream', Utils::getMimeByExtension('foo'));
|
||||
$this->assertEquals('foo/bar', Utils::getMimeByExtension('foo', 'foo/bar'));
|
||||
$this->assertEquals('text/html', Utils::getMimeByExtension('foo', 'text/html'));
|
||||
self::assertEquals('application/octet-stream', Utils::getMimeByExtension(''));
|
||||
self::assertEquals('text/html', Utils::getMimeByExtension('html'));
|
||||
self::assertEquals('application/json', Utils::getMimeByExtension('json'));
|
||||
self::assertEquals('application/atom+xml', Utils::getMimeByExtension('atom'));
|
||||
self::assertEquals('application/rss+xml', Utils::getMimeByExtension('rss'));
|
||||
self::assertEquals('image/jpeg', Utils::getMimeByExtension('jpg'));
|
||||
self::assertEquals('image/png', Utils::getMimeByExtension('png'));
|
||||
self::assertEquals('text/plain', Utils::getMimeByExtension('txt'));
|
||||
self::assertEquals('application/msword', Utils::getMimeByExtension('doc'));
|
||||
self::assertEquals('application/octet-stream', Utils::getMimeByExtension('foo'));
|
||||
self::assertEquals('foo/bar', Utils::getMimeByExtension('foo', 'foo/bar'));
|
||||
self::assertEquals('text/html', Utils::getMimeByExtension('foo', 'text/html'));
|
||||
}
|
||||
|
||||
public function testGetExtensionByMime()
|
||||
public function testGetExtensionByMime(): void
|
||||
{
|
||||
$this->assertEquals('html', Utils::getExtensionByMime('*/*'));
|
||||
$this->assertEquals('html', Utils::getExtensionByMime('text/*'));
|
||||
$this->assertEquals('html', Utils::getExtensionByMime('text/html'));
|
||||
$this->assertEquals('json', Utils::getExtensionByMime('application/json'));
|
||||
$this->assertEquals('atom', Utils::getExtensionByMime('application/atom+xml'));
|
||||
$this->assertEquals('rss', Utils::getExtensionByMime('application/rss+xml'));
|
||||
$this->assertEquals('jpg', Utils::getExtensionByMime('image/jpeg'));
|
||||
$this->assertEquals('png', Utils::getExtensionByMime('image/png'));
|
||||
$this->assertEquals('txt', Utils::getExtensionByMime('text/plain'));
|
||||
$this->assertEquals('doc', Utils::getExtensionByMime('application/msword'));
|
||||
$this->assertEquals('html', Utils::getExtensionByMime('foo/bar'));
|
||||
$this->assertEquals('baz', Utils::getExtensionByMime('foo/bar', 'baz'));
|
||||
self::assertEquals('html', Utils::getExtensionByMime('*/*'));
|
||||
self::assertEquals('html', Utils::getExtensionByMime('text/*'));
|
||||
self::assertEquals('html', Utils::getExtensionByMime('text/html'));
|
||||
self::assertEquals('json', Utils::getExtensionByMime('application/json'));
|
||||
self::assertEquals('atom', Utils::getExtensionByMime('application/atom+xml'));
|
||||
self::assertEquals('rss', Utils::getExtensionByMime('application/rss+xml'));
|
||||
self::assertEquals('jpg', Utils::getExtensionByMime('image/jpeg'));
|
||||
self::assertEquals('png', Utils::getExtensionByMime('image/png'));
|
||||
self::assertEquals('txt', Utils::getExtensionByMime('text/plain'));
|
||||
self::assertEquals('doc', Utils::getExtensionByMime('application/msword'));
|
||||
self::assertEquals('html', Utils::getExtensionByMime('foo/bar'));
|
||||
self::assertEquals('baz', Utils::getExtensionByMime('foo/bar', 'baz'));
|
||||
}
|
||||
|
||||
public function testNormalizePath()
|
||||
public function testNormalizePath(): void
|
||||
{
|
||||
$this->assertEquals('/test', Utils::normalizePath('/test'));
|
||||
$this->assertEquals('test', Utils::normalizePath('test'));
|
||||
$this->assertEquals('test', Utils::normalizePath('../test'));
|
||||
$this->assertEquals('/test', Utils::normalizePath('/../test'));
|
||||
$this->assertEquals('/test2', Utils::normalizePath('/test/../test2'));
|
||||
$this->assertEquals('/test3', Utils::normalizePath('/test/../test2/../test3'));
|
||||
self::assertEquals('/test', Utils::normalizePath('/test'));
|
||||
self::assertEquals('test', Utils::normalizePath('test'));
|
||||
self::assertEquals('test', Utils::normalizePath('../test'));
|
||||
self::assertEquals('/test', Utils::normalizePath('/../test'));
|
||||
self::assertEquals('/test2', Utils::normalizePath('/test/../test2'));
|
||||
self::assertEquals('/test3', Utils::normalizePath('/test/../test2/../test3'));
|
||||
|
||||
$this->assertEquals('//cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css', Utils::normalizePath('//cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css'));
|
||||
$this->assertEquals('//use.fontawesome.com/releases/v5.8.1/css/all.css', Utils::normalizePath('//use.fontawesome.com/releases/v5.8.1/css/all.css'));
|
||||
$this->assertEquals('//use.fontawesome.com/releases/v5.8.1/webfonts/fa-brands-400.eot', Utils::normalizePath('//use.fontawesome.com/releases/v5.8.1/css/../webfonts/fa-brands-400.eot'));
|
||||
self::assertEquals('//cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css', Utils::normalizePath('//cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css'));
|
||||
self::assertEquals('//use.fontawesome.com/releases/v5.8.1/css/all.css', Utils::normalizePath('//use.fontawesome.com/releases/v5.8.1/css/all.css'));
|
||||
self::assertEquals('//use.fontawesome.com/releases/v5.8.1/webfonts/fa-brands-400.eot', Utils::normalizePath('//use.fontawesome.com/releases/v5.8.1/css/../webfonts/fa-brands-400.eot'));
|
||||
|
||||
$this->assertEquals('http://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css', Utils::normalizePath('http://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css'));
|
||||
$this->assertEquals('http://use.fontawesome.com/releases/v5.8.1/css/all.css', Utils::normalizePath('http://use.fontawesome.com/releases/v5.8.1/css/all.css'));
|
||||
$this->assertEquals('http://use.fontawesome.com/releases/v5.8.1/webfonts/fa-brands-400.eot', Utils::normalizePath('http://use.fontawesome.com/releases/v5.8.1/css/../webfonts/fa-brands-400.eot'));
|
||||
self::assertEquals('http://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css', Utils::normalizePath('http://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css'));
|
||||
self::assertEquals('http://use.fontawesome.com/releases/v5.8.1/css/all.css', Utils::normalizePath('http://use.fontawesome.com/releases/v5.8.1/css/all.css'));
|
||||
self::assertEquals('http://use.fontawesome.com/releases/v5.8.1/webfonts/fa-brands-400.eot', Utils::normalizePath('http://use.fontawesome.com/releases/v5.8.1/css/../webfonts/fa-brands-400.eot'));
|
||||
|
||||
$this->assertEquals('https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css', Utils::normalizePath('https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css'));
|
||||
$this->assertEquals('https://use.fontawesome.com/releases/v5.8.1/css/all.css', Utils::normalizePath('https://use.fontawesome.com/releases/v5.8.1/css/all.css'));
|
||||
$this->assertEquals('https://use.fontawesome.com/releases/v5.8.1/webfonts/fa-brands-400.eot', Utils::normalizePath('https://use.fontawesome.com/releases/v5.8.1/css/../webfonts/fa-brands-400.eot'));
|
||||
self::assertEquals('https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css', Utils::normalizePath('https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css'));
|
||||
self::assertEquals('https://use.fontawesome.com/releases/v5.8.1/css/all.css', Utils::normalizePath('https://use.fontawesome.com/releases/v5.8.1/css/all.css'));
|
||||
self::assertEquals('https://use.fontawesome.com/releases/v5.8.1/webfonts/fa-brands-400.eot', Utils::normalizePath('https://use.fontawesome.com/releases/v5.8.1/css/../webfonts/fa-brands-400.eot'));
|
||||
}
|
||||
|
||||
public function testIsFunctionDisabled()
|
||||
public function testIsFunctionDisabled(): void
|
||||
{
|
||||
$disabledFunctions = explode(',', ini_get('disable_functions'));
|
||||
|
||||
if ($disabledFunctions[0]) {
|
||||
$this->assertEquals(Utils::isFunctionDisabled($disabledFunctions[0]), true);
|
||||
self::assertEquals(Utils::isFunctionDisabled($disabledFunctions[0]), true);
|
||||
}
|
||||
}
|
||||
|
||||
public function testTimezones()
|
||||
public function testTimezones(): void
|
||||
{
|
||||
$timezones = Utils::timezones();
|
||||
|
||||
$this->assertIsArray($timezones);
|
||||
$this->assertContainsOnly('string', $timezones);
|
||||
self::assertIsArray($timezones);
|
||||
self::assertContainsOnly('string', $timezones);
|
||||
}
|
||||
|
||||
public function testArrayFilterRecursive()
|
||||
public function testArrayFilterRecursive(): void
|
||||
{
|
||||
$array = [
|
||||
'test' => '',
|
||||
|
|
@ -285,13 +285,13 @@ class UtilsTest extends \Codeception\TestCase\Test
|
|||
return !(is_null($v) || $v === '');
|
||||
});
|
||||
|
||||
$this->assertContainsOnly('string', $array);
|
||||
$this->assertArrayNotHasKey('test', $array);
|
||||
$this->assertArrayHasKey('test2', $array);
|
||||
$this->assertEquals('test2', $array['test2']);
|
||||
self::assertContainsOnly('string', $array);
|
||||
self::assertArrayNotHasKey('test', $array);
|
||||
self::assertArrayHasKey('test2', $array);
|
||||
self::assertEquals('test2', $array['test2']);
|
||||
}
|
||||
|
||||
public function testPathPrefixedByLangCode()
|
||||
public function testPathPrefixedByLangCode(): void
|
||||
{
|
||||
$languagesEnabled = $this->grav['config']->get('system.languages.supported', []);
|
||||
$arrayOfLanguages = ['en', 'de', 'it', 'es', 'dk', 'el'];
|
||||
|
|
@ -299,24 +299,24 @@ class UtilsTest extends \Codeception\TestCase\Test
|
|||
$oneLanguageNotEnabled = reset($languagesNotEnabled);
|
||||
|
||||
if (count($languagesEnabled)) {
|
||||
$this->assertTrue(Utils::pathPrefixedByLangCode('/' . $languagesEnabled[0] . '/test'));
|
||||
self::assertTrue(Utils::pathPrefixedByLangCode('/' . $languagesEnabled[0] . '/test'));
|
||||
}
|
||||
|
||||
$this->assertFalse(Utils::pathPrefixedByLangCode('/' . $oneLanguageNotEnabled . '/test'));
|
||||
$this->assertFalse(Utils::pathPrefixedByLangCode('/test'));
|
||||
$this->assertFalse(Utils::pathPrefixedByLangCode('/xx'));
|
||||
$this->assertFalse(Utils::pathPrefixedByLangCode('/xx/'));
|
||||
$this->assertFalse(Utils::pathPrefixedByLangCode('/'));
|
||||
self::assertFalse(Utils::pathPrefixedByLangCode('/' . $oneLanguageNotEnabled . '/test'));
|
||||
self::assertFalse(Utils::pathPrefixedByLangCode('/test'));
|
||||
self::assertFalse(Utils::pathPrefixedByLangCode('/xx'));
|
||||
self::assertFalse(Utils::pathPrefixedByLangCode('/xx/'));
|
||||
self::assertFalse(Utils::pathPrefixedByLangCode('/'));
|
||||
}
|
||||
|
||||
public function testDate2timestamp()
|
||||
public function testDate2timestamp(): void
|
||||
{
|
||||
$timestamp = strtotime('10 September 2000');
|
||||
$this->assertSame($timestamp, Utils::date2timestamp('10 September 2000'));
|
||||
$this->assertSame($timestamp, Utils::date2timestamp('2000-09-10 00:00:00'));
|
||||
self::assertSame($timestamp, Utils::date2timestamp('10 September 2000'));
|
||||
self::assertSame($timestamp, Utils::date2timestamp('2000-09-10 00:00:00'));
|
||||
}
|
||||
|
||||
public function testResolve()
|
||||
public function testResolve(): void
|
||||
{
|
||||
$array = [
|
||||
'test' => [
|
||||
|
|
@ -324,10 +324,10 @@ class UtilsTest extends \Codeception\TestCase\Test
|
|||
]
|
||||
];
|
||||
|
||||
$this->assertEquals('test2Value', Utils::resolve($array, 'test.test2'));
|
||||
self::assertEquals('test2Value', Utils::resolve($array, 'test.test2'));
|
||||
}
|
||||
|
||||
public function testGetDotNotation()
|
||||
public function testGetDotNotation(): void
|
||||
{
|
||||
$array = [
|
||||
'test' => [
|
||||
|
|
@ -338,12 +338,12 @@ class UtilsTest extends \Codeception\TestCase\Test
|
|||
]
|
||||
];
|
||||
|
||||
$this->assertEquals('test2Value', Utils::getDotNotation($array, 'test.test2'));
|
||||
$this->assertEquals('test4Value', Utils::getDotNotation($array, 'test.test3.test4'));
|
||||
$this->assertEquals('defaultValue', Utils::getDotNotation($array, 'test.non_existent', 'defaultValue'));
|
||||
self::assertEquals('test2Value', Utils::getDotNotation($array, 'test.test2'));
|
||||
self::assertEquals('test4Value', Utils::getDotNotation($array, 'test.test3.test4'));
|
||||
self::assertEquals('defaultValue', Utils::getDotNotation($array, 'test.non_existent', 'defaultValue'));
|
||||
}
|
||||
|
||||
public function testSetDotNotation()
|
||||
public function testSetDotNotation(): void
|
||||
{
|
||||
$array = [
|
||||
'test' => [
|
||||
|
|
@ -359,201 +359,201 @@ class UtilsTest extends \Codeception\TestCase\Test
|
|||
];
|
||||
|
||||
Utils::setDotNotation($array, 'test.test3.test4', $new);
|
||||
$this->assertEquals('test1Value', $array['test']['test3']['test4']['test1']);
|
||||
self::assertEquals('test1Value', $array['test']['test3']['test4']['test1']);
|
||||
}
|
||||
|
||||
public function testIsPositive()
|
||||
public function testIsPositive(): void
|
||||
{
|
||||
$this->assertTrue(Utils::isPositive(true));
|
||||
$this->assertTrue(Utils::isPositive(1));
|
||||
$this->assertTrue(Utils::isPositive('1'));
|
||||
$this->assertTrue(Utils::isPositive('yes'));
|
||||
$this->assertTrue(Utils::isPositive('on'));
|
||||
$this->assertTrue(Utils::isPositive('true'));
|
||||
$this->assertFalse(Utils::isPositive(false));
|
||||
$this->assertFalse(Utils::isPositive(0));
|
||||
$this->assertFalse(Utils::isPositive('0'));
|
||||
$this->assertFalse(Utils::isPositive('no'));
|
||||
$this->assertFalse(Utils::isPositive('off'));
|
||||
$this->assertFalse(Utils::isPositive('false'));
|
||||
$this->assertFalse(Utils::isPositive('some'));
|
||||
$this->assertFalse(Utils::isPositive(2));
|
||||
self::assertTrue(Utils::isPositive(true));
|
||||
self::assertTrue(Utils::isPositive(1));
|
||||
self::assertTrue(Utils::isPositive('1'));
|
||||
self::assertTrue(Utils::isPositive('yes'));
|
||||
self::assertTrue(Utils::isPositive('on'));
|
||||
self::assertTrue(Utils::isPositive('true'));
|
||||
self::assertFalse(Utils::isPositive(false));
|
||||
self::assertFalse(Utils::isPositive(0));
|
||||
self::assertFalse(Utils::isPositive('0'));
|
||||
self::assertFalse(Utils::isPositive('no'));
|
||||
self::assertFalse(Utils::isPositive('off'));
|
||||
self::assertFalse(Utils::isPositive('false'));
|
||||
self::assertFalse(Utils::isPositive('some'));
|
||||
self::assertFalse(Utils::isPositive(2));
|
||||
}
|
||||
|
||||
public function testGetNonce()
|
||||
public function testGetNonce(): void
|
||||
{
|
||||
$this->assertIsString(Utils::getNonce('test-action'));
|
||||
$this->assertIsString(Utils::getNonce('test-action', true));
|
||||
$this->assertSame(Utils::getNonce('test-action'), Utils::getNonce('test-action'));
|
||||
$this->assertNotSame(Utils::getNonce('test-action'), Utils::getNonce('test-action2'));
|
||||
self::assertIsString(Utils::getNonce('test-action'));
|
||||
self::assertIsString(Utils::getNonce('test-action', true));
|
||||
self::assertSame(Utils::getNonce('test-action'), Utils::getNonce('test-action'));
|
||||
self::assertNotSame(Utils::getNonce('test-action'), Utils::getNonce('test-action2'));
|
||||
}
|
||||
|
||||
public function testVerifyNonce()
|
||||
public function testVerifyNonce(): void
|
||||
{
|
||||
$this->assertTrue(Utils::verifyNonce(Utils::getNonce('test-action'), 'test-action'));
|
||||
self::assertTrue(Utils::verifyNonce(Utils::getNonce('test-action'), 'test-action'));
|
||||
}
|
||||
|
||||
public function testUrl()
|
||||
public function testUrl(): void
|
||||
{
|
||||
$this->uri->initializeWithUrl('http://testing.dev/path1/path2')->init();
|
||||
|
||||
// Fail hard
|
||||
$this->assertSame(false, Utils::url('', true));
|
||||
$this->assertSame(false, Utils::url(''));
|
||||
$this->assertSame(false, Utils::url(new stdClass()));
|
||||
$this->assertSame(false, Utils::url(['foo','bar','baz']));
|
||||
$this->assertSame(false, Utils::url('user://does/not/exist'));
|
||||
self::assertSame(false, Utils::url('', true));
|
||||
self::assertSame(false, Utils::url(''));
|
||||
self::assertSame(false, Utils::url(new stdClass()));
|
||||
self::assertSame(false, Utils::url(['foo','bar','baz']));
|
||||
self::assertSame(false, Utils::url('user://does/not/exist'));
|
||||
|
||||
// Fail Gracefully
|
||||
$this->assertSame('/', Utils::url('/', false, true));
|
||||
$this->assertSame('/', Utils::url('', false, true));
|
||||
$this->assertSame('/', Utils::url(new stdClass(), false, true));
|
||||
$this->assertSame('/', Utils::url(['foo','bar','baz'], false, true));
|
||||
$this->assertSame('/user/does/not/exist', Utils::url('user://does/not/exist', false, true));
|
||||
self::assertSame('/', Utils::url('/', false, true));
|
||||
self::assertSame('/', Utils::url('', false, true));
|
||||
self::assertSame('/', Utils::url(new stdClass(), false, true));
|
||||
self::assertSame('/', Utils::url(['foo','bar','baz'], false, true));
|
||||
self::assertSame('/user/does/not/exist', Utils::url('user://does/not/exist', false, true));
|
||||
|
||||
// Simple paths
|
||||
$this->assertSame('/', Utils::url('/'));
|
||||
$this->assertSame('/path1', Utils::url('/path1'));
|
||||
$this->assertSame('/path1/path2', Utils::url('/path1/path2'));
|
||||
$this->assertSame('/random/path1/path2', Utils::url('/random/path1/path2'));
|
||||
$this->assertSame('/foobar.jpg', Utils::url('/foobar.jpg'));
|
||||
$this->assertSame('/path1/foobar.jpg', Utils::url('/path1/foobar.jpg'));
|
||||
$this->assertSame('/path1/path2/foobar.jpg', Utils::url('/path1/path2/foobar.jpg'));
|
||||
$this->assertSame('/random/path1/path2/foobar.jpg', Utils::url('/random/path1/path2/foobar.jpg'));
|
||||
self::assertSame('/', Utils::url('/'));
|
||||
self::assertSame('/path1', Utils::url('/path1'));
|
||||
self::assertSame('/path1/path2', Utils::url('/path1/path2'));
|
||||
self::assertSame('/random/path1/path2', Utils::url('/random/path1/path2'));
|
||||
self::assertSame('/foobar.jpg', Utils::url('/foobar.jpg'));
|
||||
self::assertSame('/path1/foobar.jpg', Utils::url('/path1/foobar.jpg'));
|
||||
self::assertSame('/path1/path2/foobar.jpg', Utils::url('/path1/path2/foobar.jpg'));
|
||||
self::assertSame('/random/path1/path2/foobar.jpg', Utils::url('/random/path1/path2/foobar.jpg'));
|
||||
|
||||
// Simple paths with domain
|
||||
$this->assertSame('http://testing.dev/', Utils::url('/', true));
|
||||
$this->assertSame('http://testing.dev/path1', Utils::url('/path1', true));
|
||||
$this->assertSame('http://testing.dev/path1/path2', Utils::url('/path1/path2', true));
|
||||
$this->assertSame('http://testing.dev/random/path1/path2', Utils::url('/random/path1/path2', true));
|
||||
$this->assertSame('http://testing.dev/foobar.jpg', Utils::url('/foobar.jpg', true));
|
||||
$this->assertSame('http://testing.dev/path1/foobar.jpg', Utils::url('/path1/foobar.jpg', true));
|
||||
$this->assertSame('http://testing.dev/path1/path2/foobar.jpg', Utils::url('/path1/path2/foobar.jpg', true));
|
||||
$this->assertSame('http://testing.dev/random/path1/path2/foobar.jpg', Utils::url('/random/path1/path2/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/', Utils::url('/', true));
|
||||
self::assertSame('http://testing.dev/path1', Utils::url('/path1', true));
|
||||
self::assertSame('http://testing.dev/path1/path2', Utils::url('/path1/path2', true));
|
||||
self::assertSame('http://testing.dev/random/path1/path2', Utils::url('/random/path1/path2', true));
|
||||
self::assertSame('http://testing.dev/foobar.jpg', Utils::url('/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/path1/foobar.jpg', Utils::url('/path1/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/path1/path2/foobar.jpg', Utils::url('/path1/path2/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/random/path1/path2/foobar.jpg', Utils::url('/random/path1/path2/foobar.jpg', true));
|
||||
|
||||
// Relative paths from Grav root.
|
||||
$this->assertSame('/subdir', Utils::url('subdir'));
|
||||
$this->assertSame('/subdir/path1', Utils::url('subdir/path1'));
|
||||
$this->assertSame('/subdir/path1/path2', Utils::url('subdir/path1/path2'));
|
||||
$this->assertSame('/path1', Utils::url('path1'));
|
||||
$this->assertSame('/path1/path2', Utils::url('path1/path2'));
|
||||
$this->assertSame('/foobar.jpg', Utils::url('foobar.jpg'));
|
||||
$this->assertSame('http://testing.dev/foobar.jpg', Utils::url('foobar.jpg', true));
|
||||
self::assertSame('/subdir', Utils::url('subdir'));
|
||||
self::assertSame('/subdir/path1', Utils::url('subdir/path1'));
|
||||
self::assertSame('/subdir/path1/path2', Utils::url('subdir/path1/path2'));
|
||||
self::assertSame('/path1', Utils::url('path1'));
|
||||
self::assertSame('/path1/path2', Utils::url('path1/path2'));
|
||||
self::assertSame('/foobar.jpg', Utils::url('foobar.jpg'));
|
||||
self::assertSame('http://testing.dev/foobar.jpg', Utils::url('foobar.jpg', true));
|
||||
|
||||
// Relative paths from Grav root with domain.
|
||||
$this->assertSame('http://testing.dev/foobar.jpg', Utils::url('foobar.jpg', true));
|
||||
$this->assertSame('http://testing.dev/foobar.jpg', Utils::url('/foobar.jpg', true));
|
||||
$this->assertSame('http://testing.dev/path1/foobar.jpg', Utils::url('/path1/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/foobar.jpg', Utils::url('foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/foobar.jpg', Utils::url('/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/path1/foobar.jpg', Utils::url('/path1/foobar.jpg', true));
|
||||
|
||||
// All Non-existing streams should be treated as external URI / protocol.
|
||||
$this->assertSame('http://domain.com/path', Utils::url('http://domain.com/path'));
|
||||
$this->assertSame('ftp://domain.com/path', Utils::url('ftp://domain.com/path'));
|
||||
$this->assertSame('sftp://domain.com/path', Utils::url('sftp://domain.com/path'));
|
||||
$this->assertSame('ssh://domain.com', Utils::url('ssh://domain.com'));
|
||||
$this->assertSame('pop://domain.com', Utils::url('pop://domain.com'));
|
||||
$this->assertSame('foo://bar/baz', Utils::url('foo://bar/baz'));
|
||||
$this->assertSame('foo://bar/baz', Utils::url('foo://bar/baz', true));
|
||||
// $this->assertSame('mailto:joe@domain.com', Utils::url('mailto:joe@domain.com', true)); // FIXME <-
|
||||
self::assertSame('http://domain.com/path', Utils::url('http://domain.com/path'));
|
||||
self::assertSame('ftp://domain.com/path', Utils::url('ftp://domain.com/path'));
|
||||
self::assertSame('sftp://domain.com/path', Utils::url('sftp://domain.com/path'));
|
||||
self::assertSame('ssh://domain.com', Utils::url('ssh://domain.com'));
|
||||
self::assertSame('pop://domain.com', Utils::url('pop://domain.com'));
|
||||
self::assertSame('foo://bar/baz', Utils::url('foo://bar/baz'));
|
||||
self::assertSame('foo://bar/baz', Utils::url('foo://bar/baz', true));
|
||||
// self::assertSame('mailto:joe@domain.com', Utils::url('mailto:joe@domain.com', true)); // FIXME <-
|
||||
}
|
||||
|
||||
public function testUrlWithRoot()
|
||||
public function testUrlWithRoot(): void
|
||||
{
|
||||
$this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/path1/path2', '/subdir')->init();
|
||||
|
||||
// Fail hard
|
||||
$this->assertSame(false, Utils::url('', true));
|
||||
$this->assertSame(false, Utils::url(''));
|
||||
$this->assertSame(false, Utils::url(new stdClass()));
|
||||
$this->assertSame(false, Utils::url(['foo','bar','baz']));
|
||||
$this->assertSame(false, Utils::url('user://does/not/exist'));
|
||||
self::assertSame(false, Utils::url('', true));
|
||||
self::assertSame(false, Utils::url(''));
|
||||
self::assertSame(false, Utils::url(new stdClass()));
|
||||
self::assertSame(false, Utils::url(['foo','bar','baz']));
|
||||
self::assertSame(false, Utils::url('user://does/not/exist'));
|
||||
|
||||
// Fail Gracefully
|
||||
$this->assertSame('/subdir/', Utils::url('/', false, true));
|
||||
$this->assertSame('/subdir/', Utils::url('', false, true));
|
||||
$this->assertSame('/subdir/', Utils::url(new stdClass(), false, true));
|
||||
$this->assertSame('/subdir/', Utils::url(['foo','bar','baz'], false, true));
|
||||
$this->assertSame('/subdir/user/does/not/exist', Utils::url('user://does/not/exist', false, true));
|
||||
self::assertSame('/subdir/', Utils::url('/', false, true));
|
||||
self::assertSame('/subdir/', Utils::url('', false, true));
|
||||
self::assertSame('/subdir/', Utils::url(new stdClass(), false, true));
|
||||
self::assertSame('/subdir/', Utils::url(['foo','bar','baz'], false, true));
|
||||
self::assertSame('/subdir/user/does/not/exist', Utils::url('user://does/not/exist', false, true));
|
||||
|
||||
// Simple paths
|
||||
$this->assertSame('/subdir/', Utils::url('/'));
|
||||
$this->assertSame('/subdir/path1', Utils::url('/path1'));
|
||||
$this->assertSame('/subdir/path1/path2', Utils::url('/path1/path2'));
|
||||
$this->assertSame('/subdir/random/path1/path2', Utils::url('/random/path1/path2'));
|
||||
$this->assertSame('/subdir/foobar.jpg', Utils::url('/foobar.jpg'));
|
||||
$this->assertSame('/subdir/path1/foobar.jpg', Utils::url('/path1/foobar.jpg'));
|
||||
$this->assertSame('/subdir/path1/path2/foobar.jpg', Utils::url('/path1/path2/foobar.jpg'));
|
||||
$this->assertSame('/subdir/random/path1/path2/foobar.jpg', Utils::url('/random/path1/path2/foobar.jpg'));
|
||||
self::assertSame('/subdir/', Utils::url('/'));
|
||||
self::assertSame('/subdir/path1', Utils::url('/path1'));
|
||||
self::assertSame('/subdir/path1/path2', Utils::url('/path1/path2'));
|
||||
self::assertSame('/subdir/random/path1/path2', Utils::url('/random/path1/path2'));
|
||||
self::assertSame('/subdir/foobar.jpg', Utils::url('/foobar.jpg'));
|
||||
self::assertSame('/subdir/path1/foobar.jpg', Utils::url('/path1/foobar.jpg'));
|
||||
self::assertSame('/subdir/path1/path2/foobar.jpg', Utils::url('/path1/path2/foobar.jpg'));
|
||||
self::assertSame('/subdir/random/path1/path2/foobar.jpg', Utils::url('/random/path1/path2/foobar.jpg'));
|
||||
|
||||
// Simple paths with domain
|
||||
$this->assertSame('http://testing.dev/subdir/', Utils::url('/', true));
|
||||
$this->assertSame('http://testing.dev/subdir/path1', Utils::url('/path1', true));
|
||||
$this->assertSame('http://testing.dev/subdir/path1/path2', Utils::url('/path1/path2', true));
|
||||
$this->assertSame('http://testing.dev/subdir/random/path1/path2', Utils::url('/random/path1/path2', true));
|
||||
$this->assertSame('http://testing.dev/subdir/foobar.jpg', Utils::url('/foobar.jpg', true));
|
||||
$this->assertSame('http://testing.dev/subdir/path1/foobar.jpg', Utils::url('/path1/foobar.jpg', true));
|
||||
$this->assertSame('http://testing.dev/subdir/path1/path2/foobar.jpg', Utils::url('/path1/path2/foobar.jpg', true));
|
||||
$this->assertSame('http://testing.dev/subdir/random/path1/path2/foobar.jpg', Utils::url('/random/path1/path2/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/subdir/', Utils::url('/', true));
|
||||
self::assertSame('http://testing.dev/subdir/path1', Utils::url('/path1', true));
|
||||
self::assertSame('http://testing.dev/subdir/path1/path2', Utils::url('/path1/path2', true));
|
||||
self::assertSame('http://testing.dev/subdir/random/path1/path2', Utils::url('/random/path1/path2', true));
|
||||
self::assertSame('http://testing.dev/subdir/foobar.jpg', Utils::url('/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/subdir/path1/foobar.jpg', Utils::url('/path1/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/subdir/path1/path2/foobar.jpg', Utils::url('/path1/path2/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/subdir/random/path1/path2/foobar.jpg', Utils::url('/random/path1/path2/foobar.jpg', true));
|
||||
|
||||
// Paths including the grav base.
|
||||
$this->assertSame('/subdir/', Utils::url('/subdir'));
|
||||
$this->assertSame('/subdir/path1', Utils::url('/subdir/path1'));
|
||||
$this->assertSame('/subdir/path1/path2', Utils::url('/subdir/path1/path2'));
|
||||
$this->assertSame('/subdir/foobar.jpg', Utils::url('/subdir/foobar.jpg'));
|
||||
$this->assertSame('/subdir/path1/foobar.jpg', Utils::url('/subdir/path1/foobar.jpg'));
|
||||
self::assertSame('/subdir/', Utils::url('/subdir'));
|
||||
self::assertSame('/subdir/path1', Utils::url('/subdir/path1'));
|
||||
self::assertSame('/subdir/path1/path2', Utils::url('/subdir/path1/path2'));
|
||||
self::assertSame('/subdir/foobar.jpg', Utils::url('/subdir/foobar.jpg'));
|
||||
self::assertSame('/subdir/path1/foobar.jpg', Utils::url('/subdir/path1/foobar.jpg'));
|
||||
|
||||
// Relative paths from Grav root with domain.
|
||||
$this->assertSame('http://testing.dev/subdir/', Utils::url('/subdir', true));
|
||||
$this->assertSame('http://testing.dev/subdir/path1', Utils::url('/subdir/path1', true));
|
||||
$this->assertSame('http://testing.dev/subdir/path1/path2', Utils::url('/subdir/path1/path2', true));
|
||||
$this->assertSame('http://testing.dev/subdir/foobar.jpg', Utils::url('/subdir/foobar.jpg', true));
|
||||
$this->assertSame('http://testing.dev/subdir/path1/foobar.jpg', Utils::url('/subdir/path1/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/subdir/', Utils::url('/subdir', true));
|
||||
self::assertSame('http://testing.dev/subdir/path1', Utils::url('/subdir/path1', true));
|
||||
self::assertSame('http://testing.dev/subdir/path1/path2', Utils::url('/subdir/path1/path2', true));
|
||||
self::assertSame('http://testing.dev/subdir/foobar.jpg', Utils::url('/subdir/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/subdir/path1/foobar.jpg', Utils::url('/subdir/path1/foobar.jpg', true));
|
||||
|
||||
// Relative paths from Grav root.
|
||||
$this->assertSame('/subdir/subdir', Utils::url('subdir'));
|
||||
$this->assertSame('/subdir/subdir/path1', Utils::url('subdir/path1'));
|
||||
$this->assertSame('/subdir/subdir/path1/path2', Utils::url('subdir/path1/path2'));
|
||||
$this->assertSame('/subdir/path1', Utils::url('path1'));
|
||||
$this->assertSame('/subdir/path1/path2', Utils::url('path1/path2'));
|
||||
$this->assertSame('/subdir/foobar.jpg', Utils::url('foobar.jpg'));
|
||||
$this->assertSame('http://testing.dev/subdir/foobar.jpg', Utils::url('foobar.jpg', true));
|
||||
self::assertSame('/subdir/subdir', Utils::url('subdir'));
|
||||
self::assertSame('/subdir/subdir/path1', Utils::url('subdir/path1'));
|
||||
self::assertSame('/subdir/subdir/path1/path2', Utils::url('subdir/path1/path2'));
|
||||
self::assertSame('/subdir/path1', Utils::url('path1'));
|
||||
self::assertSame('/subdir/path1/path2', Utils::url('path1/path2'));
|
||||
self::assertSame('/subdir/foobar.jpg', Utils::url('foobar.jpg'));
|
||||
self::assertSame('http://testing.dev/subdir/foobar.jpg', Utils::url('foobar.jpg', true));
|
||||
|
||||
// All Non-existing streams should be treated as external URI / protocol.
|
||||
$this->assertSame('http://domain.com/path', Utils::url('http://domain.com/path'));
|
||||
$this->assertSame('ftp://domain.com/path', Utils::url('ftp://domain.com/path'));
|
||||
$this->assertSame('sftp://domain.com/path', Utils::url('sftp://domain.com/path'));
|
||||
$this->assertSame('ssh://domain.com', Utils::url('ssh://domain.com'));
|
||||
$this->assertSame('pop://domain.com', Utils::url('pop://domain.com'));
|
||||
$this->assertSame('foo://bar/baz', Utils::url('foo://bar/baz'));
|
||||
$this->assertSame('foo://bar/baz', Utils::url('foo://bar/baz', true));
|
||||
// $this->assertSame('mailto:joe@domain.com', Utils::url('mailto:joe@domain.com', true)); // FIXME <-
|
||||
self::assertSame('http://domain.com/path', Utils::url('http://domain.com/path'));
|
||||
self::assertSame('ftp://domain.com/path', Utils::url('ftp://domain.com/path'));
|
||||
self::assertSame('sftp://domain.com/path', Utils::url('sftp://domain.com/path'));
|
||||
self::assertSame('ssh://domain.com', Utils::url('ssh://domain.com'));
|
||||
self::assertSame('pop://domain.com', Utils::url('pop://domain.com'));
|
||||
self::assertSame('foo://bar/baz', Utils::url('foo://bar/baz'));
|
||||
self::assertSame('foo://bar/baz', Utils::url('foo://bar/baz', true));
|
||||
// self::assertSame('mailto:joe@domain.com', Utils::url('mailto:joe@domain.com', true)); // FIXME <-
|
||||
}
|
||||
|
||||
public function testUrlWithStreams()
|
||||
public function testUrlWithStreams(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testUrlwithExternals()
|
||||
public function testUrlwithExternals(): void
|
||||
{
|
||||
$this->uri->initializeWithUrl('http://testing.dev/path1/path2')->init();
|
||||
$this->assertSame('http://foo.com', Utils::url('http://foo.com'));
|
||||
$this->assertSame('https://foo.com', Utils::url('https://foo.com'));
|
||||
$this->assertSame('//foo.com', Utils::url('//foo.com'));
|
||||
$this->assertSame('//foo.com?param=x', Utils::url('//foo.com?param=x'));
|
||||
self::assertSame('http://foo.com', Utils::url('http://foo.com'));
|
||||
self::assertSame('https://foo.com', Utils::url('https://foo.com'));
|
||||
self::assertSame('//foo.com', Utils::url('//foo.com'));
|
||||
self::assertSame('//foo.com?param=x', Utils::url('//foo.com?param=x'));
|
||||
}
|
||||
|
||||
public function testCheckFilename()
|
||||
public function testCheckFilename(): void
|
||||
{
|
||||
// configure extension for consistent results
|
||||
/** @var \Grav\Common\Config\Config $config */
|
||||
$config = $this->grav['config'];
|
||||
$config->set('security.uploads_dangerous_extensions', ['php', 'html', 'htm', 'exe', 'js']);
|
||||
|
||||
$this->assertFalse(Utils::checkFilename('foo.php'));
|
||||
$this->assertFalse(Utils::checkFilename('bar.js'));
|
||||
self::assertFalse(Utils::checkFilename('foo.php'));
|
||||
self::assertFalse(Utils::checkFilename('bar.js'));
|
||||
|
||||
$this->assertTrue(Utils::checkFilename('foo.json'));
|
||||
$this->assertTrue(Utils::checkFilename('foo.xml'));
|
||||
$this->assertTrue(Utils::checkFilename('foo.yaml'));
|
||||
$this->assertTrue(Utils::checkFilename('foo.yml'));
|
||||
self::assertTrue(Utils::checkFilename('foo.json'));
|
||||
self::assertTrue(Utils::checkFilename('foo.xml'));
|
||||
self::assertTrue(Utils::checkFilename('foo.yaml'));
|
||||
self::assertTrue(Utils::checkFilename('foo.yml'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use Codeception\Util\Fixtures;
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Console\Gpm\InstallCommand;
|
||||
|
||||
/**
|
||||
* Class InstallCommandTest
|
||||
|
|
@ -15,13 +16,13 @@ class InstallCommandTest extends \Codeception\TestCase\Test
|
|||
protected $installCommand;
|
||||
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$this->grav = Fixtures::get('grav');
|
||||
$this->installCommand = new InstallCommand();
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,12 @@
|
|||
|
||||
use Grav\Framework\File\Formatter\CsvFormatter;
|
||||
|
||||
/**
|
||||
* Class CsvFormatterTest
|
||||
*/
|
||||
class CsvFormatterTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
public function testEncodeWithAssocColumns()
|
||||
public function testEncodeWithAssocColumns(): void
|
||||
{
|
||||
$data = [
|
||||
['col1' => 1, 'col2' => 2, 'col3' => 3],
|
||||
|
|
@ -23,7 +26,7 @@ class CsvFormatterTest extends \Codeception\TestCase\Test
|
|||
* TBD - If indexes are all numeric, what's the purpose
|
||||
* of displaying header
|
||||
*/
|
||||
public function testEncodeWithIndexColumns()
|
||||
public function testEncodeWithIndexColumns(): void
|
||||
{
|
||||
$data = [
|
||||
[0 => 1, 1 => 2, 2 => 3],
|
||||
|
|
@ -37,7 +40,7 @@ class CsvFormatterTest extends \Codeception\TestCase\Test
|
|||
self::assertEquals('0,1,2', $lines[0]);
|
||||
}
|
||||
|
||||
public function testEncodeEmptyData()
|
||||
public function testEncodeEmptyData(): void
|
||||
{
|
||||
$encoded = (new CsvFormatter())->encode([]);
|
||||
self::assertEquals('', $encoded);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
use Grav\Framework\Filesystem\Filesystem;
|
||||
|
||||
/**
|
||||
* Class FilesystemTest
|
||||
*/
|
||||
class FilesystemTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
protected $class;
|
||||
|
|
@ -277,17 +280,21 @@ class FilesystemTest extends \Codeception\TestCase\Test
|
|||
],
|
||||
];
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$this->class = Filesystem::getInstance();
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
unset($this->class);
|
||||
}
|
||||
|
||||
protected function runTestSet(array $tests, $method)
|
||||
/**
|
||||
* @param array $tests
|
||||
* @param string $method
|
||||
*/
|
||||
protected function runTestSet(array $tests, $method): void
|
||||
{
|
||||
$class = $this->class;
|
||||
foreach ($tests as $path => $candidates) {
|
||||
|
|
@ -299,32 +306,32 @@ class FilesystemTest extends \Codeception\TestCase\Test
|
|||
|
||||
$result = $class->{$method}($path);
|
||||
|
||||
$this->assertSame($expected, $result, "Test {$method}('{$path}')");
|
||||
self::assertSame($expected, $result, "Test {$method}('{$path}')");
|
||||
|
||||
if (function_exists($method) && !strpos($path, '://')) {
|
||||
$cmp_result = $method($path);
|
||||
|
||||
$this->assertSame($cmp_result, $result, "Compare to original {$method}('{$path}')");
|
||||
self::assertSame($cmp_result, $result, "Compare to original {$method}('{$path}')");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testParent()
|
||||
public function testParent(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'parent');
|
||||
}
|
||||
|
||||
public function testNormalize()
|
||||
public function testNormalize(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'normalize');
|
||||
}
|
||||
|
||||
public function testDirname()
|
||||
public function testDirname(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'dirname');
|
||||
}
|
||||
|
||||
public function testPathinfo()
|
||||
public function testPathinfo(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'pathinfo');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user