mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
✅ First Pages testing in place with first simple site stub structure provided under tests/fake
This commit is contained in:
parent
3fb684d608
commit
4108c7710b
1
tests/fake/simple-site/user/pages/01.home/default.md
Normal file
1
tests/fake/simple-site/user/pages/01.home/default.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
Test
|
||||
|
|
@ -0,0 +1 @@
|
|||
Test
|
||||
|
|
@ -0,0 +1 @@
|
|||
Test
|
||||
5
tests/fake/simple-site/user/pages/03.about/default.md
Normal file
5
tests/fake/simple-site/user/pages/03.about/default.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: test
|
||||
---
|
||||
|
||||
# Test
|
||||
49
tests/unit/Grav/Common/Page/PagesTest.php
Normal file
49
tests/unit/Grav/Common/Page/PagesTest.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
use Codeception\Util\Fixtures;
|
||||
use Codeception\Util\Stub;
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\Page\Pages;
|
||||
use Grav\Common\Page\Page;
|
||||
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
|
||||
|
||||
/**
|
||||
* Class PagesTest
|
||||
*/
|
||||
class PagesTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
/** @var Grav $grav */
|
||||
protected $grav;
|
||||
|
||||
/** @var Pages $pages */
|
||||
protected $pages;
|
||||
|
||||
/** @var Page $root_page */
|
||||
protected $root_page;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
$this->grav = Fixtures::get('grav');
|
||||
$this->pages = $this->grav['pages'];
|
||||
|
||||
/** @var UniformResourceLocator $locator */
|
||||
$locator = $this->grav['locator'];
|
||||
$locator->addPath('page', '', 'tests/fake/simple-site/user/pages', false);
|
||||
$this->pages->init();
|
||||
}
|
||||
|
||||
public function testAll()
|
||||
{
|
||||
$this->assertTrue(is_object($this->pages->all()));
|
||||
$this->assertTrue(is_array($this->pages->all()->toArray()));
|
||||
$this->assertInstanceOf('Grav\Common\Page\Page', $this->pages->all()->first());
|
||||
}
|
||||
|
||||
public function testGetList()
|
||||
{
|
||||
$list = $this->pages->getList();
|
||||
$this->assertTrue(is_array($list));
|
||||
$this->assertSame($list['/'], 'Home');
|
||||
$this->assertSame($list['/blog'], 'Blog');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user