Merge pull request #1 from getgrav/develop

Sync Fork
This commit is contained in:
Tyler Cosgrove 2016-02-01 11:44:48 -05:00
commit 1f5641069b
13 changed files with 341 additions and 123 deletions

View File

@ -8,6 +8,7 @@
"require": {
"php": ">=5.5.9",
"twig/twig": "~1.24",
"erusev/parsedown": "dev-master as 1.6.0",
"erusev/parsedown-extra": "~0.7",
"symfony/yaml": "~2.8",
"symfony/console": "~2.8",
@ -31,12 +32,6 @@
"codeception/codeception": "^2.1",
"fzaninotto/faker": "^1.5"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/getgrav/parsedown"
}
],
"autoload": {
"psr-4": {
"Grav\\": "system/src/Grav"

36
composer.lock generated
View File

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "a779e113a6d1bc09fff7a0a27ec8251e",
"content-hash": "335b1c5c62ea10a4df7d085816a50f91",
"hash": "a641806eb4174e72533c76a56d4fac5e",
"content-hash": "812ba1911705385948bc6b15c197f9b4",
"packages": [
{
"name": "doctrine/cache",
@ -130,24 +130,28 @@
},
{
"name": "erusev/parsedown",
"version": "1.6.0",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/getgrav/parsedown.git",
"reference": "3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7"
"url": "https://github.com/erusev/parsedown.git",
"reference": "94688f21cc5d8bc85f1783b4c8b98b3288d712cb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/getgrav/parsedown/zipball/3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7",
"reference": "3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/94688f21cc5d8bc85f1783b4c8b98b3288d712cb",
"reference": "94688f21cc5d8bc85f1783b4c8b98b3288d712cb",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"autoload": {
"psr-0": {
"Parsedown": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -164,10 +168,7 @@
"markdown",
"parser"
],
"support": {
"source": "https://github.com/getgrav/parsedown/tree/1.6.0"
},
"time": "2015-10-04 16:44:32"
"time": "2016-01-07 17:36:51"
},
{
"name": "erusev/parsedown-extra",
@ -2647,9 +2648,18 @@
"time": "2015-12-05 11:13:14"
}
],
"aliases": [],
"aliases": [
{
"alias": "1.6.0",
"alias_normalized": "1.6.0.0",
"version": "9999999-dev",
"package": "erusev/parsedown"
}
],
"minimum-stability": "stable",
"stability-flags": [],
"stability-flags": {
"erusev/parsedown": 20
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {

View File

@ -190,21 +190,6 @@ class Grav extends Container
return new Browser();
};
$container['base_url_absolute'] = function ($c) {
/** @var Grav $c */
return $c['config']->get('system.base_url_absolute') ?: $c['uri']->rootUrl(true);
};
$container['base_url_relative'] = function ($c) {
/** @var Grav $c */
return $c['config']->get('system.base_url_relative') ?: $c['uri']->rootUrl(false);
};
$container['base_url'] = function ($c) {
/** @var Grav $c */
return $c['config']->get('system.absolute_urls') ? $c['base_url_absolute'] : $c['base_url_relative'];
};
$container->register(new StreamsServiceProvider);
$container->register(new ConfigServiceProvider);

View File

@ -221,7 +221,6 @@ class Uri
{
$this->initializeWithUrl($url);
$this->root_path = $root_path;
$this->root = $this->base . $this->root_path;
return $this;
}
@ -304,6 +303,11 @@ class Uri
if ($this->content_path != '') {
$this->paths = explode('/', $this->content_path);
}
// Set some Grav stuff
$grav['base_url_absolute'] = $this->rootUrl(true);
$grav['base_url_relative'] = $this->rootUrl(false);
$grav['base_url'] = $grav['config']->get('system.absolute_urls') ? $grav['base_url_absolute'] : $grav['base_url_relative'];
}
/**

View File

@ -40,8 +40,11 @@ $grav = Grav::instance(
)
);
$grav['uri']->init();
$grav['debugger']->init();
$grav['assets']->init();
$grav['config']->set('system.cache.enabled', false);
// Set default $_SERVER value used for nonces
empty( $_SERVER['HTTP_CLIENT_IP'] ) && $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.1';

View File

@ -1,13 +1,80 @@
<?php
namespace Helper;
use Codeception;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class Unit extends \Codeception\Module
/**
* Class Unit
* @package Helper
*/
class Unit extends Codeception\Module
{
public function _afterSuite()
{
// Tear down after test suite
/**
* HOOK: used after configuration is loaded
*/
public function _initialize() {
}
/**
* HOOK: on every Actor class initialization
*/
public function _cleanup() {
}
/**
* HOOK: before suite
*
* @param array $settings
*/
public function _beforeSuite($settings = []) {
}
/**
* HOOK: after suite
**/
public function _afterSuite() {
}
/**
* HOOK: before each step
*
* @param Codeception\Step $step*
*/
public function _beforeStep(Codeception\Step $step) {
}
/**
* HOOK: after each step
*
* @param Codeception\Step $step
*/
public function _afterStep(Codeception\Step $step) {
}
/**
* HOOK: before each suite
*
* @param Codeception\TestCase $test
*/
public function _before(Codeception\TestCase $test) {
}
/**
* HOOK: before each suite
*
* @param Codeception\TestCase $test
*/
public function _after(Codeception\TestCase $test) {
}
/**
* HOOK: on fail
*
* @param Codeception\TestCase $test
* @param $fail
*/
public function _failed(Codeception\TestCase $test, $fail) {
}
}

View File

@ -1 +1,10 @@
Test
---
title: Home
---
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

View File

@ -0,0 +1,10 @@
---
title: Blog
---
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

View File

@ -1 +1,10 @@
Test
---
title: Post 1
---
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

View File

@ -1 +1,10 @@
Test
---
title: Post 2
---
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

View File

@ -1,5 +1,10 @@
---
title: test
title: About
---
# Test
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

View File

@ -2,6 +2,8 @@
use Codeception\Util\Fixtures;
use Grav\Common\Grav;
use Grav\Common\Uri;
use Grav\Common\Config\Config;
use Grav\Common\Page\Pages;
use Grav\Common\Page\Page;
use Grav\Common\Markdown\Parsedown;
@ -21,16 +23,33 @@ class MarkdownTest extends \Codeception\TestCase\Test
/** @var Pages $pages */
protected $pages;
/** @var Config $config */
protected $config;
/** @var Uri $uri */
protected $uri;
static $run = false;
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/nested-site/user/pages', false);
$this->pages->init();
$this->config = $this->grav['config'];
$this->uri = $this->grav['uri'];
if (!self::$run) {
/** @var UniformResourceLocator $locator */
$locator = $this->grav['locator'];
$locator->addPath('page', '', 'tests/fake/nested-site/user/pages', false);
$this->pages->init();
self::$run = true;
}
$defaults = [
'extra' => false,
@ -42,6 +61,9 @@ class MarkdownTest extends \Codeception\TestCase\Test
$page = $this->pages->dispatch('/item2/item2-2');
$this->parsedown = new Parsedown($page, $defaults);
}
protected function _after()
@ -58,108 +80,192 @@ class MarkdownTest extends \Codeception\TestCase\Test
return preg_replace('/^\s*(.*)/', '', $string);
}
public function testAnchorLinks()
public function testAnchorLinksNoPortRelativeUrls()
{
$this->assertSame($this->parsedown->text('[Peer Anchor](../item2-1#foo)'),
'<p><a href="/item2/item2-1#foo">Peer Anchor</a></p>');
$this->assertSame($this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)'),
'<p><a href="/item2/item2-1/#foo">Peer Anchor 2</a></p>');
// $this->assertSame($this->parsedown->text('[Current Anchor](#foo)'),
// '<p><a href="#foo">Current Anchor</a></p>');
$this->assertSame($this->parsedown->text('[Root Anchor](/#foo)'),
'<p><a href="/#foo">Root Anchor</a></p>');
$this->config->set('system.absolute_urls', false);
$this->uri->initializeWithURL('http://localhost/item2/item-2-2')->init();
$this->assertSame('<p><a href="/item2/item2-1#foo">Peer Anchor</a></p>',
$this->parsedown->text('[Peer Anchor](../item2-1#foo)'));
$this->assertSame('<p><a href="/item2/item2-1/#foo">Peer Anchor 2</a></p>',
$this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)'));
// $this->assertSame('<p><a href="#foo">Current Anchor</a></p>',
// $this->parsedown->text('[Current Anchor](#foo)'));
$this->assertSame('<p><a href="/#foo">Root Anchor</a></p>',
$this->parsedown->text('[Root Anchor](/#foo)'));
}
public function testAnchorLinksNoPortAbsoluteUrls()
{
$this->config->set('system.absolute_urls', true);
$this->uri->initializeWithURL('http://localhost/item2/item-2-2')->init();
$this->assertSame('<p><a href="http://localhost/item2/item2-1#foo">Peer Anchor</a></p>',
$this->parsedown->text('[Peer Anchor](../item2-1#foo)'));
$this->assertSame('<p><a href="http://localhost/item2/item2-1/#foo">Peer Anchor 2</a></p>',
$this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)'));
// $this->assertSame('<p><a href="#foo">Current Anchor</a></p>',
// $this->parsedown->text('[Current Anchor](#foo)'));
$this->assertSame('<p><a href="http://localhost/#foo">Root Anchor</a></p>',
$this->parsedown->text('[Root Anchor](/#foo)'));
}
public function testAnchorLinksWithPortAbsoluteUrls()
{
$this->config->set('system.absolute_urls', true);
$this->uri->initializeWithURL('http://localhost:8080/item2/item-2-2')->init();
$this->assertSame('<p><a href="http://localhost:8080/item2/item2-1#foo">Peer Anchor</a></p>',
$this->parsedown->text('[Peer Anchor](../item2-1#foo)'));
$this->assertSame('<p><a href="http://localhost:8080/item2/item2-1/#foo">Peer Anchor 2</a></p>',
$this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)'));
// $this->assertSame('<p><a href="http://localhost:8080#foo">Current Anchor</a></p>',
// $this->parsedown->text('[Current Anchor](#foo)'));
$this->assertSame('<p><a href="http://localhost:8080/#foo">Root Anchor</a></p>',
$this->parsedown->text('[Root Anchor](/#foo)'));
}
public function testAnchorLinksSubDirRelativeUrls()
{
$this->config->set('system.absolute_urls', false);
$this->uri->initializeWithUrlAndRootPath('http://localhost/subdir/item2/item-2-2', '/subdir')->init();
$this->assertSame('<p><a href="/subdir/item2/item2-1#foo">Peer Anchor</a></p>',
$this->parsedown->text('[Peer Anchor](../item2-1#foo)'));
$this->assertSame('<p><a href="/subdir/item2/item2-1/#foo">Peer Anchor 2</a></p>',
$this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)'));
// $this->assertSame('<p><a href="/subdir/#foo">Current Anchor</a></p>',
// $this->parsedown->text('[Current Anchor](#foo)'));
$this->assertSame('<p><a href="/subdir/#foo">Root Anchor</a></p>',
$this->parsedown->text('[Root Anchor](/#foo)'));
}
public function testAnchorLinksSubDirAbsoluteUrls()
{
$this->config->set('system.absolute_urls', true);
$this->uri->initializeWithUrlAndRootPath('http://localhost/subdir/item2/item-2-2', '/subdir')->init();
$this->assertSame('<p><a href="http://localhost/subdir/item2/item2-1#foo">Peer Anchor</a></p>',
$this->parsedown->text('[Peer Anchor](../item2-1#foo)'));
$this->assertSame('<p><a href="http://localhost/subdir/item2/item2-1/#foo">Peer Anchor 2</a></p>',
$this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)'));
// $this->assertSame('<p><a href="http://localhost/subdir#foo">Current Anchor</a></p>',
// $this->parsedown->text('[Current Anchor](#foo)'));
$this->assertSame('<p><a href="http://localhost/subdir/#foo">Root Anchor</a></p>',
$this->parsedown->text('[Root Anchor](/#foo)'));
}
public function testSlugRelativeLinks()
{
$this->assertSame($this->parsedown->text('[Peer Page](../item2-1)'),
'<p><a href="/item2/item2-1">Peer Page</a></p>');
$this->assertSame($this->parsedown->text('[Down a Level](item2-2-1)'),
'<p><a href="/item2/item2-2/item2-2-1">Down a Level</a></p>');
$this->assertSame($this->parsedown->text('[Up a Level](..)'),
'<p><a href="/item2">Up a Level</a></p>');
$this->assertSame($this->parsedown->text('[Up and Down](../../item3/item3-3)'),
'<p><a href="/item3/item3-3">Up and Down</a></p>');
$this->assertSame($this->parsedown->text('[Down a Level with Query](item2-2-1?foo=bar)'),
'<p><a href="/item2/item2-2/item2-2-1?foo=bar">Down a Level with Query</a></p>');
// $this->assertSame($this->parsedown->text('[Up a Level with Query](../?foo=bar)'),
// '<p><a href="/item2?foo=bar">Up a Level with Query</a></p>');
$this->assertSame($this->parsedown->text('[Up and Down with Query](../../item3/item3-3?foo=bar)'),
'<p><a href="/item3/item3-3?foo=bar">Up and Down with Query</a></p>');
$this->assertSame($this->parsedown->text('[Up and Down with Param](../../item3/item3-3/foo:bar)'),
'<p><a href="/item3/item3-3/foo:bar">Up and Down with Param</a></p>');
$this->assertSame($this->parsedown->text('[Up and Down with Anchor](../../item3/item3-3#foo)'),
'<p><a href="/item3/item3-3#foo">Up and Down with Anchor</a></p>');
$this->config->set('system.absolute_urls', false);
$this->uri->initializeWithURL('http://localhost/item2/item-2-2')->init();
$this->assertSame('<p><a href="/item2/item2-1">Peer Page</a></p>',
$this->parsedown->text('[Peer Page](../item2-1)'));
$this->assertSame('<p><a href="/item2/item2-2/item2-2-1">Down a Level</a></p>',
$this->parsedown->text('[Down a Level](item2-2-1)'));
$this->assertSame('<p><a href="/item2">Up a Level</a></p>',
$this->parsedown->text('[Up a Level](..)'));
$this->assertSame('<p><a href="/item3/item3-3">Up and Down</a></p>',
$this->parsedown->text('[Up and Down](../../item3/item3-3)'));
$this->assertSame('<p><a href="/item2/item2-2/item2-2-1?foo=bar">Down a Level with Query</a></p>',
$this->parsedown->text('[Down a Level with Query](item2-2-1?foo=bar)'));
// $this->assertSame('<p><a href="/item2?foo=bar">Up a Level with Query</a></p>',
// $this->parsedown->text('[Up a Level with Query](../?foo=bar)'));
$this->assertSame('<p><a href="/item3/item3-3?foo=bar">Up and Down with Query</a></p>',
$this->parsedown->text('[Up and Down with Query](../../item3/item3-3?foo=bar)'));
$this->assertSame('<p><a href="/item3/item3-3/foo:bar">Up and Down with Param</a></p>',
$this->parsedown->text('[Up and Down with Param](../../item3/item3-3/foo:bar)'));
$this->assertSame('<p><a href="/item3/item3-3#foo">Up and Down with Anchor</a></p>',
$this->parsedown->text('[Up and Down with Anchor](../../item3/item3-3#foo)'));
}
public function testDirectoryRelativeLinks()
{
$this->assertSame($this->parsedown->text('[Peer Page](../01.item2-1)'),
'<p><a href="/item2/item2-1">Peer Page</a></p>');
$this->assertSame($this->parsedown->text('[Down a Level](01.item2-2-1)'),
'<p><a href="/item2/item2-2/item2-2-1">Down a Level</a></p>');
$this->assertSame($this->parsedown->text('[Up and Down](../../03.item3/03.item3-3)'),
'<p><a href="/item3/item3-3">Up and Down</a></p>');
$this->assertSame($this->parsedown->text('[Down a Level with Query](01.item2-2-1?foo=bar)'),
'<p><a href="/item2/item2-2/item2-2-1?foo=bar">Down a Level with Query</a></p>');
$this->assertSame($this->parsedown->text('[Up and Down with Query](../../03.item3/03.item3-3?foo=bar)'),
'<p><a href="/item3/item3-3?foo=bar">Up and Down with Query</a></p>');
// $this->assertSame($this->parsedown->text('[Up and Down with Param](../../03.item3/03.item3-3/foo:bar)'),
// '<p><a href="/item3/item3-3/foo:bar">Up and Down with Param</a></p>');
$this->assertSame($this->parsedown->text('[Up and Down with Anchor](../../03.item3/03.item3-3#foo)'),
'<p><a href="/item3/item3-3#foo">Up and Down with Anchor</a></p>');
$this->config->set('system.absolute_urls', false);
$this->uri->initializeWithURL('http://localhost/item2/item-2-2')->init();
$this->assertSame('<p><a href="/item2/item2-1">Peer Page</a></p>',
$this->parsedown->text('[Peer Page](../01.item2-1)'));
$this->assertSame('<p><a href="/item2/item2-2/item2-2-1">Down a Level</a></p>',
$this->parsedown->text('[Down a Level](01.item2-2-1)'));
$this->assertSame('<p><a href="/item3/item3-3">Up and Down</a></p>',
$this->parsedown->text('[Up and Down](../../03.item3/03.item3-3)'));
$this->assertSame('<p><a href="/item2/item2-2/item2-2-1?foo=bar">Down a Level with Query</a></p>',
$this->parsedown->text('[Down a Level with Query](01.item2-2-1?foo=bar)'));
$this->assertSame('<p><a href="/item3/item3-3?foo=bar">Up and Down with Query</a></p>',
$this->parsedown->text('[Up and Down with Query](../../03.item3/03.item3-3?foo=bar)'));
// $this->assertSame('<p><a href="/item3/item3-3/foo:bar">Up and Down with Param</a></p>',
// $this->parsedown->text('[Up and Down with Param](../../03.item3/03.item3-3/foo:bar)'));
$this->assertSame('<p><a href="/item3/item3-3#foo">Up and Down with Anchor</a></p>',
$this->parsedown->text('[Up and Down with Anchor](../../03.item3/03.item3-3#foo)'));
}
public function testDirectoryAbsoluteLinks()
{
$this->assertSame($this->parsedown->text('[Peer Page](/item2/item2-1)'),
'<p><a href="/item2/item2-1">Peer Page</a></p>');
$this->assertSame($this->parsedown->text('[Down a Level](/item2/item2-2/item2-2-1)'),
'<p><a href="/item2/item2-2/item2-2-1">Down a Level</a></p>');
$this->assertSame($this->parsedown->text('[Up a Level](/item2)'),
'<p><a href="/item2">Up a Level</a></p>');
$this->assertSame($this->parsedown->text('[With Query](/item2?foo=bar)'),
'<p><a href="/item2?foo=bar">With Query</a></p>');
$this->assertSame($this->parsedown->text('[With Param](/item2/foo:bar)'),
'<p><a href="/item2/foo:bar">With Param</a></p>');
$this->assertSame($this->parsedown->text('[With Anchor](/item2#foo)'),
'<p><a href="/item2#foo">With Anchor</a></p>');
$this->config->set('system.absolute_urls', false);
$this->uri->initializeWithURL('http://localhost/item2/item-2-2')->init();
$this->assertSame('<p><a href="/item2/item2-1">Peer Page</a></p>',
$this->parsedown->text('[Peer Page](/item2/item2-1)'));
$this->assertSame('<p><a href="/item2/item2-2/item2-2-1">Down a Level</a></p>',
$this->parsedown->text('[Down a Level](/item2/item2-2/item2-2-1)'));
$this->assertSame('<p><a href="/item2">Up a Level</a></p>',
$this->parsedown->text('[Up a Level](/item2)'));
$this->assertSame('<p><a href="/item2?foo=bar">With Query</a></p>',
$this->parsedown->text('[With Query](/item2?foo=bar)'));
$this->assertSame('<p><a href="/item2/foo:bar">With Param</a></p>',
$this->parsedown->text('[With Param](/item2/foo:bar)'));
$this->assertSame('<p><a href="/item2#foo">With Anchor</a></p>',
$this->parsedown->text('[With Anchor](/item2#foo)'));
}
public function testSpecialProtocols()
{
$this->assertSame($this->parsedown->text('[mailto](mailto:user@domain.com)'),
'<p><a href="mailto:user@domain.com">mailto</a></p>');
$this->assertSame($this->parsedown->text('[xmpp](xmpp:xyx@domain.com)'),
'<p><a href="xmpp:xyx@domain.com">xmpp</a></p>');
$this->assertSame($this->parsedown->text('[tel](tel:123-555-12345)'),
'<p><a href="tel:123-555-12345">tel</a></p>');
$this->assertSame($this->parsedown->text('[sms](sms:123-555-12345)'),
'<p><a href="sms:123-555-12345">sms</a></p>');
$this->config->set('system.absolute_urls', false);
$this->uri->initializeWithURL('http://localhost/item2/item-2-2')->init();
$this->assertSame('<p><a href="mailto:user@domain.com">mailto</a></p>',
$this->parsedown->text('[mailto](mailto:user@domain.com)'));
$this->assertSame('<p><a href="xmpp:xyx@domain.com">xmpp</a></p>',
$this->parsedown->text('[xmpp](xmpp:xyx@domain.com)'));
$this->assertSame('<p><a href="tel:123-555-12345">tel</a></p>',
$this->parsedown->text('[tel](tel:123-555-12345)'));
$this->assertSame('<p><a href="sms:123-555-12345">sms</a></p>',
$this->parsedown->text('[sms](sms:123-555-12345)'));
}
public function testReferenceLinks()
{
$this->config->set('system.absolute_urls', false);
$this->uri->initializeWithURL('http://localhost/item2/item-2-2')->init();
$sample = '[relative link][r_relative]
[r_relative]: ../item2-3#blah';
$this->assertSame($this->parsedown->text($sample), '<p><a href="/item2/item2-3#blah">relative link</a></p>');
$this->assertSame('<p><a href="/item2/item2-3#blah">relative link</a></p>',
$this->parsedown->text($sample));
$sample = '[absolute link][r_absolute]
[r_absolute]: /item3#blah';
$this->assertSame($this->parsedown->text($sample),
'<p><a href="/item3#blah">absolute link</a></p>');
$this->assertSame('<p><a href="/item3#blah">absolute link</a></p>',
$this->parsedown->text($sample));
$sample = '[external link][r_external]
[r_external]: http://www.cnn.com';
$this->assertSame($this->parsedown->text($sample), '<p><a href="http://www.cnn.com">external link</a></p>');
$this->assertSame('<p><a href="http://www.cnn.com">external link</a></p>',
$this->parsedown->text($sample));
}
public function testExternalLinks()
{
$this->assertSame($this->parsedown->text('[cnn.com](http://www.cnn.com)'),
'<p><a href="http://www.cnn.com">cnn.com</a></p>');
$this->assertSame($this->parsedown->text('[google.com](https://www.google.com)'),
'<p><a href="https://www.google.com">google.com</a></p>');
$this->assertSame('<p><a href="http://www.cnn.com">cnn.com</a></p>',
$this->parsedown->text('[cnn.com](http://www.cnn.com)'));
$this->assertSame('<p><a href="https://www.google.com">google.com</a></p>',
$this->parsedown->text('[google.com](https://www.google.com)'));
}
}

View File

@ -21,15 +21,21 @@ class PagesTest extends \Codeception\TestCase\Test
/** @var Page $root_page */
protected $root_page;
static $run = false;
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();
if (!self::$run) {
/** @var UniformResourceLocator $locator */
$locator = $this->grav['locator'];
$locator->addPath('page', '', 'tests/fake/simple-site/user/pages', false);
$this->pages->init();
self::$run = true;
}
}
public function testAll()
@ -43,7 +49,7 @@ class PagesTest extends \Codeception\TestCase\Test
{
$list = $this->pages->getList();
$this->assertTrue(is_array($list));
// $this->assertSame($list['/home'], 'Home');
// $this->assertSame($list['/blog'], 'Blog');
$this->assertSame($list['/'], 'Home');
$this->assertSame($list['/blog'], 'Blog');
}
}