Misc minor code quality fixes

This commit is contained in:
Matias Griese
2019-10-24 11:26:04 +03:00
parent 0f66032c9b
commit c4ce2d1648
5 changed files with 19 additions and 13 deletions

View File

@@ -230,7 +230,7 @@ trait TestingAssetsTrait
* Get the timestamp for assets
*
* @param bool $include_join
* @return string
* @return string|null
*/
public function getTimestamp($include_join = true)
{

View File

@@ -210,6 +210,7 @@ class PageObject extends FlexPageObject
// Make sure that pages has been initialized.
Pages::getTypes();
// TODO: We need to move raw blueprint logic to Grav itself to remove admin dependency here.
if ($name === 'raw') {
// Admin RAW mode.
/** @var Admin $admin */

View File

@@ -25,6 +25,7 @@ use Grav\Common\Utils;
use Grav\Framework\Flex\Flex;
use Grav\Framework\Flex\FlexDirectory;
use Grav\Framework\Flex\Interfaces\FlexTranslateInterface;
use Grav\Framework\Flex\Pages\FlexPageObject;
use Grav\Plugin\Admin;
use RocketTheme\Toolbox\Event\Event;
use RocketTheme\Toolbox\Event\EventDispatcher;
@@ -1402,7 +1403,7 @@ class Pages
$page = $page && $page->hasTranslation() ? $page->getTranslation() : null;
}
if (!$page || $path === $root_path) {
if (!$page instanceof FlexPageObject || $path === $root_path) {
continue;
}

View File

@@ -69,9 +69,15 @@ parameters:
-
message: '#Call to static method sendEmail\(\) on an unknown class Grav\\Plugin\\Email\\Utils#'
path: 'system/src/Grav/Common/Scheduler/Job.php'
-
message: '#unknown class RedisException#'
path: 'system/src/Grav/Common/Cache.php'
-
message: '#on an unknown class Grav\\Plugin\\Admin#'
path: 'system/src/Grav/Common/Page/Pages.php'
-
message: '#on an unknown class Grav\\Plugin\\Admin#'
path: 'system/src/Grav/Common/Page/Flex/PageObject.php'
-
message: '#Call to method getFlash\(\) on an unknown class Grav\\Common\\Grav\\Plugin\\Form\\Forms#'
path: 'system/src/Grav/Common/Session.php'

View File

@@ -53,7 +53,7 @@ class PagesTest extends \Codeception\TestCase\Test
public function testInstances()
{
$this->assertInternalType('array', $this->pages->instances());
$this->assertIsArray($this->pages->instances());
foreach ($this->pages->instances() as $instance) {
$this->assertInstanceOf(PageInterface::class, $instance);
}
@@ -65,7 +65,7 @@ class PagesTest extends \Codeception\TestCase\Test
$locator = $this->grav['locator'];
$folder = $locator->findResource('tests://');
$this->assertInternalType('array', $this->pages->routes());
$this->assertIsArray($this->pages->routes());
$this->assertSame($folder . '/fake/simple-site/user/pages/01.home', $this->pages->routes()['/']);
$this->assertSame($folder . '/fake/simple-site/user/pages/01.home', $this->pages->routes()['/home']);
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog', $this->pages->routes()['/blog']);
@@ -99,7 +99,7 @@ class PagesTest extends \Codeception\TestCase\Test
$aPage = $this->pages->find('/blog');
$subPagesSorted = $this->pages->sort($aPage);
$this->assertInternalType('array', $subPagesSorted);
$this->assertIsArray($subPagesSorted);
$this->assertCount(2, $subPagesSorted);
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted)[0]);
@@ -113,7 +113,7 @@ class PagesTest extends \Codeception\TestCase\Test
$subPagesSorted = $this->pages->sort($aPage, null, 'desc');
$this->assertInternalType('array', $subPagesSorted);
$this->assertIsArray($subPagesSorted);
$this->assertCount(2, $subPagesSorted);
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted)[0]);
@@ -135,7 +135,7 @@ class PagesTest extends \Codeception\TestCase\Test
$aPage = $this->pages->find('/blog');
$subPagesSorted = $this->pages->sortCollection($aPage->children(), $aPage->orderBy());
$this->assertInternalType('array', $subPagesSorted);
$this->assertIsArray($subPagesSorted);
$this->assertCount(2, $subPagesSorted);
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted)[0]);
@@ -149,7 +149,7 @@ class PagesTest extends \Codeception\TestCase\Test
$subPagesSorted = $this->pages->sortCollection($aPage->children(), $aPage->orderBy(), 'desc');
$this->assertInternalType('array', $subPagesSorted);
$this->assertIsArray($subPagesSorted);
$this->assertCount(2, $subPagesSorted);
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted)[0]);
@@ -170,12 +170,10 @@ class PagesTest extends \Codeception\TestCase\Test
//Page existing
$aPage = $this->pages->get($folder . '/fake/simple-site/user/pages/03.about');
$this->assertInternalType('object', $aPage);
$this->assertInstanceOf(PageInterface::class, $aPage);
//Page not existing
$anotherPage = $this->pages->get($folder . '/fake/simple-site/user/pages/03.non-existing');
$this->assertNotInternalType('object', $anotherPage);
$this->assertNull($anotherPage);
}
@@ -223,8 +221,8 @@ class PagesTest extends \Codeception\TestCase\Test
public function testAll()
{
$this->assertInternalType('object', $this->pages->all());
$this->assertInternalType('array', $this->pages->all()->toArray());
$this->assertIsObject($this->pages->all());
$this->assertIsArray($this->pages->all()->toArray());
foreach ($this->pages->all() as $page) {
$this->assertInstanceOf(PageInterface::class, $page);
}
@@ -233,7 +231,7 @@ class PagesTest extends \Codeception\TestCase\Test
public function testGetList()
{
$list = $this->pages->getList();
$this->assertInternalType('array', $list);
$this->assertIsArray($list);
$this->assertSame('—-▸ Home', $list['/']);
$this->assertSame('—-▸ Blog', $list['/blog']);
}