diff --git a/tests/unit/Grav/Common/AssetsTest.php b/tests/unit/Grav/Common/AssetsTest.php
index 82d26cd4b..747c8ed51 100644
--- a/tests/unit/Grav/Common/AssetsTest.php
+++ b/tests/unit/Grav/Common/AssetsTest.php
@@ -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('' . PHP_EOL, $css);
+ self::assertSame('' . 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('' . PHP_EOL, $js);
+ self::assertSame('' . 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('' . PHP_EOL, $css);
+ self::assertSame('' . 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('' . PHP_EOL, $css);
+ self::assertSame('' . 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('' . PHP_EOL, $css);
+ self::assertSame('' . PHP_EOL, $css);
//test addJs()
$this->assets->reset();
$this->assets->addJs('test.js');
$js = $this->assets->js();
- $this->assertSame('' . PHP_EOL, $js);
+ self::assertSame('' . 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('' . PHP_EOL, $css);
+ self::assertSame('' . 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('' . PHP_EOL, $js);
+ self::assertSame('' . 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('' . PHP_EOL, $js);
+ self::assertSame('' . 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('' . PHP_EOL, $js);
+ self::assertSame('' . 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('' . PHP_EOL, $css);
+ self::assertSame('' . 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('' . PHP_EOL, $js);
+ self::assertSame('' . 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('' . PHP_EOL, $js);
+ self::assertSame('' . 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('' . PHP_EOL .
+ self::assertSame('' . PHP_EOL .
'' . 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('' . PHP_EOL, $js);
+ self::assertSame('' . PHP_EOL, $js);
$js = $this->assets->js('footer');
- $this->assertSame('' . PHP_EOL, $js);
+ self::assertSame('' . 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('' . PHP_EOL .
+ self::assertSame('' . PHP_EOL .
'' . 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('' . PHP_EOL, $css);
+ self::assertSame('' . 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('' . PHP_EOL, $js);
+ self::assertSame('' . 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('' . PHP_EOL, $css);
+ self::assertSame('' . PHP_EOL, $css);
$this->assets->reset();
$this->assets->addInlineJs('alert("test")', 15, 'bottom', ['id' => 'foo']);
$js = $this->assets->js('bottom');
- $this->assertSame('' . PHP_EOL, $js);
+ self::assertSame('' . 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('' . PHP_EOL .
+ self::assertSame('' . PHP_EOL .
'' . 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('' . PHP_EOL, $css);
+ self::assertSame('' . PHP_EOL, $css);
$css = $this->assets->css('footer');
- $this->assertSame('' . PHP_EOL, $css);
+ self::assertSame('' . 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('' . PHP_EOL .
+ self::assertSame('' . PHP_EOL .
'' . 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('' . PHP_EOL .
+ self::assertSame('' . PHP_EOL .
'' . 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('' . PHP_EOL .
+ self::assertSame('' . PHP_EOL .
'' . 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('' . PHP_EOL .
+ self::assertSame('' . PHP_EOL .
'' . PHP_EOL .
'' . 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('##', $css);
+ self::assertRegExp('##', $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('##', $css);
+ self::assertRegExp('##', $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('##', $css);
+ self::assertRegExp('##', $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("\n", $css);
+ self::assertSame("\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("\n", $css);
+ self::assertSame("\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('' . PHP_EOL, $js);
+ self::assertSame('' . PHP_EOL, $js);
}
- public function testAddDeferJs()
+ public function testAddDeferJs(): void
{
$this->assets->reset();
$this->assets->addDeferJs('jquery');
$js = $this->assets->js();
- $this->assertSame('' . PHP_EOL, $js);
+ self::assertSame('' . 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('' . PHP_EOL, $css);
+ self::assertSame('' . 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('' . PHP_EOL, $css);
+ self::assertSame('' . 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('' . PHP_EOL, $css);
+ self::assertSame('' . 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('' . PHP_EOL, $css);
+ self::assertSame('' . 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('' . PHP_EOL, $css);
+ self::assertSame('' . 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('' . PHP_EOL, $css);
+ self::assertSame('' . 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('' . PHP_EOL, $css);
+ self::assertSame('' . 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('' . PHP_EOL, $css);
+ self::assertSame('' . 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('' . PHP_EOL, $css);
+ self::assertSame('' . PHP_EOL, $css);
}
- public function testAddInlineJs()
+ public function testAddInlineJs(): void
{
$this->assets->reset();
$this->assets->addInlineJs('alert("test")');
$js = $this->assets->js();
- $this->assertSame('' . PHP_EOL, $js);
+ self::assertSame('' . 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());
}
}
diff --git a/tests/unit/Grav/Common/BrowserTest.php b/tests/unit/Grav/Common/BrowserTest.php
index a4df12003..a1033d8c9 100644
--- a/tests/unit/Grav/Common/BrowserTest.php
+++ b/tests/unit/Grav/Common/BrowserTest.php
@@ -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());
}
}
diff --git a/tests/unit/Grav/Common/ComposerTest.php b/tests/unit/Grav/Common/ComposerTest.php
index 67a15f47d..8c73a1fc3 100644
--- a/tests/unit/Grav/Common/ComposerTest.php
+++ b/tests/unit/Grav/Common/ComposerTest.php
@@ -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'));
}
}
diff --git a/tests/unit/Grav/Common/Data/BlueprintTest.php b/tests/unit/Grav/Common/Data/BlueprintTest.php
index 7ffa58366..ff6ccf56e 100644
--- a/tests/unit/Grav/Common/Data/BlueprintTest.php
+++ b/tests/unit/Grav/Common/Data/BlueprintTest.php
@@ -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');
diff --git a/tests/unit/Grav/Common/GPM/GPMTest.php b/tests/unit/Grav/Common/GPM/GPMTest.php
index 1fe79555e..684ed3dd1 100644
--- a/tests/unit/Grav/Common/GPM/GPMTest.php
+++ b/tests/unit/Grav/Common/GPM/GPMTest.php
@@ -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'));
}
}
diff --git a/tests/unit/Grav/Common/Helpers/ExcerptsTest.php b/tests/unit/Grav/Common/Helpers/ExcerptsTest.php
index 1d95f3c96..8cb473c31 100644
--- a/tests/unit/Grav/Common/Helpers/ExcerptsTest.php
+++ b/tests/unit/Grav/Common/Helpers/ExcerptsTest.php
@@ -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(
'|
|',
Excerpts::processImageHtml('
', $this->page)
);
- $this->assertRegexp(
+ self::assertRegexp(
'|
|',
Excerpts::processImageHtml('
', $this->page)
);
}
- public function testNoProcess()
+ public function testNoProcess(): void
{
- $this->assertStringStartsWith(
+ self::assertStringStartsWith(
'regular process')
);
- $this->assertStringStartsWith(
+ self::assertStringStartsWith(
'noprocess')
);
- $this->assertStringStartsWith(
+ self::assertStringStartsWith(
'noprocess=id')
);
}
- public function testTarget()
+ public function testTarget(): void
{
- $this->assertStringStartsWith(
+ self::assertStringStartsWith(
'only target')
);
- $this->assertStringStartsWith(
+ self::assertStringStartsWith(
'target and rel')
);
diff --git a/tests/unit/Grav/Common/InflectorTest.php b/tests/unit/Grav/Common/InflectorTest.php
index b0b1d4ad9..1db51a2aa 100644
--- a/tests/unit/Grav/Common/InflectorTest.php
+++ b/tests/unit/Grav/Common/InflectorTest.php
@@ -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));
}
}
diff --git a/tests/unit/Grav/Common/Language/LanguageCodesTest.php b/tests/unit/Grav/Common/Language/LanguageCodesTest.php
index 3fbc69eb0..3450c88ea 100644
--- a/tests/unit/Grav/Common/Language/LanguageCodesTest.php
+++ b/tests/unit/Grav/Common/Language/LanguageCodesTest.php
@@ -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'));
}
}
diff --git a/tests/unit/Grav/Common/Markdown/ParsedownTest.php b/tests/unit/Grav/Common/Markdown/ParsedownTest.php
index 451190965..2547a0eae 100644
--- a/tests/unit/Grav/Common/Markdown/ParsedownTest.php
+++ b/tests/unit/Grav/Common/Markdown/ParsedownTest.php
@@ -35,7 +35,7 @@ class ParsedownTest extends \Codeception\TestCase\Test
protected $old_home;
- protected function _before()
+ protected function _before(): void
{
$grav = Fixtures::get('grav');
$this->grav = $grav();
@@ -72,176 +72,176 @@ class ParsedownTest extends \Codeception\TestCase\Test
$this->parsedown = new Parsedown($excerpts);
}
- protected function _after()
+ protected function _after(): void
{
$this->config->set('system.home.alias', $this->old_home);
}
- public function testImages()
+ public function testImages(): void
{
$this->config->set('system.languages.supported', ['fr','en']);
unset($this->grav['language']);
$this->grav['language'] = new Language($this->grav);
$this->uri->initializeWithURL('http://testing.dev/fr/item2/item2-2')->init();
- $this->assertSame(
+ self::assertSame(
'

<\/p>|',
$this->parsedown->text('')
);
$this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
- $this->assertSame(
+ self::assertSame(
'

<\/p>|',
$this->parsedown->text('')
);
- $this->assertRegexp(
+ self::assertRegexp(
'|
<\/p>|',
$this->parsedown->text('')
);
- $this->assertSame(
+ self::assertSame(
'



<\/p>|',
$this->parsedown->text('')
);
- $this->assertSame(
+ self::assertSame(
'

<\/p>|',
$this->parsedown->text('')
);
- $this->assertSame(
+ self::assertSame(
'



<\/p>|',
$this->parsedown->text('')
);
- $this->assertRegexp(
+ self::assertRegexp(
'|
<\/p>|',
$this->parsedown->text('')
);
- $this->assertSame(
+ self::assertSame(
'



<\/p>|',
$this->parsedown->text('')
);
- $this->assertRegexp(
+ self::assertRegexp(
'|
<\/p>|',
$this->parsedown->text('')
);
- $this->assertSame(
+ self::assertSame(
'










<\/p>|',
$this->parsedown->text('')
);
- $this->assertRegexp(
+ self::assertRegexp(
'|
<\/p>|',
$this->parsedown->text('')
);
- $this->assertSame(
+ self::assertSame(
'



<\/p>|',
$this->parsedown->text('')
);
- $this->assertRegexp(
+ self::assertRegexp(
'|
<\/p>|',
$this->parsedown->text('')
);
- $this->assertSame(
+ self::assertSame(
'


this is my text
', '(<\/?p>)', '') ); - $this->assertSame( + self::assertSame( 'this is my text', $this->twig_ext->regexReplace('this is my text
', ['()','(<\/p>)'], ['','']) ); } - 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)); } } diff --git a/tests/unit/Grav/Common/UriTest.php b/tests/unit/Grav/Common/UriTest.php index cec8eb62c..8f1601a6f 100644 --- a/tests/unit/Grav/Common/UriTest.php +++ b/tests/unit/Grav/Common/UriTest.php @@ -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'); } diff --git a/tests/unit/Grav/Common/UtilsTest.php b/tests/unit/Grav/Common/UtilsTest.php index adce03edd..d396a2c3b 100644 --- a/tests/unit/Grav/Common/UtilsTest.php +++ b/tests/unit/Grav/Common/UtilsTest.php @@ -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('', 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('', 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('
T...
', Utils::truncateHtml('This is a string to truncate
', 1)); - $this->assertEquals('This...
', Utils::truncateHtml('This is a string to truncate
', 4)); - $this->assertEquals('This is a...
', Utils::truncateHtml('This is a string to truncate
', 10)); - $this->assertEquals('This is a string to truncate
', Utils::truncateHtml('This is a string to truncate
', 100)); - $this->assertEquals('', Utils::truncateHtml('', 6)); - $this->assertEquals('This is a string.
\nIt splits two lines.
", Utils::truncateHtml("This is a string.
\nIt splits two lines.
", 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('T...
', Utils::truncateHtml('This is a string to truncate
', 1)); + self::assertEquals('This...
', Utils::truncateHtml('This is a string to truncate
', 4)); + self::assertEquals('This is a...
', Utils::truncateHtml('This is a string to truncate
', 10)); + self::assertEquals('This is a string to truncate
', Utils::truncateHtml('This is a string to truncate
', 100)); + self::assertEquals('', Utils::truncateHtml('', 6)); + self::assertEquals('This is a string.
\nIt splits two lines.
", Utils::truncateHtml("This is a string.
\nIt splits two lines.
", 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('This...
', Utils::safeTruncateHtml('This is a string to truncate
', 1)); - $this->assertEquals('This is...
', Utils::safeTruncateHtml('This is a string to truncate
', 2)); - $this->assertEquals('This is a string to...
', Utils::safeTruncateHtml('This is a string to truncate
', 5)); - $this->assertEquals('This is a string to truncate
', Utils::safeTruncateHtml('This is a string to truncate
', 20)); - $this->assertEquals('', Utils::safeTruncateHtml('', 6)); - $this->assertEquals('This...
', Utils::safeTruncateHtml('This is a string to truncate
', 1)); + self::assertEquals('This is...
', Utils::safeTruncateHtml('This is a string to truncate
', 2)); + self::assertEquals('This is a string to...
', Utils::safeTruncateHtml('This is a string to truncate
', 5)); + self::assertEquals('This is a string to truncate
', Utils::safeTruncateHtml('This is a string to truncate
', 20)); + self::assertEquals('', Utils::safeTruncateHtml('', 6)); + self::assertEquals('