mirror of
https://github.com/getgrav/grav.git
synced 2026-05-09 15:46:08 +02:00
Merge branch 'develop' into feature/page_level_ssl
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -39,4 +39,5 @@ user/config/security.yaml
|
||||
|
||||
tests/_output/*
|
||||
tests/_support/_generated/*
|
||||
tests/cache/*
|
||||
tests/cache/*
|
||||
tests/error.log
|
||||
|
||||
32
.travis.yml
32
.travis.yml
@@ -1,7 +1,12 @@
|
||||
language: php
|
||||
php: 5.6
|
||||
php:
|
||||
- '5.5'
|
||||
- '5.6'
|
||||
- '7.0'
|
||||
- hhvm
|
||||
branches:
|
||||
only:
|
||||
- develop
|
||||
- master
|
||||
- build_test
|
||||
notifications:
|
||||
@@ -13,7 +18,7 @@ notifications:
|
||||
rooms:
|
||||
- secure: "bqO0wM1B7bJnQw2fuhquSXEqI9gw6WmFytIh9sEWXzbYTzTUP5t0PcKOd3FT2BNMRaDxPJLVl+vG/oqmqDUBkEmOGcG504IQjeNzZqnMz0tXQMIcCc22Las9tFfc4Jf6RVi/qGomFtHGE9Wgii+TAN4zqZaufbNjwd8SyjO0+W8="
|
||||
template:
|
||||
- '%{repository}#%{build_number} (%{branch}): Grav Core and Skeletons packages have been uploaded. (<a href="%{build_url}">Details</a>)'
|
||||
- '%{repository}#%{build_number} (%{branch}): Travis Job Finished [%{duration}] (<a href="%{build_url}">Details</a>)'
|
||||
format: html
|
||||
env:
|
||||
global:
|
||||
@@ -42,15 +47,24 @@ env:
|
||||
before_install:
|
||||
- export TZ=Pacific/Honolulu
|
||||
- composer self-update
|
||||
- go get github.com/aktau/github-release
|
||||
- echo "Travis Date - `date`"
|
||||
- git clone --quiet --depth=50 --branch=master https://${BB_TOKEN}bitbucket.org/rockettheme/grav-devtools.git $RT_DEVTOOLS &>/dev/null;
|
||||
- if [ ! -z "$TRAVIS_TAG" ]; then
|
||||
cd "${RT_DEVTOOLS}";
|
||||
./build-grav.sh skeletons.txt;
|
||||
- if [ $TRAVIS_BRANCH == 'develop' ]; then
|
||||
composer install --dev --prefer-dist;
|
||||
fi
|
||||
- if [ $TRAVIS_BRANCH != 'develop' ] && [ $TRAVIS_PHP_VERSION == '5.6' ] && [ $TRAVIS_PULL_REQUEST == "false" ]; then
|
||||
go get github.com/aktau/github-release;
|
||||
git clone --quiet --depth=50 --branch=master https://${BB_TOKEN}bitbucket.org/rockettheme/grav-devtools.git $RT_DEVTOOLS &>/dev/null;
|
||||
if [ ! -z "$TRAVIS_TAG" ]; then
|
||||
cd ${RT_DEVTOOLS};
|
||||
./build-grav.sh skeletons.txt;
|
||||
fi;
|
||||
fi
|
||||
before_script:
|
||||
- [ $TRAVIS_PHP_VERSION != 'hhvm' ]; then phpenv config-rm xdebug.ini; fi
|
||||
script:
|
||||
- if [ ! -z "$TRAVIS_TAG" ]; then
|
||||
- if [ $TRAVIS_BRANCH == 'develop' ]; then
|
||||
vendor/bin/codecept run;
|
||||
fi
|
||||
- if [ ! -z "$TRAVIS_TAG" ] && [ $TRAVIS_BRANCH != 'develop' ] && [ $TRAVIS_PHP_VERSION == '5.6' ] && [ $TRAVIS_PULL_REQUEST == "false" ]; then
|
||||
FILES="$RT_DEVTOOLS/grav-dist/*.zip";
|
||||
for file in ${FILES[@]}; do
|
||||
NAME=${file##*/};
|
||||
|
||||
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,3 +1,9 @@
|
||||
# v1.0.9
|
||||
## XX/XX/2016
|
||||
|
||||
1. [](#improved)
|
||||
* [BC] Metadata now supports only flat arrays. To use open graph metas and the likes (ie, 'og:title'), simply specify it in the key.
|
||||
|
||||
# v1.0.8
|
||||
## 01/08/2016
|
||||
|
||||
@@ -18,13 +24,13 @@
|
||||
* Added support for APCu and PHP7.0 via new Doctrine Cache release
|
||||
* Added global setting for `twig_first` processing (false by default)
|
||||
* New configuration options for Session settings #553
|
||||
1. [](#improved)
|
||||
1. [](#improved)
|
||||
* Switched to SSL for GPM calls
|
||||
* Use `URI->host()` for session domain
|
||||
* Add support for `open_basedir` when installing packages via GPM
|
||||
* Improved `Utils::generateNonceString()` method to handle reverse proxies
|
||||
* Optimized core thumbnails saving 38% in file size
|
||||
* Added new `bin/gpm index --installed-only` option
|
||||
* Added new `bin/gpm index --installed-only` option
|
||||
* Improved GPM errors to provider more helpful diagnostic of issues
|
||||
* Removed old hardcoded PHP version references
|
||||
* Moved `onPageContentProcessed()` event so it's fired more reliably
|
||||
@@ -34,7 +40,7 @@
|
||||
* Fixed an issue with cache/config checksum not being set on cache load
|
||||
* Fix for page blueprint and theme inheritance issue #534
|
||||
* Set `ZipBackup` timeout to 10 minutes if possible
|
||||
* Fix case where we only have inline data for CSS or JS #565
|
||||
* Fix case where we only have inline data for CSS or JS #565
|
||||
* Fix `bin/grav sandbox` command to work with new `webserver-config` folder
|
||||
* Fix for markdown attributes on external URLs
|
||||
* Fixed issue where `data:` page header was acting as `publish_date:`
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#  Grav
|
||||
#  Grav [](https://travis-ci.org/getgrav/grav)
|
||||
|
||||
[](https://insight.sensiolabs.com/projects/cfd20465-d0f8-4a0a-8444-467f5b5f16ad) [](https://gitter.im/getgrav/grav?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
@@ -101,7 +101,7 @@ What you mainly want to know is that:
|
||||
* [Install](http://learn.getgrav.org/basics/installation) Grav in few seconds
|
||||
* Understand the [Configuration](http://learn.getgrav.org/basics/grav-configuration)
|
||||
* Take a peek at our available free [Skeletons](http://getgrav.org/downloads/skeletons)
|
||||
* If you have questions, jump on our [Gitter Room](https://gitter.im/getgrav/grav)!
|
||||
* If you have questions, jump on our [Gitter Room](https://gitter.im/getgrav/grav)!
|
||||
* Have fun!
|
||||
|
||||
# Exploring More
|
||||
|
||||
1515
composer.lock
generated
1515
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -101,6 +101,8 @@ class Page
|
||||
|
||||
/**
|
||||
* Page Object Constructor
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -110,6 +112,8 @@ class Page
|
||||
$this->taxonomy = [];
|
||||
$this->process = $config->get('system.pages.process');
|
||||
$this->published = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,6 +121,8 @@ class Page
|
||||
*
|
||||
* @param \SplFileInfo $file The file information for the .md file that the page represents
|
||||
* @param string $extension
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function init(\SplFileInfo $file, $extension = null)
|
||||
{
|
||||
@@ -148,6 +154,8 @@ class Page
|
||||
// extract page language from page extension
|
||||
$language = trim(basename($this->extension(), 'md'), '.') ?: null;
|
||||
$this->language($language);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1247,28 +1255,31 @@ class Page
|
||||
// Build an array of meta objects..
|
||||
foreach ((array)$metadata as $key => $value) {
|
||||
// If this is a property type metadata: "og", "twitter", "facebook" etc
|
||||
// Backward compatibility for nested arrays in metas
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $property => $prop_value) {
|
||||
$prop_key = $key . ":" . $property;
|
||||
$this->metadata[$prop_key] = [
|
||||
'property' => $prop_key,
|
||||
'content' => htmlspecialchars($prop_value, ENT_QUOTES)
|
||||
];
|
||||
$prop_key = $key . ":" . $property;
|
||||
$this->metadata[$prop_key] = ['name' => $prop_key, 'property' => $prop_key, 'content' => htmlspecialchars($prop_value, ENT_QUOTES)];
|
||||
}
|
||||
// If it this is a standard meta data type
|
||||
} else {
|
||||
// If it this is a standard meta data type
|
||||
if ($value) {
|
||||
if (in_array($key, $header_tag_http_equivs)) {
|
||||
$this->metadata[$key] = [
|
||||
'http_equiv' => $key,
|
||||
'content' => htmlspecialchars($value, ENT_QUOTES)
|
||||
];
|
||||
$this->metadata[$key] = ['http_equiv' => $key, 'content' => htmlspecialchars($value, ENT_QUOTES)];
|
||||
} else {
|
||||
$this->metadata[$key] = ['name' => $key, 'content' => htmlspecialchars($value, ENT_QUOTES)];
|
||||
// if it's a social metadata with separator, render as property
|
||||
$separator = strpos($key, ':');
|
||||
$hasSeparator = $separator && $separator < strlen($key) - 1;
|
||||
$entry = ['name' => $key, 'content' => htmlspecialchars($value, ENT_QUOTES)];
|
||||
|
||||
if ($hasSeparator) {
|
||||
$entry['property'] = $key;
|
||||
}
|
||||
|
||||
$this->metadata[$key] = $entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
|
||||
use Whoops\Exception\ErrorException;
|
||||
|
||||
/**
|
||||
* GravPages is the class that is the entry point into the hierarchy of pages
|
||||
* Pages is the class that is the entry point into the hierarchy of pages
|
||||
*
|
||||
* @author RocketTheme
|
||||
* @license MIT
|
||||
@@ -63,8 +63,19 @@ class Pages
|
||||
*/
|
||||
protected $last_modified;
|
||||
|
||||
/**
|
||||
* @var array|string[]
|
||||
*/
|
||||
protected $ignore_files;
|
||||
|
||||
/**
|
||||
* @var array|string[]
|
||||
*/
|
||||
protected $ignore_folders;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $ignore_hidden;
|
||||
|
||||
/**
|
||||
@@ -72,6 +83,9 @@ class Pages
|
||||
*/
|
||||
static protected $types;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
static protected $home_route;
|
||||
|
||||
/**
|
||||
@@ -112,6 +126,10 @@ class Pages
|
||||
$this->ignore_folders = $config->get('system.pages.ignore_folders');
|
||||
$this->ignore_hidden = $config->get('system.pages.ignore_hidden');
|
||||
|
||||
$this->instances = [];
|
||||
$this->children = [];
|
||||
$this->routes = [];
|
||||
|
||||
$this->buildPages();
|
||||
}
|
||||
|
||||
@@ -351,7 +369,6 @@ class Pages
|
||||
{
|
||||
/** @var UniformResourceLocator $locator */
|
||||
$locator = $this->grav['locator'];
|
||||
|
||||
return $this->instances[rtrim($locator->findResource('page://'), DS)];
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ namespace Grav;
|
||||
use Codeception\Util\Fixtures;
|
||||
use Faker\Factory;
|
||||
|
||||
ini_set('error_log', __DIR__ . '/error.log');
|
||||
|
||||
// Ensure vendor libraries exist
|
||||
$autoload = __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
|
||||
@@ -6,5 +6,8 @@ namespace Helper;
|
||||
|
||||
class Unit extends \Codeception\Module
|
||||
{
|
||||
|
||||
public function _afterSuite()
|
||||
{
|
||||
// Tear down after test suite
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,18 +0,0 @@
|
||||
<?php //[STAMP] 217732cfcf1663b385a9cfd121bbeed3
|
||||
namespace _generated;
|
||||
|
||||
// This class was automatically generated by build task
|
||||
// You should not change it manually as it will be overwritten on next build
|
||||
// @codingStandardsIgnoreFile
|
||||
|
||||
use Helper\Functional;
|
||||
|
||||
trait FunctionalTesterActions
|
||||
{
|
||||
/**
|
||||
* @return \Codeception\Scenario
|
||||
*/
|
||||
abstract protected function getScenario();
|
||||
|
||||
|
||||
}
|
||||
@@ -1,348 +0,0 @@
|
||||
<?php //[STAMP] 8c2b6acdd1e147b7717797f40c58c89c
|
||||
namespace _generated;
|
||||
|
||||
// This class was automatically generated by build task
|
||||
// You should not change it manually as it will be overwritten on next build
|
||||
// @codingStandardsIgnoreFile
|
||||
|
||||
use Codeception\Module\Asserts;
|
||||
use Helper\Unit;
|
||||
|
||||
trait UnitTesterActions
|
||||
{
|
||||
/**
|
||||
* @return \Codeception\Scenario
|
||||
*/
|
||||
abstract protected function getScenario();
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that two variables are equal.
|
||||
*
|
||||
* @param $expected
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
*
|
||||
* @return mixed
|
||||
* @see \Codeception\Module\Asserts::assertEquals()
|
||||
*/
|
||||
public function assertEquals($expected, $actual, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEquals', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that two variables are not equal
|
||||
*
|
||||
* @param $expected
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertNotEquals()
|
||||
*/
|
||||
public function assertNotEquals($expected, $actual, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEquals', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that two variables are same
|
||||
*
|
||||
* @param $expected
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
*
|
||||
* @return mixed
|
||||
* @see \Codeception\Module\Asserts::assertSame()
|
||||
*/
|
||||
public function assertSame($expected, $actual, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertSame', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that two variables are not same
|
||||
*
|
||||
* @param $expected
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertNotSame()
|
||||
*/
|
||||
public function assertNotSame($expected, $actual, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotSame', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that actual is greater than expected
|
||||
*
|
||||
* @param $expected
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertGreaterThan()
|
||||
*/
|
||||
public function assertGreaterThan($expected, $actual, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThan', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* @deprecated
|
||||
* @see \Codeception\Module\Asserts::assertGreaterThen()
|
||||
*/
|
||||
public function assertGreaterThen($expected, $actual, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThen', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that actual is greater or equal than expected
|
||||
*
|
||||
* @param $expected
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertGreaterThanOrEqual()
|
||||
*/
|
||||
public function assertGreaterThanOrEqual($expected, $actual, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThanOrEqual', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* @deprecated
|
||||
* @see \Codeception\Module\Asserts::assertGreaterThenOrEqual()
|
||||
*/
|
||||
public function assertGreaterThenOrEqual($expected, $actual, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThenOrEqual', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that actual is less than expected
|
||||
*
|
||||
* @param $expected
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertLessThan()
|
||||
*/
|
||||
public function assertLessThan($expected, $actual, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessThan', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that actual is less or equal than expected
|
||||
*
|
||||
* @param $expected
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertLessThanOrEqual()
|
||||
*/
|
||||
public function assertLessThanOrEqual($expected, $actual, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessThanOrEqual', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that haystack contains needle
|
||||
*
|
||||
* @param $needle
|
||||
* @param $haystack
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertContains()
|
||||
*/
|
||||
public function assertContains($needle, $haystack, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContains', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that haystack doesn't contain needle.
|
||||
*
|
||||
* @param $needle
|
||||
* @param $haystack
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertNotContains()
|
||||
*/
|
||||
public function assertNotContains($needle, $haystack, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotContains', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that string match with pattern
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param string $string
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertRegExp()
|
||||
*/
|
||||
public function assertRegExp($pattern, $string, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertRegExp', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that string not match with pattern
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param string $string
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertNotRegExp()
|
||||
*/
|
||||
public function assertNotRegExp($pattern, $string, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotRegExp', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that variable is empty.
|
||||
*
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertEmpty()
|
||||
*/
|
||||
public function assertEmpty($actual, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEmpty', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that variable is not empty.
|
||||
*
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertNotEmpty()
|
||||
*/
|
||||
public function assertNotEmpty($actual, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEmpty', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that variable is NULL
|
||||
*
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertNull()
|
||||
*/
|
||||
public function assertNull($actual, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNull', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that variable is not NULL
|
||||
*
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertNotNull()
|
||||
*/
|
||||
public function assertNotNull($actual, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotNull', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that condition is positive.
|
||||
*
|
||||
* @param $condition
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertTrue()
|
||||
*/
|
||||
public function assertTrue($condition, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertTrue', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that condition is negative.
|
||||
*
|
||||
* @param $condition
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertFalse()
|
||||
*/
|
||||
public function assertFalse($condition, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFalse', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks if file exists
|
||||
*
|
||||
* @param string $filename
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertFileExists()
|
||||
*/
|
||||
public function assertFileExists($filename, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileExists', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks if file doesn't exist
|
||||
*
|
||||
* @param string $filename
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertFileNotExists()
|
||||
*/
|
||||
public function assertFileNotExists($filename, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotExists', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Fails the test with message.
|
||||
*
|
||||
* @param $message
|
||||
* @see \Codeception\Module\Asserts::fail()
|
||||
*/
|
||||
public function fail($message) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('fail', func_get_args()));
|
||||
}
|
||||
}
|
||||
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
|
||||
@@ -1,276 +1,263 @@
|
||||
<?php
|
||||
|
||||
use Codeception\Util\Fixtures;
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\Assets;
|
||||
|
||||
/**
|
||||
* Class AssetsTest
|
||||
*/
|
||||
class AssetsTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
/**
|
||||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
/** @var Grav $grav */
|
||||
protected $grav;
|
||||
|
||||
/** @var Assets $assets */
|
||||
protected $assets;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
$this->grav = Fixtures::get('grav');
|
||||
$this->assets = $this->grav['assets'];
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
{
|
||||
}
|
||||
|
||||
public function grav()
|
||||
{
|
||||
$grav = Fixtures::get('grav');
|
||||
return $grav;
|
||||
}
|
||||
|
||||
public function assets()
|
||||
{
|
||||
return $this->grav()['assets'];
|
||||
}
|
||||
|
||||
public function testAddingAssets()
|
||||
{
|
||||
$assets = $this->assets();
|
||||
|
||||
//test add()
|
||||
$assets->add('test.css');
|
||||
$this->assets->add('test.css');
|
||||
|
||||
$css = $assets->css();
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame($css, '<link href="/test.css" type="text/css" rel="stylesheet" />' . PHP_EOL);
|
||||
|
||||
$array = $assets->getCss();
|
||||
$array = $this->assets->getCss();
|
||||
$this->assertSame(reset($array), [
|
||||
'asset' => '/test.css',
|
||||
'asset' => '/test.css',
|
||||
'priority' => 10,
|
||||
'order' => 0,
|
||||
'order' => 0,
|
||||
'pipeline' => true,
|
||||
'group' => 'head'
|
||||
'group' => 'head'
|
||||
]);
|
||||
|
||||
$assets->add('test.js');
|
||||
$js = $assets->js();
|
||||
$this->assets->add('test.js');
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame($js, '<script src="/test.js" type="text/javascript" ></script>' . PHP_EOL);
|
||||
|
||||
$array = $assets->getCss();
|
||||
$array = $this->assets->getCss();
|
||||
$this->assertSame(reset($array), [
|
||||
'asset' => '/test.css',
|
||||
'asset' => '/test.css',
|
||||
'priority' => 10,
|
||||
'order' => 0,
|
||||
'order' => 0,
|
||||
'pipeline' => true,
|
||||
'group' => 'head'
|
||||
'group' => 'head'
|
||||
]);
|
||||
|
||||
//test addCss(). Test adding asset to a separate group
|
||||
$assets->reset();
|
||||
$assets->addCSS('test.css');
|
||||
$css = $assets->css();
|
||||
$this->assets->reset();
|
||||
$this->assets->addCSS('test.css');
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame($css, '<link href="/test.css" type="text/css" rel="stylesheet" />' . PHP_EOL);
|
||||
|
||||
$array = $assets->getCss();
|
||||
$array = $this->assets->getCss();
|
||||
$this->assertSame(reset($array), [
|
||||
'asset' => '/test.css',
|
||||
'asset' => '/test.css',
|
||||
'priority' => 10,
|
||||
'order' => 0,
|
||||
'order' => 0,
|
||||
'pipeline' => true,
|
||||
'group' => 'head'
|
||||
'group' => 'head'
|
||||
]);
|
||||
|
||||
//test addJs()
|
||||
$assets->reset();
|
||||
$assets->addJs('test.js');
|
||||
$js = $assets->js();
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('test.js');
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame($js, '<script src="/test.js" type="text/javascript" ></script>' . PHP_EOL);
|
||||
|
||||
$array = $assets->getJs();
|
||||
$array = $this->assets->getJs();
|
||||
$this->assertSame(reset($array), [
|
||||
'asset' => '/test.js',
|
||||
'asset' => '/test.js',
|
||||
'priority' => 10,
|
||||
'order' => 0,
|
||||
'order' => 0,
|
||||
'pipeline' => true,
|
||||
'loading' => '',
|
||||
'group' => 'head'
|
||||
'loading' => '',
|
||||
'group' => 'head'
|
||||
]);
|
||||
|
||||
//Test CSS Groups
|
||||
$assets->reset();
|
||||
$assets->addCSS('test.css', null, true, 'footer');
|
||||
$css = $assets->css();
|
||||
$this->assets->reset();
|
||||
$this->assets->addCSS('test.css', null, true, 'footer');
|
||||
$css = $this->assets->css();
|
||||
$this->assertEmpty($css);
|
||||
$css = $assets->css('footer');
|
||||
$css = $this->assets->css('footer');
|
||||
$this->assertSame($css, '<link href="/test.css" type="text/css" rel="stylesheet" />' . PHP_EOL);
|
||||
|
||||
$array = $assets->getCss();
|
||||
$array = $this->assets->getCss();
|
||||
$this->assertSame(reset($array), [
|
||||
'asset' => '/test.css',
|
||||
'asset' => '/test.css',
|
||||
'priority' => 10,
|
||||
'order' => 0,
|
||||
'order' => 0,
|
||||
'pipeline' => true,
|
||||
'group' => 'footer'
|
||||
'group' => 'footer'
|
||||
]);
|
||||
|
||||
//Test JS Groups
|
||||
$assets->reset();
|
||||
$assets->addJs('test.js', null, true, null, 'footer');
|
||||
$js = $assets->js();
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('test.js', null, true, null, 'footer');
|
||||
$js = $this->assets->js();
|
||||
$this->assertEmpty($js);
|
||||
$js = $assets->js('footer');
|
||||
$js = $this->assets->js('footer');
|
||||
$this->assertSame($js, '<script src="/test.js" type="text/javascript" ></script>' . PHP_EOL);
|
||||
|
||||
$array = $assets->getJs();
|
||||
$array = $this->assets->getJs();
|
||||
$this->assertSame(reset($array), [
|
||||
'asset' => '/test.js',
|
||||
'asset' => '/test.js',
|
||||
'priority' => 10,
|
||||
'order' => 0,
|
||||
'order' => 0,
|
||||
'pipeline' => true,
|
||||
'loading' => '',
|
||||
'group' => 'footer'
|
||||
'loading' => '',
|
||||
'group' => 'footer'
|
||||
]);
|
||||
|
||||
//Test async / defer
|
||||
$assets->reset();
|
||||
$assets->addJs('test.js', null, true, 'async', null);
|
||||
$js = $assets->js();
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('test.js', null, true, 'async', null);
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame($js, '<script src="/test.js" type="text/javascript" async></script>' . PHP_EOL);
|
||||
|
||||
$array = $assets->getJs();
|
||||
$array = $this->assets->getJs();
|
||||
$this->assertSame(reset($array), [
|
||||
'asset' => '/test.js',
|
||||
'asset' => '/test.js',
|
||||
'priority' => 10,
|
||||
'order' => 0,
|
||||
'order' => 0,
|
||||
'pipeline' => true,
|
||||
'loading' => 'async',
|
||||
'group' => 'head'
|
||||
'loading' => 'async',
|
||||
'group' => 'head'
|
||||
]);
|
||||
|
||||
$assets->reset();
|
||||
$assets->addJs('test.js', null, true, 'defer', null);
|
||||
$js = $assets->js();
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('test.js', null, true, 'defer', null);
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame($js, '<script src="/test.js" type="text/javascript" defer></script>' . PHP_EOL);
|
||||
|
||||
$array = $assets->getJs();
|
||||
$array = $this->assets->getJs();
|
||||
$this->assertSame(reset($array), [
|
||||
'asset' => '/test.js',
|
||||
'asset' => '/test.js',
|
||||
'priority' => 10,
|
||||
'order' => 0,
|
||||
'order' => 0,
|
||||
'pipeline' => true,
|
||||
'loading' => 'defer',
|
||||
'group' => 'head'
|
||||
'loading' => 'defer',
|
||||
'group' => 'head'
|
||||
]);
|
||||
}
|
||||
|
||||
public function testAddingAssetPropertiesWithArray()
|
||||
{
|
||||
$assets = $this->assets();
|
||||
|
||||
//Test adding assets with object to define properties
|
||||
$assets->reset();
|
||||
$assets->addJs('test.js', ['loading' => 'async']);
|
||||
$js = $assets->js();
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('test.js', ['loading' => 'async']);
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame($js, '<script src="/test.js" type="text/javascript" async></script>' . PHP_EOL);
|
||||
$assets->reset();
|
||||
$this->assets->reset();
|
||||
|
||||
}
|
||||
|
||||
public function testAddingJSAssetPropertiesWithArrayFromCollection()
|
||||
{
|
||||
$assets = $this->assets();
|
||||
|
||||
//Test adding properties with array
|
||||
$assets->reset();
|
||||
$assets->addJs('jquery', ['loading' => 'async']);
|
||||
$js = $assets->js();
|
||||
$this->assertSame($js, '<script src="/system/assets/jquery/jquery-2.x.min.js" type="text/javascript" async></script>' . PHP_EOL);
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('jquery', ['loading' => 'async']);
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame($js,
|
||||
'<script src="/system/assets/jquery/jquery-2.x.min.js" type="text/javascript" async></script>' . PHP_EOL);
|
||||
|
||||
//Test priority too
|
||||
$assets->reset();
|
||||
$assets->addJs('jquery', ['loading' => 'async', 'priority' => 1]);
|
||||
$assets->addJs('test.js', ['loading' => 'async', 'priority' => 2]);
|
||||
$js = $assets->js();
|
||||
$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($js, '<script src="/test.js" type="text/javascript" async></script>' . PHP_EOL .
|
||||
'<script src="/system/assets/jquery/jquery-2.x.min.js" type="text/javascript" async></script>' . PHP_EOL);
|
||||
|
||||
//Test multiple groups
|
||||
$assets->reset();
|
||||
$assets->addJs('jquery', ['loading' => 'async', 'priority' => 1, 'group' => 'footer']);
|
||||
$assets->addJs('test.js', ['loading' => 'async', 'priority' => 2]);
|
||||
$js = $assets->js();
|
||||
$this->assets->reset();
|
||||
$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($js, '<script src="/test.js" type="text/javascript" async></script>' . PHP_EOL);
|
||||
$js = $assets->js('footer');
|
||||
$this->assertSame($js, '<script src="/system/assets/jquery/jquery-2.x.min.js" type="text/javascript" async></script>' . PHP_EOL);
|
||||
$js = $this->assets->js('footer');
|
||||
$this->assertSame($js,
|
||||
'<script src="/system/assets/jquery/jquery-2.x.min.js" type="text/javascript" async></script>' . PHP_EOL);
|
||||
|
||||
//Test adding array of assets
|
||||
//Test priority too
|
||||
$assets->reset();
|
||||
$assets->addJs(['jquery', 'test.js'], ['loading' => 'async']);
|
||||
$js = $assets->js();
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs(['jquery', 'test.js'], ['loading' => 'async']);
|
||||
$js = $this->assets->js();
|
||||
|
||||
$this->assertSame($js, '<script src="/system/assets/jquery/jquery-2.x.min.js" type="text/javascript" async></script>' . PHP_EOL .
|
||||
$this->assertSame($js,
|
||||
'<script src="/system/assets/jquery/jquery-2.x.min.js" type="text/javascript" async></script>' . PHP_EOL .
|
||||
'<script src="/test.js" type="text/javascript" async></script>' . PHP_EOL);
|
||||
}
|
||||
|
||||
public function testAddingCSSAssetPropertiesWithArrayFromCollection()
|
||||
{
|
||||
$assets = $this->assets();
|
||||
|
||||
$assets->registerCollection('test', ['/system/assets/whoops.css']);
|
||||
$this->assets->registerCollection('test', ['/system/assets/whoops.css']);
|
||||
|
||||
//Test priority too
|
||||
$assets->reset();
|
||||
$assets->addCss('test', ['priority' => 1]);
|
||||
$assets->addCss('test.css', ['priority' => 2]);
|
||||
$css = $assets->css();
|
||||
$this->assets->reset();
|
||||
$this->assets->addCss('test', ['priority' => 1]);
|
||||
$this->assets->addCss('test.css', ['priority' => 2]);
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame($css, '<link href="/test.css" type="text/css" rel="stylesheet" />' . PHP_EOL .
|
||||
'<link href="/system/assets/whoops.css" type="text/css" rel="stylesheet" />' . PHP_EOL);
|
||||
|
||||
//Test multiple groups
|
||||
$assets->reset();
|
||||
$assets->addCss('test', ['priority' => 1, 'group' => 'footer']);
|
||||
$assets->addCss('test.css', ['priority' => 2]);
|
||||
$css = $assets->css();
|
||||
$this->assets->reset();
|
||||
$this->assets->addCss('test', ['priority' => 1, 'group' => 'footer']);
|
||||
$this->assets->addCss('test.css', ['priority' => 2]);
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame($css, '<link href="/test.css" type="text/css" rel="stylesheet" />' . PHP_EOL);
|
||||
$css = $assets->css('footer');
|
||||
$css = $this->assets->css('footer');
|
||||
$this->assertSame($css, '<link href="/system/assets/whoops.css" type="text/css" rel="stylesheet" />' . PHP_EOL);
|
||||
|
||||
//Test adding array of assets
|
||||
//Test priority too
|
||||
$assets->reset();
|
||||
$assets->addCss(['test', 'test.css'], ['loading' => 'async']);
|
||||
$css = $assets->css();
|
||||
$this->assets->reset();
|
||||
$this->assets->addCss(['test', 'test.css'], ['loading' => 'async']);
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame($css, '<link href="/system/assets/whoops.css" type="text/css" rel="stylesheet" />' . PHP_EOL .
|
||||
'<link href="/test.css" type="text/css" rel="stylesheet" />' . PHP_EOL);
|
||||
}
|
||||
|
||||
public function testPriorityOfAssets()
|
||||
{
|
||||
$assets = $this->assets();
|
||||
$this->assets->reset();
|
||||
$this->assets->add('test.css');
|
||||
$this->assets->add('test-after.css');
|
||||
|
||||
$assets->reset();
|
||||
$assets->add('test.css');
|
||||
$assets->add('test-after.css');
|
||||
|
||||
$css = $assets->css();
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame($css, '<link href="/test.css" type="text/css" rel="stylesheet" />' . PHP_EOL .
|
||||
'<link href="/test-after.css" type="text/css" rel="stylesheet" />' . PHP_EOL);
|
||||
|
||||
//----------------
|
||||
$assets->reset();
|
||||
$assets->add('test-after.css', 1);
|
||||
$assets->add('test.css', 2);
|
||||
$this->assets->reset();
|
||||
$this->assets->add('test-after.css', 1);
|
||||
$this->assets->add('test.css', 2);
|
||||
|
||||
$css = $assets->css();
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame($css, '<link href="/test.css" type="text/css" rel="stylesheet" />' . PHP_EOL .
|
||||
'<link href="/test-after.css" type="text/css" rel="stylesheet" />' . PHP_EOL);
|
||||
|
||||
//----------------
|
||||
$assets->reset();
|
||||
$assets->add('test-after.css', 1);
|
||||
$assets->add('test.css', 2);
|
||||
$assets->add('test-before.css', 3);
|
||||
$this->assets->reset();
|
||||
$this->assets->add('test-after.css', 1);
|
||||
$this->assets->add('test.css', 2);
|
||||
$this->assets->add('test-before.css', 3);
|
||||
|
||||
$css = $assets->css();
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame($css, '<link href="/test-before.css" type="text/css" rel="stylesheet" />' . PHP_EOL .
|
||||
'<link href="/test.css" type="text/css" rel="stylesheet" />' . PHP_EOL .
|
||||
'<link href="/test-after.css" type="text/css" rel="stylesheet" />' . PHP_EOL);
|
||||
@@ -278,196 +265,175 @@ class AssetsTest extends \Codeception\TestCase\Test
|
||||
|
||||
public function testPipeline()
|
||||
{
|
||||
$assets = $this->assets();
|
||||
|
||||
$assets->reset();
|
||||
$this->assets->reset();
|
||||
|
||||
//File not existing. Pipeline searches for that file without reaching it. Output is empty.
|
||||
$assets->add('test.css', null, true);
|
||||
$assets->setCssPipeline(true);
|
||||
$css = $assets->css();
|
||||
$this->assets->add('test.css', null, true);
|
||||
$this->assets->setCssPipeline(true);
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame($css, '');
|
||||
|
||||
//Add a core Grav CSS file, which is found. Pipeline will now return a file
|
||||
$assets->add('/system/assets/debugger.css', null, true);
|
||||
$css = $assets->css();
|
||||
$this->assets->add('/system/assets/debugger.css', null, true);
|
||||
$css = $this->assets->css();
|
||||
$this->assertContains('<link href=', $css);
|
||||
$this->assertContains('type="text/css" rel="stylesheet" />', $css);
|
||||
}
|
||||
|
||||
public function testAddAsyncJs()
|
||||
{
|
||||
$assets = $this->assets();
|
||||
|
||||
$assets->reset();
|
||||
$assets->addAsyncJs('jquery');
|
||||
$js = $assets->js();
|
||||
$this->assertSame($js, '<script src="/system/assets/jquery/jquery-2.x.min.js" type="text/javascript" async></script>' . PHP_EOL);
|
||||
$this->assets->reset();
|
||||
$this->assets->addAsyncJs('jquery');
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame($js,
|
||||
'<script src="/system/assets/jquery/jquery-2.x.min.js" type="text/javascript" async></script>' . PHP_EOL);
|
||||
}
|
||||
|
||||
public function testAddDeferJs()
|
||||
{
|
||||
$assets = $this->assets();
|
||||
|
||||
$assets->reset();
|
||||
$assets->addDeferJs('jquery');
|
||||
$js = $assets->js();
|
||||
$this->assertSame($js, '<script src="/system/assets/jquery/jquery-2.x.min.js" type="text/javascript" defer></script>' . PHP_EOL);
|
||||
$this->assets->reset();
|
||||
$this->assets->addDeferJs('jquery');
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame($js,
|
||||
'<script src="/system/assets/jquery/jquery-2.x.min.js" type="text/javascript" defer></script>' . PHP_EOL);
|
||||
}
|
||||
|
||||
public function testAddInlineCss()
|
||||
{
|
||||
$assets = $this->assets();
|
||||
|
||||
$assets->reset();
|
||||
$assets->addInlineCss('body { color: black }');
|
||||
$css = $assets->css();
|
||||
$this->assertSame($css, PHP_EOL. '<style>' .PHP_EOL . 'body { color: black }' . PHP_EOL.PHP_EOL .'</style>' . PHP_EOL);
|
||||
$this->assets->reset();
|
||||
$this->assets->addInlineCss('body { color: black }');
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame($css,
|
||||
PHP_EOL . '<style>' . PHP_EOL . 'body { color: black }' . PHP_EOL . PHP_EOL . '</style>' . PHP_EOL);
|
||||
}
|
||||
|
||||
public function testAddInlineJs()
|
||||
{
|
||||
$assets = $this->assets();
|
||||
|
||||
$assets->reset();
|
||||
$assets->addInlineJs('alert("test")');
|
||||
$js = $assets->js();
|
||||
$this->assets->reset();
|
||||
$this->assets->addInlineJs('alert("test")');
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame($js,
|
||||
PHP_EOL . '<script>' . PHP_EOL . 'alert("test")' . PHP_EOL . PHP_EOL . '</script>' . PHP_EOL);
|
||||
}
|
||||
|
||||
public function testGetCollections()
|
||||
{
|
||||
$assets = $this->assets();
|
||||
|
||||
$this->assertTrue(is_array($assets->getCollections()));
|
||||
$this->assertTrue(in_array('jquery', array_keys($assets->getCollections())));
|
||||
$this->assertTrue(in_array('system://assets/jquery/jquery-2.x.min.js', $assets->getCollections()));
|
||||
$this->assertTrue(is_array($this->assets->getCollections()));
|
||||
$this->assertTrue(in_array('jquery', array_keys($this->assets->getCollections())));
|
||||
$this->assertTrue(in_array('system://assets/jquery/jquery-2.x.min.js', $this->assets->getCollections()));
|
||||
}
|
||||
|
||||
public function testExists()
|
||||
{
|
||||
$assets = $this->assets();
|
||||
|
||||
$this->assertTrue($assets->exists('jquery'));
|
||||
$this->assertFalse($assets->exists('another-unexisting-library'));
|
||||
$this->assertTrue($this->assets->exists('jquery'));
|
||||
$this->assertFalse($this->assets->exists('another-unexisting-library'));
|
||||
}
|
||||
|
||||
public function testRegisterCollection()
|
||||
{
|
||||
$assets = $this->assets();
|
||||
|
||||
$assets->registerCollection('debugger', ['/system/assets/debugger.css']);
|
||||
$this->assertTrue($assets->exists('debugger'));
|
||||
$this->assertTrue(in_array('debugger', array_keys($assets->getCollections())));
|
||||
$this->assets->registerCollection('debugger', ['/system/assets/debugger.css']);
|
||||
$this->assertTrue($this->assets->exists('debugger'));
|
||||
$this->assertTrue(in_array('debugger', array_keys($this->assets->getCollections())));
|
||||
}
|
||||
|
||||
public function testReset()
|
||||
{
|
||||
$assets = $this->assets();
|
||||
$this->assets->addInlineJs('alert("test")');
|
||||
$this->assets->reset();
|
||||
$this->assertTrue(count($this->assets->js()) == 0);
|
||||
|
||||
$assets->addInlineJs('alert("test")');
|
||||
$assets->reset();
|
||||
$this->assertTrue(count($assets->js()) == 0);
|
||||
$this->assets->addAsyncJs('jquery');
|
||||
$this->assets->reset();
|
||||
|
||||
$assets->addAsyncJs('jquery');
|
||||
$assets->reset();
|
||||
$this->assertTrue(count($this->assets->js()) == 0);
|
||||
|
||||
$this->assertTrue(count($assets->js()) == 0);
|
||||
$this->assets->addInlineCss('body { color: black }');
|
||||
$this->assets->reset();
|
||||
|
||||
$assets->addInlineCss('body { color: black }');
|
||||
$assets->reset();
|
||||
$this->assertTrue(count($this->assets->css()) == 0);
|
||||
|
||||
$this->assertTrue(count($assets->css()) == 0);
|
||||
$this->assets->add('/system/assets/debugger.css', null, true);
|
||||
$this->assets->reset();
|
||||
|
||||
$assets->add('/system/assets/debugger.css', null, true);
|
||||
$assets->reset();
|
||||
|
||||
$this->assertTrue(count($assets->css()) == 0);
|
||||
$this->assertTrue(count($this->assets->css()) == 0);
|
||||
}
|
||||
|
||||
public function testResetJs()
|
||||
{
|
||||
$assets = $this->assets();
|
||||
$this->assets->addInlineJs('alert("test")');
|
||||
$this->assets->resetJs();
|
||||
$this->assertTrue(count($this->assets->js()) == 0);
|
||||
|
||||
$assets->addInlineJs('alert("test")');
|
||||
$assets->resetJs();
|
||||
$this->assertTrue(count($assets->js()) == 0);
|
||||
$this->assets->addAsyncJs('jquery');
|
||||
$this->assets->resetJs();
|
||||
|
||||
$assets->addAsyncJs('jquery');
|
||||
$assets->resetJs();
|
||||
|
||||
$this->assertTrue(count($assets->js()) == 0);
|
||||
$this->assertTrue(count($this->assets->js()) == 0);
|
||||
}
|
||||
|
||||
public function testResetCss()
|
||||
{
|
||||
$assets = $this->assets();
|
||||
$this->assertTrue(count($this->assets->js()) == 0);
|
||||
|
||||
$this->assertTrue(count($assets->js()) == 0);
|
||||
$this->assets->addInlineCss('body { color: black }');
|
||||
$this->assets->resetCss();
|
||||
|
||||
$assets->addInlineCss('body { color: black }');
|
||||
$assets->resetCss();
|
||||
$this->assertTrue(count($this->assets->css()) == 0);
|
||||
|
||||
$this->assertTrue(count($assets->css()) == 0);
|
||||
$this->assets->add('/system/assets/debugger.css', null, true);
|
||||
$this->assets->resetCss();
|
||||
|
||||
$assets->add('/system/assets/debugger.css', null, true);
|
||||
$assets->resetCss();
|
||||
|
||||
$this->assertTrue(count($assets->css()) == 0);
|
||||
$this->assertTrue(count($this->assets->css()) == 0);
|
||||
}
|
||||
|
||||
public function testAddDirCss()
|
||||
{
|
||||
$assets = $this->assets();
|
||||
$assets->reset();
|
||||
$assets->addDirCss('/system');
|
||||
$this->assets->addDirCss('/system');
|
||||
|
||||
$this->assertTrue(is_array($assets->getCss()));
|
||||
$this->assertTrue(count($assets->getCss()) > 0);
|
||||
$this->assertTrue(is_array($assets->getJs()));
|
||||
$this->assertTrue(count($assets->getJs()) == 0);
|
||||
$this->assertTrue(is_array($this->assets->getCss()));
|
||||
$this->assertTrue(count($this->assets->getCss()) > 0);
|
||||
$this->assertTrue(is_array($this->assets->getJs()));
|
||||
$this->assertTrue(count($this->assets->getJs()) == 0);
|
||||
|
||||
$assets->reset();
|
||||
$assets->addDirCss('/system/assets');
|
||||
$this->assets->reset();
|
||||
$this->assets->addDirCss('/system/assets');
|
||||
|
||||
$this->assertTrue(is_array($assets->getCss()));
|
||||
$this->assertTrue(count($assets->getCss()) > 0);
|
||||
$this->assertTrue(is_array($assets->getJs()));
|
||||
$this->assertTrue(count($assets->getJs()) == 0);
|
||||
$this->assertTrue(is_array($this->assets->getCss()));
|
||||
$this->assertTrue(count($this->assets->getCss()) > 0);
|
||||
$this->assertTrue(is_array($this->assets->getJs()));
|
||||
$this->assertTrue(count($this->assets->getJs()) == 0);
|
||||
|
||||
$assets->reset();
|
||||
$assets->addDirJs('/system');
|
||||
$this->assets->reset();
|
||||
$this->assets->addDirJs('/system');
|
||||
|
||||
$this->assertTrue(is_array($assets->getCss()));
|
||||
$this->assertTrue(count($assets->getCss()) == 0);
|
||||
$this->assertTrue(is_array($assets->getJs()));
|
||||
$this->assertTrue(count($assets->getJs()) > 0);
|
||||
$this->assertTrue(is_array($this->assets->getCss()));
|
||||
$this->assertTrue(count($this->assets->getCss()) == 0);
|
||||
$this->assertTrue(is_array($this->assets->getJs()));
|
||||
$this->assertTrue(count($this->assets->getJs()) > 0);
|
||||
|
||||
$assets->reset();
|
||||
$assets->addDirJs('/system/assets');
|
||||
$this->assets->reset();
|
||||
$this->assets->addDirJs('/system/assets');
|
||||
|
||||
$this->assertTrue(is_array($assets->getCss()));
|
||||
$this->assertTrue(count($assets->getCss()) == 0);
|
||||
$this->assertTrue(is_array($assets->getJs()));
|
||||
$this->assertTrue(count($assets->getJs()) > 0);
|
||||
$this->assertTrue(is_array($this->assets->getCss()));
|
||||
$this->assertTrue(count($this->assets->getCss()) == 0);
|
||||
$this->assertTrue(is_array($this->assets->getJs()));
|
||||
$this->assertTrue(count($this->assets->getJs()) > 0);
|
||||
|
||||
$assets->reset();
|
||||
$assets->addDir('/system/assets');
|
||||
$this->assets->reset();
|
||||
$this->assets->addDir('/system/assets');
|
||||
|
||||
$this->assertTrue(is_array($assets->getCss()));
|
||||
$this->assertTrue(count($assets->getCss()) > 0);
|
||||
$this->assertTrue(is_array($assets->getJs()));
|
||||
$this->assertTrue(count($assets->getJs()) > 0);
|
||||
$this->assertTrue(is_array($this->assets->getCss()));
|
||||
$this->assertTrue(count($this->assets->getCss()) > 0);
|
||||
$this->assertTrue(is_array($this->assets->getJs()));
|
||||
$this->assertTrue(count($this->assets->getJs()) > 0);
|
||||
|
||||
//Use streams
|
||||
$assets->reset();
|
||||
$assets->addDir('system://assets');
|
||||
$this->assets->reset();
|
||||
$this->assets->addDir('system://assets');
|
||||
|
||||
$this->assertTrue(is_array($assets->getCss()));
|
||||
$this->assertTrue(count($assets->getCss()) > 0);
|
||||
$this->assertTrue(is_array($assets->getJs()));
|
||||
$this->assertTrue(count($assets->getJs()) > 0);
|
||||
$this->assertTrue(is_array($this->assets->getCss()));
|
||||
$this->assertTrue(count($this->assets->getCss()) > 0);
|
||||
$this->assertTrue(is_array($this->assets->getJs()));
|
||||
$this->assertTrue(count($this->assets->getJs()) > 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +1,47 @@
|
||||
<?php
|
||||
|
||||
use Codeception\Util\Fixtures;
|
||||
use Grav\Common\Grav;
|
||||
|
||||
/**
|
||||
* Class BrowserTest
|
||||
*/
|
||||
class BrowserTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
/**
|
||||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
/** @var Grav $grav */
|
||||
protected $grav;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
$this->grav = Fixtures::get('grav');
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
{
|
||||
}
|
||||
|
||||
public function grav()
|
||||
{
|
||||
return Fixtures::get('grav');
|
||||
public function testGetBrowser()
|
||||
{ /* Already covered by PhpUserAgent tests */
|
||||
}
|
||||
|
||||
public function testGetBrowser() { /* Already covered by PhpUserAgent tests */ }
|
||||
public function testGetPlatform() { /* Already covered by PhpUserAgent tests */ }
|
||||
public function testGetLongVersion() { /* Already covered by PhpUserAgent tests */ }
|
||||
public function testGetVersion() { /* Already covered by PhpUserAgent tests */ }
|
||||
public function testGetPlatform()
|
||||
{ /* Already covered by PhpUserAgent tests */
|
||||
}
|
||||
|
||||
public function testGetLongVersion()
|
||||
{ /* Already covered by PhpUserAgent tests */
|
||||
}
|
||||
|
||||
public function testGetVersion()
|
||||
{ /* Already covered by PhpUserAgent tests */
|
||||
}
|
||||
|
||||
public function testIsHuman()
|
||||
{
|
||||
//Already Partially covered by PhpUserAgent tests
|
||||
|
||||
//Make sure it recognizes the test as not human
|
||||
$this->assertFalse($this->grav()['browser']->isHuman());
|
||||
$this->assertFalse($this->grav['browser']->isHuman());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,6 @@ use Grav\Common\Composer;
|
||||
|
||||
class ComposerTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
/**
|
||||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Codeception\Util\Fixtures;
|
||||
use Grav\Common\Grav;
|
||||
|
||||
/**
|
||||
* Class AssetsTest
|
||||
*/
|
||||
class MarkdownTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
/**
|
||||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
/** @var Parsedown $parsedown */
|
||||
protected $parsedown;
|
||||
|
||||
/** @var Grav $grav */
|
||||
protected $grav;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
$this->grav = Fixtures::get('grav');
|
||||
|
||||
$defaults = [
|
||||
'extra' => false,
|
||||
'extra' => false,
|
||||
'auto_line_breaks' => false,
|
||||
'auto_url_links' => false,
|
||||
'escape_markup' => false,
|
||||
'special_chars' => ['>' => 'gt', '<' => 'lt'],
|
||||
'auto_url_links' => false,
|
||||
'escape_markup' => false,
|
||||
'special_chars' => ['>' => 'gt', '<' => 'lt'],
|
||||
];
|
||||
$page = new \Grav\Common\Page\Page();
|
||||
|
||||
@@ -31,24 +34,26 @@ class MarkdownTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
}
|
||||
|
||||
public function grav()
|
||||
{
|
||||
$grav = Fixtures::get('grav');
|
||||
return $grav;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $string
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function stripLeadingWhitespace($string)
|
||||
{
|
||||
return preg_replace('/^\s*(.*)/', '', $string);
|
||||
}
|
||||
|
||||
|
||||
public function testMarkdownSpecialProtocols()
|
||||
{
|
||||
$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->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>');
|
||||
}
|
||||
|
||||
public function testMarkdownReferenceLinks()
|
||||
@@ -59,7 +64,8 @@ class MarkdownTest extends \Codeception\TestCase\Test
|
||||
|
||||
$sample = '[absolute link][r_absolute]
|
||||
[r_absolute]: /blog/focus-and-blur#blah';
|
||||
$this->assertSame($this->parsedown->text($sample), '<p><a href="/blog/focus-and-blur#blah">absolute link</a></p>');
|
||||
$this->assertSame($this->parsedown->text($sample),
|
||||
'<p><a href="/blog/focus-and-blur#blah">absolute link</a></p>');
|
||||
|
||||
$sample = '[external link][r_external]
|
||||
[r_external]: http://www.cnn.com';
|
||||
@@ -68,7 +74,9 @@ class MarkdownTest extends \Codeception\TestCase\Test
|
||||
|
||||
public function testMarkdownExternalLinks()
|
||||
{
|
||||
$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($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>');
|
||||
}
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
@@ -1,435 +1,397 @@
|
||||
<?php
|
||||
|
||||
use Codeception\Util\Fixtures;
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\Uri;
|
||||
use Grav\Common\Utils;
|
||||
|
||||
/**
|
||||
* Class UriTest
|
||||
*/
|
||||
class UriTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
/**
|
||||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
/** @var Grav $grav */
|
||||
protected $grav;
|
||||
|
||||
/** @var Uri $uri */
|
||||
protected $uri;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
$this->grav = Fixtures::get('grav');
|
||||
$this->uri = $this->grav['uri'];
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
{
|
||||
}
|
||||
|
||||
public function grav()
|
||||
{
|
||||
return Fixtures::get('grav');
|
||||
}
|
||||
|
||||
public function getURI()
|
||||
{
|
||||
return $this->grav()['uri'];
|
||||
}
|
||||
|
||||
public function testValidatingHostname()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
$this->assertTrue($this->uri->validateHostname('localhost') == 1);
|
||||
$this->assertTrue($this->uri->validateHostname('google.com') == 1);
|
||||
$this->assertTrue($this->uri->validateHostname('google.it') == 1);
|
||||
$this->assertTrue($this->uri->validateHostname('goog.le') == 1);
|
||||
$this->assertTrue($this->uri->validateHostname('goog.wine') == 1);
|
||||
$this->assertTrue($this->uri->validateHostname('goog.localhost') == 1);
|
||||
|
||||
$this->assertTrue($uri->validateHostname('localhost') == 1);
|
||||
$this->assertTrue($uri->validateHostname('google.com') == 1);
|
||||
$this->assertTrue($uri->validateHostname('google.it') == 1);
|
||||
$this->assertTrue($uri->validateHostname('goog.le') == 1);
|
||||
$this->assertTrue($uri->validateHostname('goog.wine') == 1);
|
||||
$this->assertTrue($uri->validateHostname('goog.localhost') == 1);
|
||||
|
||||
$this->assertFalse($uri->validateHostname('localhost:80') == 1);
|
||||
$this->assertFalse($uri->validateHostname('http://localhost') == 1);
|
||||
$this->assertFalse($uri->validateHostname('localhost!') == 1);
|
||||
$this->assertFalse($this->uri->validateHostname('localhost:80') == 1);
|
||||
$this->assertFalse($this->uri->validateHostname('http://localhost') == 1);
|
||||
$this->assertFalse($this->uri->validateHostname('localhost!') == 1);
|
||||
}
|
||||
|
||||
public function testInitializingUris()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init();
|
||||
$this->assertTrue($this->uri->params() == null);
|
||||
$this->assertTrue($this->uri->query() == '');
|
||||
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init();
|
||||
$this->assertTrue($uri->params() == null);
|
||||
$this->assertTrue($uri->query() == '');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertFalse($this->uri->params() == null);
|
||||
$this->assertTrue($this->uri->query() == '');
|
||||
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertFalse($uri->params() == null);
|
||||
$this->assertTrue($uri->query() == '');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init();
|
||||
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init();
|
||||
$this->assertTrue($this->uri->params() == null);
|
||||
$this->assertTrue($this->uri->query() != '');
|
||||
$this->assertTrue($this->uri->query() == 'test=x');
|
||||
$this->assertTrue($this->uri->port() == '8080');
|
||||
|
||||
$this->assertTrue($uri->params() == null);
|
||||
$this->assertTrue($uri->query() != '');
|
||||
$this->assertTrue($uri->query() == 'test=x');
|
||||
$this->assertTrue($uri->port() == '8080');
|
||||
$this->uri->initializeWithURL('http://localhost:80/grav/it/ueper?test=x')->init();
|
||||
$this->assertTrue($this->uri->port() == '80');
|
||||
|
||||
$uri->initializeWithURL('http://localhost:80/grav/it/ueper?test=x')->init();
|
||||
$this->assertTrue($uri->port() == '80');
|
||||
$this->uri->initializeWithURL('http://localhost/grav/it/ueper?test=x')->init();
|
||||
$this->assertTrue($this->uri->port() == '80');
|
||||
|
||||
$uri->initializeWithURL('http://localhost/grav/it/ueper?test=x')->init();
|
||||
$this->assertTrue($uri->port() == '80');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init();
|
||||
$this->assertTrue($this->uri->params() == null);
|
||||
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init();
|
||||
$this->assertTrue($uri->params() == null);
|
||||
|
||||
$uri->initializeWithURL('http://grav/grav/it/ueper')->init();
|
||||
$this->assertTrue($uri->params() == null);
|
||||
$this->uri->initializeWithURL('http://grav/grav/it/ueper')->init();
|
||||
$this->assertTrue($this->uri->params() == null);
|
||||
}
|
||||
|
||||
public function testPaths()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init();
|
||||
$this->assertSame($uri->paths(), ['grav', 'it', 'ueper']);
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame($uri->paths(), ['grav', 'it']);
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init();
|
||||
$this->assertSame($uri->paths(), ['grav', 'it', 'ueper']);
|
||||
$uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init();
|
||||
$this->assertSame($uri->paths(), ['a', 'b', 'c', 'd']);
|
||||
$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->assertSame($uri->paths(), ['a', 'b', 'c', 'd', 'e', 'f', 'a', 'b', 'c', 'd', 'e', 'f', 'a', 'b', 'c', 'd', 'e', 'f']);
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init();
|
||||
$this->assertSame($this->uri->paths(), ['grav', 'it', 'ueper']);
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame($this->uri->paths(), ['grav', 'it']);
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init();
|
||||
$this->assertSame($this->uri->paths(), ['grav', 'it', 'ueper']);
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init();
|
||||
$this->assertSame($this->uri->paths(), ['a', 'b', 'c', 'd']);
|
||||
$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->assertSame($this->uri->paths(),
|
||||
['a', 'b', 'c', 'd', 'e', 'f', 'a', 'b', 'c', 'd', 'e', 'f', 'a', 'b', 'c', 'd', 'e', 'f']);
|
||||
}
|
||||
|
||||
public function testRoute()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init();
|
||||
$this->assertSame($uri->route(), '/grav/it/ueper');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame($uri->route(), '/grav/it');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init();
|
||||
$this->assertSame($uri->route(), '/grav/it/ueper');
|
||||
$uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init();
|
||||
$this->assertSame($uri->route(), '/a/b/c/d');
|
||||
$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->assertSame($uri->route(), '/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init();
|
||||
$this->assertSame($this->uri->route(), '/grav/it/ueper');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame($this->uri->route(), '/grav/it');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init();
|
||||
$this->assertSame($this->uri->route(), '/grav/it/ueper');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init();
|
||||
$this->assertSame($this->uri->route(), '/a/b/c/d');
|
||||
$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->assertSame($this->uri->route(), '/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f');
|
||||
}
|
||||
|
||||
public function testQuery()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init();
|
||||
$this->assertSame($uri->query(), '');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame($uri->query(), '');
|
||||
$this->assertSame($uri->query('id'), null);
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init();
|
||||
$this->assertSame($uri->query(), 'test=x');
|
||||
$this->assertSame($uri->query('id'), null);
|
||||
$this->assertSame($uri->query('test'), 'x');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init();
|
||||
$this->assertSame($uri->query(), 'test=x&test2=y');
|
||||
$this->assertSame($uri->query('id'), null);
|
||||
$this->assertSame($uri->query('test'), 'x');
|
||||
$this->assertSame($uri->query('test2'), 'y');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init();
|
||||
$this->assertSame($uri->query(), 'test=x&test2=y&test3=x&test4=y');
|
||||
$this->assertSame($uri->query('id'), null);
|
||||
$this->assertSame($uri->query('test'), 'x');
|
||||
$this->assertSame($uri->query('test2'), 'y');
|
||||
$this->assertSame($uri->query('test4'), 'y');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init();
|
||||
$this->assertSame($this->uri->query(), '');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame($this->uri->query(), '');
|
||||
$this->assertSame($this->uri->query('id'), null);
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init();
|
||||
$this->assertSame($this->uri->query(), 'test=x');
|
||||
$this->assertSame($this->uri->query('id'), null);
|
||||
$this->assertSame($this->uri->query('test'), 'x');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init();
|
||||
$this->assertSame($this->uri->query(), 'test=x&test2=y');
|
||||
$this->assertSame($this->uri->query('id'), null);
|
||||
$this->assertSame($this->uri->query('test'), 'x');
|
||||
$this->assertSame($this->uri->query('test2'), 'y');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init();
|
||||
$this->assertSame($this->uri->query(), 'test=x&test2=y&test3=x&test4=y');
|
||||
$this->assertSame($this->uri->query('id'), null);
|
||||
$this->assertSame($this->uri->query('test'), 'x');
|
||||
$this->assertSame($this->uri->query('test2'), 'y');
|
||||
$this->assertSame($this->uri->query('test4'), 'y');
|
||||
//Test all after the ? is encoded in the query
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init();
|
||||
$this->assertSame($uri->query(), 'test=x&test2=y&test3=x&test4=y%2Ftest');
|
||||
$this->assertSame($uri->query('id'), null);
|
||||
$this->assertSame($uri->query('test'), 'x');
|
||||
$this->assertSame($uri->query('test2'), 'y');
|
||||
$this->assertSame($uri->query('test4'), 'y/test');
|
||||
$uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init();
|
||||
$this->assertSame($uri->query(), '');
|
||||
$this->assertSame($uri->query('id'), null);
|
||||
$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->assertSame($uri->query(), '');
|
||||
$this->assertSame($uri->query('id'), null);
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init();
|
||||
$this->assertSame($this->uri->query(), 'test=x&test2=y&test3=x&test4=y%2Ftest');
|
||||
$this->assertSame($this->uri->query('id'), null);
|
||||
$this->assertSame($this->uri->query('test'), 'x');
|
||||
$this->assertSame($this->uri->query('test2'), 'y');
|
||||
$this->assertSame($this->uri->query('test4'), 'y/test');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init();
|
||||
$this->assertSame($this->uri->query(), '');
|
||||
$this->assertSame($this->uri->query('id'), null);
|
||||
$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->assertSame($this->uri->query(), '');
|
||||
$this->assertSame($this->uri->query('id'), null);
|
||||
}
|
||||
|
||||
public function testParams()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init();
|
||||
$this->assertSame($uri->params(), null);
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame($uri->params(), '/ueper:xxx');
|
||||
$this->assertSame($uri->params('ueper'), '/ueper:xxx');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init();
|
||||
$this->assertSame($uri->params(), '/ueper:xxx/test:yyy');
|
||||
$this->assertSame($uri->params('ueper'), '/ueper:xxx');
|
||||
$this->assertSame($uri->params('test'), '/test:yyy');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init();
|
||||
$this->assertSame($uri->params(), null);
|
||||
$this->assertSame($uri->params('ueper'), null);
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init();
|
||||
$this->assertSame($uri->params(), null);
|
||||
$this->assertSame($uri->params('ueper'), null);
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init();
|
||||
$this->assertSame($uri->params(), null);
|
||||
$this->assertSame($uri->params('ueper'), null);
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init();
|
||||
$this->assertSame($uri->params(), null);
|
||||
$this->assertSame($uri->params('ueper'), null);
|
||||
$uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init();
|
||||
$this->assertSame($uri->params(), null);
|
||||
$this->assertSame($uri->params('ueper'), null);
|
||||
$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->assertSame($uri->params(), null);
|
||||
$this->assertSame($uri->params('ueper'), null);
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init();
|
||||
$this->assertSame($this->uri->params(), null);
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame($this->uri->params(), '/ueper:xxx');
|
||||
$this->assertSame($this->uri->params('ueper'), '/ueper:xxx');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init();
|
||||
$this->assertSame($this->uri->params(), '/ueper:xxx/test:yyy');
|
||||
$this->assertSame($this->uri->params('ueper'), '/ueper:xxx');
|
||||
$this->assertSame($this->uri->params('test'), '/test:yyy');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init();
|
||||
$this->assertSame($this->uri->params(), null);
|
||||
$this->assertSame($this->uri->params('ueper'), null);
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init();
|
||||
$this->assertSame($this->uri->params(), null);
|
||||
$this->assertSame($this->uri->params('ueper'), null);
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init();
|
||||
$this->assertSame($this->uri->params(), null);
|
||||
$this->assertSame($this->uri->params('ueper'), null);
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init();
|
||||
$this->assertSame($this->uri->params(), null);
|
||||
$this->assertSame($this->uri->params('ueper'), null);
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init();
|
||||
$this->assertSame($this->uri->params(), null);
|
||||
$this->assertSame($this->uri->params('ueper'), null);
|
||||
$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->assertSame($this->uri->params(), null);
|
||||
$this->assertSame($this->uri->params('ueper'), null);
|
||||
}
|
||||
|
||||
public function testParam()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame($uri->param('ueper'), 'xxx');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init();
|
||||
$this->assertSame($uri->param('ueper'), 'xxx');
|
||||
$this->assertSame($uri->param('test'), 'yyy');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame($this->uri->param('ueper'), 'xxx');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init();
|
||||
$this->assertSame($this->uri->param('ueper'), 'xxx');
|
||||
$this->assertSame($this->uri->param('test'), 'yyy');
|
||||
}
|
||||
|
||||
public function testUrl()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init();
|
||||
$this->assertSame($uri->url(), '/grav/it/ueper');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame($uri->url(), '/grav/it');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init();
|
||||
$this->assertSame($uri->url(), '/grav/it');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init();
|
||||
$this->assertSame($uri->url(), '/grav/it/ueper');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init();
|
||||
$this->assertSame($uri->url(), '/grav/it/ueper');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init();
|
||||
$this->assertSame($uri->url(), '/grav/it/ueper');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init();
|
||||
$this->assertSame($uri->url(), '/grav/it/ueper');
|
||||
$uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init();
|
||||
$this->assertSame($uri->url(), '/a/b/c/d');
|
||||
$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->assertSame($uri->url(), '/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init();
|
||||
$this->assertSame($this->uri->url(), '/grav/it/ueper');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame($this->uri->url(), '/grav/it');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init();
|
||||
$this->assertSame($this->uri->url(), '/grav/it');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init();
|
||||
$this->assertSame($this->uri->url(), '/grav/it/ueper');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init();
|
||||
$this->assertSame($this->uri->url(), '/grav/it/ueper');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init();
|
||||
$this->assertSame($this->uri->url(), '/grav/it/ueper');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init();
|
||||
$this->assertSame($this->uri->url(), '/grav/it/ueper');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init();
|
||||
$this->assertSame($this->uri->url(), '/a/b/c/d');
|
||||
$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->assertSame($this->uri->url(), '/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f');
|
||||
}
|
||||
|
||||
public function testPath()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init();
|
||||
$this->assertSame($uri->path(), '/grav/it/ueper');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame($uri->path(), '/grav/it');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init();
|
||||
$this->assertSame($uri->path(), '/grav/it');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init();
|
||||
$this->assertSame($uri->path(), '/grav/it/ueper');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init();
|
||||
$this->assertSame($uri->path(), '/grav/it/ueper');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init();
|
||||
$this->assertSame($uri->path(), '/grav/it/ueper');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init();
|
||||
$this->assertSame($uri->path(), '/grav/it/ueper');
|
||||
$uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init();
|
||||
$this->assertSame($uri->path(), '/a/b/c/d');
|
||||
$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->assertSame($uri->path(), '/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f');
|
||||
$uri->initializeWithURL('http://localhost/')->init();
|
||||
$this->assertSame($uri->path(), '/');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init();
|
||||
$this->assertSame($this->uri->path(), '/grav/it/ueper');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame($this->uri->path(), '/grav/it');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init();
|
||||
$this->assertSame($this->uri->path(), '/grav/it');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init();
|
||||
$this->assertSame($this->uri->path(), '/grav/it/ueper');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init();
|
||||
$this->assertSame($this->uri->path(), '/grav/it/ueper');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init();
|
||||
$this->assertSame($this->uri->path(), '/grav/it/ueper');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init();
|
||||
$this->assertSame($this->uri->path(), '/grav/it/ueper');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init();
|
||||
$this->assertSame($this->uri->path(), '/a/b/c/d');
|
||||
$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->assertSame($this->uri->path(), '/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f');
|
||||
$this->uri->initializeWithURL('http://localhost/')->init();
|
||||
$this->assertSame($this->uri->path(), '/');
|
||||
}
|
||||
|
||||
public function testExtension()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
$uri->initializeWithURL('http://localhost/a-page')->init();
|
||||
$this->assertSame($uri->extension(), null);
|
||||
$uri->initializeWithURL('http://localhost/a-page')->init();
|
||||
$this->assertSame($uri->extension('x'), 'x');
|
||||
$uri->initializeWithURL('http://localhost/a-page.html')->init();
|
||||
$this->assertSame($uri->extension(), 'html');
|
||||
$uri->initializeWithURL('http://localhost/a-page.xml')->init();
|
||||
$this->assertSame($uri->extension(), 'xml');
|
||||
$uri->initializeWithURL('http://localhost/a-page.foo')->init();
|
||||
$this->assertSame($uri->extension(), 'foo');
|
||||
$this->uri->initializeWithURL('http://localhost/a-page')->init();
|
||||
$this->assertSame($this->uri->extension(), null);
|
||||
$this->uri->initializeWithURL('http://localhost/a-page')->init();
|
||||
$this->assertSame($this->uri->extension('x'), 'x');
|
||||
$this->uri->initializeWithURL('http://localhost/a-page.html')->init();
|
||||
$this->assertSame($this->uri->extension(), 'html');
|
||||
$this->uri->initializeWithURL('http://localhost/a-page.xml')->init();
|
||||
$this->assertSame($this->uri->extension(), 'xml');
|
||||
$this->uri->initializeWithURL('http://localhost/a-page.foo')->init();
|
||||
$this->assertSame($this->uri->extension(), 'foo');
|
||||
}
|
||||
|
||||
public function testHost()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
|
||||
$address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '::1';
|
||||
if ($uri->host() == 'localhost' || $address == '::1' || $address == '127.0.0.1') {
|
||||
if ($this->uri->host() == 'localhost' || $address == '::1' || $address == '127.0.0.1') {
|
||||
$address = 'localhost';
|
||||
}
|
||||
|
||||
$uri->initializeWithURL('http://localhost/a-page')->init();
|
||||
$this->assertSame($uri->host(), $address);
|
||||
$uri->initializeWithURL('http://localhost/')->init();
|
||||
$this->assertSame($uri->host(), $address);
|
||||
$this->uri->initializeWithURL('http://localhost/a-page')->init();
|
||||
$this->assertSame($this->uri->host(), $address);
|
||||
$this->uri->initializeWithURL('http://localhost/')->init();
|
||||
$this->assertSame($this->uri->host(), $address);
|
||||
//Host is set to localhost when running from local
|
||||
$uri->initializeWithURL('http://google.com/')->init();
|
||||
$this->assertSame($uri->host(), $address);
|
||||
$this->uri->initializeWithURL('http://google.com/')->init();
|
||||
$this->assertSame($this->uri->host(), $address);
|
||||
}
|
||||
|
||||
public function testPort()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
$uri->initializeWithURL('http://localhost/a-page')->init();
|
||||
$this->assertSame($uri->port(), '80');
|
||||
$uri->initializeWithURL('http://localhost:8080/a-page')->init();
|
||||
$this->assertSame($uri->port(), 8080);
|
||||
$uri->initializeWithURL('http://localhost:443/a-page')->init();
|
||||
$this->assertSame($uri->port(), 443);
|
||||
$uri->initializeWithURL('https://localhost/a-page')->init();
|
||||
$this->assertSame($uri->port(), '80');
|
||||
$this->uri->initializeWithURL('http://localhost/a-page')->init();
|
||||
$this->assertSame($this->uri->port(), '80');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a-page')->init();
|
||||
$this->assertSame($this->uri->port(), 8080);
|
||||
$this->uri->initializeWithURL('http://localhost:443/a-page')->init();
|
||||
$this->assertSame($this->uri->port(), 443);
|
||||
$this->uri->initializeWithURL('https://localhost/a-page')->init();
|
||||
$this->assertSame($this->uri->port(), '80');
|
||||
}
|
||||
|
||||
public function testEnvironment()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
|
||||
$address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '::1';
|
||||
if ($uri->host() == 'localhost' || $address == '::1' || $address == '127.0.0.1') {
|
||||
if ($this->uri->host() == 'localhost' || $address == '::1' || $address == '127.0.0.1') {
|
||||
$address = 'localhost';
|
||||
}
|
||||
|
||||
$uri->initializeWithURL('http://localhost/a-page')->init();
|
||||
$this->assertSame($uri->environment(), $address);
|
||||
$uri->initializeWithURL('http://localhost:8080/a-page')->init();
|
||||
$this->assertSame($uri->environment(), $address);
|
||||
$uri->initializeWithURL('http://foobar.it:443/a-page')->init();
|
||||
$this->assertSame($uri->environment(), $address);
|
||||
$uri->initializeWithURL('https://google.com/a-page')->init();
|
||||
$this->assertSame($uri->environment(), $address);
|
||||
$this->uri->initializeWithURL('http://localhost/a-page')->init();
|
||||
$this->assertSame($this->uri->environment(), $address);
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a-page')->init();
|
||||
$this->assertSame($this->uri->environment(), $address);
|
||||
$this->uri->initializeWithURL('http://foobar.it:443/a-page')->init();
|
||||
$this->assertSame($this->uri->environment(), $address);
|
||||
$this->uri->initializeWithURL('https://google.com/a-page')->init();
|
||||
$this->assertSame($this->uri->environment(), $address);
|
||||
}
|
||||
|
||||
public function testBasename()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init();
|
||||
$this->assertSame($uri->basename(), 'ueper');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame($uri->basename(), 'it');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init();
|
||||
$this->assertSame($uri->basename(), 'it');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init();
|
||||
$this->assertSame($uri->basename(), 'ueper');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init();
|
||||
$this->assertSame($uri->basename(), 'ueper');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init();
|
||||
$this->assertSame($uri->basename(), 'ueper');
|
||||
$uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init();
|
||||
$this->assertSame($uri->basename(), 'ueper');
|
||||
$uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init();
|
||||
$this->assertSame($uri->basename(), 'd');
|
||||
$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->assertSame($uri->basename(), 'f');
|
||||
$uri->initializeWithURL('http://localhost/')->init();
|
||||
$this->assertSame($uri->basename(), '');
|
||||
$uri->initializeWithURL('http://localhost/test.xml')->init();
|
||||
$this->assertSame($uri->basename(), 'test.xml');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init();
|
||||
$this->assertSame($this->uri->basename(), 'ueper');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame($this->uri->basename(), 'it');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init();
|
||||
$this->assertSame($this->uri->basename(), 'it');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init();
|
||||
$this->assertSame($this->uri->basename(), 'ueper');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init();
|
||||
$this->assertSame($this->uri->basename(), 'ueper');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init();
|
||||
$this->assertSame($this->uri->basename(), 'ueper');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init();
|
||||
$this->assertSame($this->uri->basename(), 'ueper');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init();
|
||||
$this->assertSame($this->uri->basename(), 'd');
|
||||
$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->assertSame($this->uri->basename(), 'f');
|
||||
$this->uri->initializeWithURL('http://localhost/')->init();
|
||||
$this->assertSame($this->uri->basename(), '');
|
||||
$this->uri->initializeWithURL('http://localhost/test.xml')->init();
|
||||
$this->assertSame($this->uri->basename(), 'test.xml');
|
||||
}
|
||||
|
||||
public function testBase()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
|
||||
$uri->initializeWithURL('http://localhost/a-page')->init();
|
||||
$this->assertSame($uri->base(), 'http://localhost');
|
||||
$uri->initializeWithURL('http://localhost:8080/a-page')->init();
|
||||
$this->assertSame($uri->base(), 'http://localhost:8080');
|
||||
$uri->initializeWithURL('http://foobar.it:80/a-page')->init();
|
||||
$this->assertSame($uri->base(), 'http://foobar.it');
|
||||
$uri->initializeWithURL('https://google.com/a-page')->init();
|
||||
$this->assertSame($uri->base(), 'http://google.com');
|
||||
$this->uri->initializeWithURL('http://localhost/a-page')->init();
|
||||
$this->assertSame($this->uri->base(), 'http://localhost');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a-page')->init();
|
||||
$this->assertSame($this->uri->base(), 'http://localhost:8080');
|
||||
$this->uri->initializeWithURL('http://foobar.it:80/a-page')->init();
|
||||
$this->assertSame($this->uri->base(), 'http://foobar.it');
|
||||
$this->uri->initializeWithURL('https://google.com/a-page')->init();
|
||||
$this->assertSame($this->uri->base(), 'http://google.com');
|
||||
}
|
||||
|
||||
public function testRootUrl()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
|
||||
//Without explicitly adding the root path via `initializeWithUrlAndRootPath`,
|
||||
//tests always default to the base empty root path
|
||||
$uri->initializeWithURL('http://localhost/a-page')->init();
|
||||
$this->assertSame($uri->rootUrl(true), 'http://localhost');
|
||||
$uri->initializeWithURL('http://localhost:8080/a-page')->init();
|
||||
$this->assertSame($uri->rootUrl(true), 'http://localhost:8080');
|
||||
$uri->initializeWithURL('http://foobar.it:80/a-page')->init();
|
||||
$this->assertSame($uri->rootUrl(true), 'http://foobar.it');
|
||||
$uri->initializeWithURL('https://google.com/a-page/xxx')->init();
|
||||
$this->assertSame($uri->rootUrl(true), 'http://google.com');
|
||||
$this->uri->initializeWithURL('http://localhost/a-page')->init();
|
||||
$this->assertSame($this->uri->rootUrl(true), 'http://localhost');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a-page')->init();
|
||||
$this->assertSame($this->uri->rootUrl(true), 'http://localhost:8080');
|
||||
$this->uri->initializeWithURL('http://foobar.it:80/a-page')->init();
|
||||
$this->assertSame($this->uri->rootUrl(true), 'http://foobar.it');
|
||||
$this->uri->initializeWithURL('https://google.com/a-page/xxx')->init();
|
||||
$this->assertSame($this->uri->rootUrl(true), 'http://google.com');
|
||||
|
||||
$uri->initializeWithUrlAndRootPath('https://localhost/grav/page-foo', '/grav')->init();
|
||||
$this->assertSame($uri->rootUrl(), '/grav');
|
||||
$this->assertSame($uri->rootUrl(true), 'http://localhost/grav');
|
||||
$this->uri->initializeWithUrlAndRootPath('https://localhost/grav/page-foo', '/grav')->init();
|
||||
$this->assertSame($this->uri->rootUrl(), '/grav');
|
||||
$this->assertSame($this->uri->rootUrl(true), 'http://localhost/grav');
|
||||
}
|
||||
|
||||
public function testCurrentPage()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
|
||||
$uri->initializeWithURL('http://localhost/foo/page:test')->init();
|
||||
$this->assertSame($uri->currentPage(), 'test');
|
||||
$uri->initializeWithURL('http://localhost:8080/a-page')->init();
|
||||
$this->assertSame($uri->currentPage(), 1);
|
||||
$uri->initializeWithURL('http://localhost:8080/a-page/page:2')->init();
|
||||
$this->assertSame($uri->currentPage(), '2');
|
||||
$uri->initializeWithURL('http://localhost:8080/a-page/page:x')->init();
|
||||
$this->assertSame($uri->currentPage(), 'x');
|
||||
$uri->initializeWithURL('http://localhost:8080/a-page/page:')->init();
|
||||
$this->assertSame($uri->currentPage(), '');
|
||||
$this->uri->initializeWithURL('http://localhost/foo/page:test')->init();
|
||||
$this->assertSame($this->uri->currentPage(), 'test');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a-page')->init();
|
||||
$this->assertSame($this->uri->currentPage(), 1);
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a-page/page:2')->init();
|
||||
$this->assertSame($this->uri->currentPage(), '2');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a-page/page:x')->init();
|
||||
$this->assertSame($this->uri->currentPage(), 'x');
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a-page/page:')->init();
|
||||
$this->assertSame($this->uri->currentPage(), '');
|
||||
}
|
||||
|
||||
public function testReferrer()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
|
||||
$uri->initializeWithURL('http://localhost/foo/page:test')->init();
|
||||
$this->assertSame($uri->referrer(), '/foo');
|
||||
$uri->initializeWithURL('http://localhost/foo/bar/page:test')->init();
|
||||
$this->assertSame($uri->referrer(), '/foo/bar');
|
||||
$this->uri->initializeWithURL('http://localhost/foo/page:test')->init();
|
||||
$this->assertSame($this->uri->referrer(), '/foo');
|
||||
$this->uri->initializeWithURL('http://localhost/foo/bar/page:test')->init();
|
||||
$this->assertSame($this->uri->referrer(), '/foo/bar');
|
||||
}
|
||||
|
||||
public function testIp()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
|
||||
$uri->initializeWithURL('http://localhost/foo/page:test')->init();
|
||||
$this->assertSame($uri->ip(), 'UNKNOWN');
|
||||
$this->uri->initializeWithURL('http://localhost/foo/page:test')->init();
|
||||
$this->assertSame($this->uri->ip(), 'UNKNOWN');
|
||||
}
|
||||
|
||||
public function testIsExternal()
|
||||
{
|
||||
$uri = $this->getURI();
|
||||
|
||||
$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'));
|
||||
$this->uri->initializeWithURL('http://localhost/')->init();
|
||||
$this->assertFalse($this->uri->isExternal('/test'));
|
||||
$this->assertFalse($this->uri->isExternal('/foo/bar'));
|
||||
$this->assertTrue($this->uri->isExternal('http://localhost/test'));
|
||||
$this->assertTrue($this->uri->isExternal('http://google.it/test'));
|
||||
}
|
||||
|
||||
public function testBuildUrl()
|
||||
{
|
||||
$parsed_url = [
|
||||
'scheme' => 'http',
|
||||
'host' => 'localhost',
|
||||
'port' => '8080',
|
||||
'host' => 'localhost',
|
||||
'port' => '8080',
|
||||
];
|
||||
|
||||
$this->assertSame(Uri::buildUrl($parsed_url), 'http://localhost:8080');
|
||||
|
||||
$parsed_url = [
|
||||
'scheme' => 'http',
|
||||
'host' => 'localhost',
|
||||
'port' => '8080',
|
||||
'user' => 'foo',
|
||||
'pass' => 'bar',
|
||||
'path' => '/test',
|
||||
'query' => 'x=2',
|
||||
'scheme' => 'http',
|
||||
'host' => 'localhost',
|
||||
'port' => '8080',
|
||||
'user' => 'foo',
|
||||
'pass' => 'bar',
|
||||
'path' => '/test',
|
||||
'query' => 'x=2',
|
||||
'fragment' => 'xxx',
|
||||
];
|
||||
|
||||
@@ -447,11 +409,9 @@ class UriTest extends \Codeception\TestCase\Test
|
||||
$this->assertStringStartsWith($url, Uri::addNonce($url, 'test-action'));
|
||||
$this->assertStringStartsWith($url . '/nonce:', Uri::addNonce($url, 'test-action'));
|
||||
|
||||
$uri = $this->getURI();
|
||||
|
||||
$uri->initializeWithURL(Uri::addNonce($url, 'test-action'))->init();
|
||||
$this->assertTrue(is_string($uri->param('nonce')));
|
||||
$this->assertSame($uri->param('nonce'), Utils::getNonce('test-action'));
|
||||
$this->uri->initializeWithURL(Uri::addNonce($url, 'test-action'))->init();
|
||||
$this->assertTrue(is_string($this->uri->param('nonce')));
|
||||
$this->assertSame($this->uri->param('nonce'), Utils::getNonce('test-action'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,40 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Codeception\Util\Fixtures;
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\Utils;
|
||||
|
||||
/**
|
||||
* Class UtilsTest
|
||||
*/
|
||||
class UtilsTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
/**
|
||||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
/** @var Grav $grav */
|
||||
protected $grav;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
$this->grav = Fixtures::get('grav');
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
{
|
||||
}
|
||||
|
||||
public function grav()
|
||||
{
|
||||
$grav = Fixtures::get('grav');
|
||||
return $grav;
|
||||
}
|
||||
|
||||
public function testStartsWith()
|
||||
{
|
||||
$this->assertTrue(Utils::startsWith('english', 'en'));
|
||||
$this->assertTrue(Utils::startsWith('English', 'En'));
|
||||
$this->assertTrue(Utils::startsWith('ENGLISH', 'EN'));
|
||||
$this->assertTrue(Utils::startsWith('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', 'EN'));
|
||||
$this->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('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', 'e'));
|
||||
$this->assertFalse(Utils::startsWith('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'e'));
|
||||
}
|
||||
|
||||
public function testEndsWith()
|
||||
@@ -42,12 +41,14 @@ class UtilsTest extends \Codeception\TestCase\Test
|
||||
$this->assertTrue(Utils::endsWith('english', 'sh'));
|
||||
$this->assertTrue(Utils::endsWith('EngliSh', 'Sh'));
|
||||
$this->assertTrue(Utils::endsWith('ENGLISH', 'SH'));
|
||||
$this->assertTrue(Utils::endsWith('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', 'ENGLISH'));
|
||||
$this->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('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', 'DEUSTCH'));
|
||||
$this->assertFalse(Utils::endsWith('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'DEUSTCH'));
|
||||
}
|
||||
|
||||
public function testContains()
|
||||
@@ -55,11 +56,14 @@ class UtilsTest extends \Codeception\TestCase\Test
|
||||
$this->assertTrue(Utils::contains('english', 'nglis'));
|
||||
$this->assertTrue(Utils::contains('EngliSh', 'gliSh'));
|
||||
$this->assertTrue(Utils::contains('ENGLISH', 'ENGLI'));
|
||||
$this->assertTrue(Utils::contains('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', 'ENGLISH'));
|
||||
$this->assertTrue(Utils::contains('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'ENGLISH'));
|
||||
|
||||
$this->assertFalse(Utils::contains('EngliSh', 'GLI')); $this->assertFalse(Utils::contains('EngliSh', 'English'));
|
||||
$this->assertFalse(Utils::contains('EngliSh', 'GLI'));
|
||||
$this->assertFalse(Utils::contains('EngliSh', 'English'));
|
||||
$this->assertFalse(Utils::contains('ENGLISH', 'SCH'));
|
||||
$this->assertFalse(Utils::contains('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', 'DEUSTCH'));
|
||||
$this->assertFalse(Utils::contains('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'DEUSTCH'));
|
||||
}
|
||||
|
||||
public function testSubstrToString()
|
||||
@@ -84,12 +88,11 @@ class UtilsTest extends \Codeception\TestCase\Test
|
||||
|
||||
public function testDateFormats()
|
||||
{
|
||||
$grav = $this->grav();
|
||||
$dateFormats = Utils::dateFormats();
|
||||
$this->assertTrue(is_array($dateFormats));
|
||||
$this->assertContainsOnly('string', $dateFormats);
|
||||
|
||||
$default_format = $grav['config']->get('system.pages.dateformat.default');
|
||||
$default_format = $this->grav['config']->get('system.pages.dateformat.default');
|
||||
|
||||
if ($default_format !== null) {
|
||||
$this->assertTrue(isset($dateFormats[$default_format]));
|
||||
@@ -177,13 +180,13 @@ class UtilsTest extends \Codeception\TestCase\Test
|
||||
public function testArrayFilterRecursive()
|
||||
{
|
||||
$array = [
|
||||
'test' => '',
|
||||
'test' => '',
|
||||
'test2' => 'test2'
|
||||
];
|
||||
|
||||
$array = Utils::arrayFilterRecursive($array, function($k, $v) {
|
||||
return !(is_null($v) || $v === '');
|
||||
});
|
||||
$array = Utils::arrayFilterRecursive($array, function ($k, $v) {
|
||||
return !(is_null($v) || $v === '');
|
||||
});
|
||||
|
||||
$this->assertContainsOnly('string', $array);
|
||||
$this->assertFalse(isset($array['test']));
|
||||
@@ -193,7 +196,7 @@ class UtilsTest extends \Codeception\TestCase\Test
|
||||
|
||||
public function testPathPrefixedByLangCode()
|
||||
{
|
||||
$languagesEnabled = $this->grav()['config']->get('system.languages.supported', []);
|
||||
$languagesEnabled = $this->grav['config']->get('system.languages.supported', []);
|
||||
$arrayOfLanguages = ['en', 'de', 'it', 'es', 'dk', 'el'];
|
||||
$languagesNotEnabled = array_diff($arrayOfLanguages, $languagesEnabled);
|
||||
$oneLanguageNotEnabled = reset($languagesNotEnabled);
|
||||
|
||||
Reference in New Issue
Block a user