Compare commits
No commits in common. "master" and "v2.4.0" have entirely different histories.
1
.gitignore
vendored
1
.gitignore
vendored
@ -30,4 +30,3 @@ build/humbuglog.txt
|
|||||||
phpdoc/
|
phpdoc/
|
||||||
tests/test_data/json_write.json
|
tests/test_data/json_write.json
|
||||||
tests/test_data/sessions/
|
tests/test_data/sessions/
|
||||||
.phpunit.result.cache
|
|
31
.gitlab-ci.yml
Normal file
31
.gitlab-ci.yml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
test:7:
|
||||||
|
before_script:
|
||||||
|
- sh build/docker_install.sh > /dev/null
|
||||||
|
- apk add --no-cache php7-phpdbg
|
||||||
|
- curl -sS https://getcomposer.org/installer | php
|
||||||
|
- php composer.phar install --ignore-platform-reqs
|
||||||
|
image: php:7-alpine
|
||||||
|
script:
|
||||||
|
- phpdbg -qrr -- vendor/bin/phpunit -c build --coverage-text --colors=never
|
||||||
|
|
||||||
|
test:7.1:
|
||||||
|
stage: test
|
||||||
|
before_script:
|
||||||
|
- sh build/docker_install.sh > /dev/null
|
||||||
|
- apk add --no-cache php7-phpdbg
|
||||||
|
- curl -sS https://getcomposer.org/installer | php
|
||||||
|
- php composer.phar install --ignore-platform-reqs
|
||||||
|
image: php:7.1-alpine
|
||||||
|
script:
|
||||||
|
- phpdbg -qrr -- ./vendor/bin/phpunit -c build --coverage-text --colors=never
|
||||||
|
|
||||||
|
test:7.2:
|
||||||
|
stage: test
|
||||||
|
before_script:
|
||||||
|
- sh build/docker_install.sh > /dev/null
|
||||||
|
- apk add --no-cache php7-phpdbg
|
||||||
|
- curl -sS https://getcomposer.org/installer | php
|
||||||
|
- php composer.phar install --ignore-platform-reqs
|
||||||
|
image: php:7.2-alpine
|
||||||
|
script:
|
||||||
|
- phpdbg -qrr -- ./vendor/bin/phpunit -c build --coverage-text --colors=never
|
@ -4,9 +4,8 @@ install:
|
|||||||
- composer install
|
- composer install
|
||||||
|
|
||||||
php:
|
php:
|
||||||
|
- 7.1
|
||||||
- 7.2
|
- 7.2
|
||||||
- 7.3
|
|
||||||
- 7.4
|
|
||||||
- nightly
|
- nightly
|
||||||
|
|
||||||
script:
|
script:
|
||||||
@ -14,7 +13,7 @@ script:
|
|||||||
- vendor/bin/phpunit -c build
|
- vendor/bin/phpunit -c build
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- redis-server
|
- redis
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
|
50
Jenkinsfile
vendored
50
Jenkinsfile
vendored
@ -1,50 +0,0 @@
|
|||||||
pipeline {
|
|
||||||
agent none
|
|
||||||
stages {
|
|
||||||
stage('PHP 7.2') {
|
|
||||||
agent {
|
|
||||||
docker {
|
|
||||||
image 'php:7.2-alpine'
|
|
||||||
args '-u root --privileged'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
sh 'apk add --no-cache php7-phpdbg'
|
|
||||||
sh 'curl -sS https://getcomposer.org/installer | php'
|
|
||||||
sh 'rm -f composer.lock'
|
|
||||||
sh 'php composer.phar install --ignore-platform-reqs'
|
|
||||||
sh 'php composer.phar run-script coverage -- --coverage-text --colors=never'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('PHP 7.3') {
|
|
||||||
agent {
|
|
||||||
docker {
|
|
||||||
image 'php:7.3-alpine'
|
|
||||||
args '-u root --privileged'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
sh 'apk add --no-cache php7-phpdbg'
|
|
||||||
sh 'curl -sS https://getcomposer.org/installer | php'
|
|
||||||
sh 'rm -f composer.lock'
|
|
||||||
sh 'php composer.phar install --ignore-platform-reqs'
|
|
||||||
sh 'php composer.phar run-script coverage -- --coverage-text --colors=never'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('PHP 7.4') {
|
|
||||||
agent {
|
|
||||||
docker {
|
|
||||||
image 'php:7.4-alpine'
|
|
||||||
args '-u root --privileged'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
sh 'apk add --no-cache php7-phpdbg'
|
|
||||||
sh 'curl -sS https://getcomposer.org/installer | php'
|
|
||||||
sh 'rm -f composer.lock'
|
|
||||||
sh 'php composer.phar install --ignore-platform-reqs'
|
|
||||||
sh 'php composer.phar run-script coverage -- --coverage-text --colors=never'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,7 @@
|
|||||||
# Ion
|
# Ion
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/timw4mail/ion.svg?branch=master)](https://travis-ci.org/timw4mail/ion)
|
[![build status](https://git.timshomepage.net/aviat/ion/badges/master/build.svg)](https://git.timshomepage.net/aviat/ion/commits/master)
|
||||||
[![Build Status](https://jenkins.timshomepage.net/buildStatus/icon?job=Gitea%20-%20aviat/ion/master)](https://jenkins.timshomepage.net/job/Gitea%20-%20aviat/ion/master)
|
[![coverage report](https://git.timshomepage.net/aviat/ion/badges/master/coverage.svg)](https://git.timshomepage.net/aviat/ion/commits/master)
|
||||||
|
|
||||||
|
|
||||||
Ion is a set of helpful PHP libraries for general web development
|
Ion is a set of helpful PHP libraries for general web development
|
@ -93,12 +93,12 @@ class InlineCommentSniff implements Sniff
|
|||||||
private function _checkCommentStyle(File $phpcsFile, $stackPtr)
|
private function _checkCommentStyle(File $phpcsFile, $stackPtr)
|
||||||
{
|
{
|
||||||
$tokens = $phpcsFile->getTokens();
|
$tokens = $phpcsFile->getTokens();
|
||||||
if ($tokens[$stackPtr]['content'][0] === '#') {
|
if ($tokens[$stackPtr]['content']{0} === '#') {
|
||||||
$error = 'Perl-style comments are not allowed; use "// Comment" or DocBlock comments instead';
|
$error = 'Perl-style comments are not allowed; use "// Comment" or DocBlock comments instead';
|
||||||
$phpcsFile->addError($error, $stackPtr, 'WrongStyle');
|
$phpcsFile->addError($error, $stackPtr, 'WrongStyle');
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (substr($tokens[$stackPtr]['content'], 0, 2) === '/*'
|
} else if (substr($tokens[$stackPtr]['content'], 0, 2) === '/*'
|
||||||
|| $tokens[$stackPtr]['content'][0] === '*'
|
|| $tokens[$stackPtr]['content']{0} === '*'
|
||||||
) {
|
) {
|
||||||
$error = 'Multi lines comments are not allowed; use "// Comment" DocBlock comments instead';
|
$error = 'Multi lines comments are not allowed; use "// Comment" DocBlock comments instead';
|
||||||
$phpcsFile->addError($error, $stackPtr, 'WrongStyle');
|
$phpcsFile->addError($error, $stackPtr, 'WrongStyle');
|
||||||
|
12
build/docker_install.sh
Normal file
12
build/docker_install.sh
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# We need to install dependencies only for Docker
|
||||||
|
[[ ! -e /.dockerenv ]] && [[ ! -e /.dockerinit ]] && exit 0
|
||||||
|
|
||||||
|
set -xe
|
||||||
|
|
||||||
|
# Install git (the php image doesn't have it) which is required by composer
|
||||||
|
echo -e 'http://dl-cdn.alpinelinux.org/alpine/edge/main\nhttp://dl-cdn.alpinelinux.org/alpine/edge/community\nhttp://dl-cdn.alpinelinux.org/alpine/edge/testing' > /etc/apk/repositories
|
||||||
|
apk add --no-cache \
|
||||||
|
curl \
|
||||||
|
git
|
@ -3,13 +3,13 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<!-- <log type="coverage-clover" target="logs/clover.xml"/>
|
<!-- <log type="coverage-clover" target="logs/clover.xml"/>
|
||||||
<log type="coverage-crap4j" target="logs/crap4j.xml"/> -->
|
<log type="coverage-crap4j" target="logs/crap4j.xml"/> -->
|
||||||
<log type="coverage-xml" target="logs/coverage" />
|
<log type="coverage-xml" target="logs/coverage" />
|
||||||
<log type="junit" target="logs/junit.xml" />
|
<log type="junit" target="logs/junit.xml" logIncompleteSkipped="false"/>
|
||||||
</logging>
|
</logging>
|
||||||
<php>
|
<php>
|
||||||
<server name="HTTP_USER_AGENT" value="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393" />
|
<server name="HTTP_USER_AGENT" value="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393" />
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "aviat/ion",
|
"name": "aviat/ion",
|
||||||
"description": "Basic PHP Framework",
|
"description": "Basic PHP Framework",
|
||||||
"license": "MIT",
|
"license":"MIT",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"files": [
|
"files": [
|
||||||
"src/functions.php"
|
"src/functions.php"
|
||||||
@ -17,30 +17,28 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"aura/html": "^2.5.0",
|
"aviat/query": "^2.5",
|
||||||
"aviat/query": "^2.5.1",
|
"aura/html": "2.*",
|
||||||
"danielstjules/stringy": "^3.1.0",
|
"container-interop/container-interop": "1.*",
|
||||||
"ext-dom": "*",
|
"danielstjules/stringy": "^3.0.0",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"php": "^7.2",
|
|
||||||
"psr/http-message": "~1.0",
|
"psr/http-message": "~1.0",
|
||||||
"psr/log": "~1.0",
|
"psr/log": "~1.0",
|
||||||
"zendframework/zend-diactoros": "^2.0.0",
|
"zendframework/zend-diactoros": "^2.0.0"
|
||||||
"zendframework/zend-httphandlerrunner": "^1.0"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"aura/session": "^2.1.0",
|
"aura/session": "^2.1.0",
|
||||||
"consolidation/robo": "^2.0.0",
|
"consolidation/robo": "^1.1.0",
|
||||||
"monolog/monolog": "^2.0.1",
|
"monolog/monolog": "1.*",
|
||||||
"pdepend/pdepend": "^2.2",
|
"pdepend/pdepend": "^2.2",
|
||||||
"phploc/phploc": "^5.0",
|
"phploc/phploc": "^4.0",
|
||||||
"phpmd/phpmd": "^2.4",
|
"phpmd/phpmd": "^2.4",
|
||||||
"phpstan/phpstan": "^0.12.0",
|
"phpstan/phpstan": "^0.9.1",
|
||||||
"phpunit/phpunit": "^8.4.3",
|
"phpunit/phpunit": "^6.5.13",
|
||||||
"roave/security-advisories": "dev-master",
|
"robmorgan/phinx": "^0.10.6",
|
||||||
"sebastian/phpcpd": "^4.1.0",
|
"sebastian/phpcpd": "^3.0.1",
|
||||||
"squizlabs/php_codesniffer": "^3.0.0",
|
"squizlabs/php_codesniffer": "^3.0.0",
|
||||||
"theseer/phpdox": "^0.12.0"
|
"theseer/phpdox": "^0.11.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"coverage": "phpdbg -qrr -- vendor/bin/phpunit -c build",
|
"coverage": "phpdbg -qrr -- vendor/bin/phpunit -c build",
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion;
|
namespace Aviat\Ion;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion;
|
namespace Aviat\Ion;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion;
|
namespace Aviat\Ion;
|
||||||
@ -44,7 +44,7 @@ interface ConfigInterface {
|
|||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @return ConfigInterface
|
* @return ConfigInterface
|
||||||
*/
|
*/
|
||||||
public function set($key, $value): self;
|
public function set($key, $value): ConfigInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a config value
|
* Remove a config value
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Di;
|
namespace Aviat\Ion\Di;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Di;
|
namespace Aviat\Ion\Di;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Di;
|
namespace Aviat\Ion\Di;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Di;
|
namespace Aviat\Ion\Di;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Di\Exception;
|
namespace Aviat\Ion\Di\Exception;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Di\Exception;
|
namespace Aviat\Ion\Di\Exception;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion;
|
namespace Aviat\Ion;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Exception;
|
namespace Aviat\Ion\Exception;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Exception;
|
namespace Aviat\Ion\Exception;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion;
|
namespace Aviat\Ion;
|
||||||
@ -35,7 +35,7 @@ class Friend {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class of the object
|
* Reflection class of the object
|
||||||
* @var ReflectionClass
|
* @var \ReflectionClass
|
||||||
*/
|
*/
|
||||||
private $_reflect_;
|
private $_reflect_;
|
||||||
|
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion;
|
namespace Aviat\Ion;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion;
|
namespace Aviat\Ion;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion;
|
namespace Aviat\Ion;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Model;
|
namespace Aviat\Ion\Model;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion;
|
namespace Aviat\Ion;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Transformer;
|
namespace Aviat\Ion\Transformer;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Transformer;
|
namespace Aviat\Ion\Transformer;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Type;
|
namespace Aviat\Ion\Type;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Type;
|
namespace Aviat\Ion\Type;
|
||||||
@ -33,8 +33,8 @@ class StringType extends Stringy {
|
|||||||
*/
|
*/
|
||||||
public function fuzzyCaseMatch(string $strToMatch): bool
|
public function fuzzyCaseMatch(string $strToMatch): bool
|
||||||
{
|
{
|
||||||
$firstStr = (string)self::create($this->str)->dasherize();
|
$firstStr = self::create($this->str)->dasherize()->__toString();
|
||||||
$secondStr = (string)self::create($strToMatch)->dasherize();
|
$secondStr = self::create($strToMatch)->dasherize()->__toString();
|
||||||
|
|
||||||
return $firstStr === $secondStr;
|
return $firstStr === $secondStr;
|
||||||
}
|
}
|
||||||
|
12
src/View.php
12
src/View.php
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion;
|
namespace Aviat\Ion;
|
||||||
@ -50,8 +50,6 @@ abstract class View
|
|||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param ContainerInterface $container
|
* @param ContainerInterface $container
|
||||||
* @throws Di\Exception\ContainerException
|
|
||||||
* @throws Di\Exception\NotFoundException
|
|
||||||
*/
|
*/
|
||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
@ -137,7 +135,7 @@ abstract class View
|
|||||||
*/
|
*/
|
||||||
public function getOutput(): string
|
public function getOutput(): string
|
||||||
{
|
{
|
||||||
return (string)$this->response->getBody();
|
return $this->response->getBody()->__toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// End of View.php
|
// End of View.php
|
@ -4,22 +4,19 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\View;
|
namespace Aviat\Ion\View;
|
||||||
|
|
||||||
use Aura\Html\HelperLocator;
|
|
||||||
use Aviat\Ion\Di\ContainerInterface;
|
use Aviat\Ion\Di\ContainerInterface;
|
||||||
use Aviat\Ion\Di\Exception\ContainerException;
|
|
||||||
use Aviat\Ion\Di\Exception\NotFoundException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View class for outputting HTML
|
* View class for outputting HTML
|
||||||
@ -29,7 +26,7 @@ class HtmlView extends HttpView {
|
|||||||
/**
|
/**
|
||||||
* HTML generator/escaper helper
|
* HTML generator/escaper helper
|
||||||
*
|
*
|
||||||
* @var HelperLocator
|
* @var \Aura\Html\HelperLocator
|
||||||
*/
|
*/
|
||||||
protected $helper;
|
protected $helper;
|
||||||
|
|
||||||
@ -44,8 +41,6 @@ class HtmlView extends HttpView {
|
|||||||
* Create the Html View
|
* Create the Html View
|
||||||
*
|
*
|
||||||
* @param ContainerInterface $container
|
* @param ContainerInterface $container
|
||||||
* @throws ContainerException
|
|
||||||
* @throws NotFoundException
|
|
||||||
*/
|
*/
|
||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
@ -69,7 +64,8 @@ class HtmlView extends HttpView {
|
|||||||
ob_start();
|
ob_start();
|
||||||
extract($data, \EXTR_OVERWRITE);
|
extract($data, \EXTR_OVERWRITE);
|
||||||
include_once $path;
|
include_once $path;
|
||||||
$buffer = ob_get_clean();
|
$buffer = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
|
||||||
|
|
||||||
// Very basic html minify, that won't affect content between html tags
|
// Very basic html minify, that won't affect content between html tags
|
||||||
|
@ -4,20 +4,19 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\View;
|
namespace Aviat\Ion\View;
|
||||||
|
|
||||||
use Zend\Diactoros\Response;
|
use Zend\Diactoros\Response\SapiEmitter;
|
||||||
use Zend\HttpHandlerRunner\Emitter\SapiEmitter;
|
|
||||||
|
|
||||||
use Aviat\Ion\Exception\DoubleRenderException;
|
use Aviat\Ion\Exception\DoubleRenderException;
|
||||||
use Aviat\Ion\View as BaseView;
|
use Aviat\Ion\View as BaseView;
|
||||||
@ -39,13 +38,24 @@ class HttpView extends BaseView {
|
|||||||
*
|
*
|
||||||
* @param string $url
|
* @param string $url
|
||||||
* @param int $code
|
* @param int $code
|
||||||
* @param array $headers
|
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function redirect(string $url, int $code = 302, array $headers = []): void
|
public function redirect(string $url, int $code): void
|
||||||
{
|
{
|
||||||
$this->response = new Response\RedirectResponse($url, $code, $headers);
|
ob_start();
|
||||||
|
$this->setStatusCode($code);
|
||||||
|
$message = $this->response->getReasonPhrase();
|
||||||
|
$this->response = $this->response->withHeader('Location', $url);
|
||||||
|
|
||||||
|
if (PHP_SAPI !== 'cli')
|
||||||
|
{
|
||||||
|
header("HTTP/1.1 ${code} ${message}");
|
||||||
|
header("Location: {$url}");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->hasRendered = TRUE;
|
||||||
|
ob_end_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,20 +4,19 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\View;
|
namespace Aviat\Ion\View;
|
||||||
|
|
||||||
use Aviat\Ion\Json;
|
use Aviat\Ion\Json;
|
||||||
use Aviat\Ion\JsonException;
|
|
||||||
use Aviat\Ion\ViewInterface;
|
use Aviat\Ion\ViewInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,7 +37,7 @@ class JsonView extends HttpView {
|
|||||||
* @param mixed $string
|
* @param mixed $string
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
* @throws JsonException
|
* @throws \Aviat\Ion\JsonException
|
||||||
* @return ViewInterface
|
* @return ViewInterface
|
||||||
*/
|
*/
|
||||||
public function setOutput($string): ViewInterface
|
public function setOutput($string): ViewInterface
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion;
|
namespace Aviat\Ion;
|
||||||
|
279
src/XML.php
279
src/XML.php
@ -1,279 +0,0 @@
|
|||||||
<?php declare(strict_types=1);
|
|
||||||
/**
|
|
||||||
* Ion
|
|
||||||
*
|
|
||||||
* Building blocks for web development
|
|
||||||
*
|
|
||||||
* PHP version 7.2
|
|
||||||
*
|
|
||||||
* @package Ion
|
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
||||||
* @version 3.0.0
|
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Aviat\Ion;
|
|
||||||
|
|
||||||
use DOMDocument, DOMNode, DOMNodeList, InvalidArgumentException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XML <=> PHP Array codec
|
|
||||||
*/
|
|
||||||
final class XML {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XML representation of the data
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $xml;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHP array version of the data
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private $data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XML constructor
|
|
||||||
*
|
|
||||||
* @param string $xml
|
|
||||||
* @param array $data
|
|
||||||
*/
|
|
||||||
public function __construct(string $xml = '', array $data = [])
|
|
||||||
{
|
|
||||||
$this->setXML($xml)->setData($data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialize the data to an xml string
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function __toString(): string
|
|
||||||
{
|
|
||||||
return static::toXML($this->getData());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the data parsed from the XML
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getData(): array
|
|
||||||
{
|
|
||||||
return $this->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the data to create xml from
|
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @return self
|
|
||||||
*/
|
|
||||||
public function setData(array $data): self
|
|
||||||
{
|
|
||||||
$this->data = $data;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the xml created from the data
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getXML(): string
|
|
||||||
{
|
|
||||||
return $this->xml;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the xml to parse the data from
|
|
||||||
*
|
|
||||||
* @param string $xml
|
|
||||||
* @return self
|
|
||||||
*/
|
|
||||||
public function setXML(string $xml): self
|
|
||||||
{
|
|
||||||
$this->xml = $xml;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse an xml document string to a php array
|
|
||||||
*
|
|
||||||
* @param string $xml
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public static function toArray(string $xml): array
|
|
||||||
{
|
|
||||||
$data = [];
|
|
||||||
|
|
||||||
$xml = static::stripXMLWhitespace($xml);
|
|
||||||
|
|
||||||
$dom = new DOMDocument();
|
|
||||||
$hasLoaded = @$dom->loadXML($xml);
|
|
||||||
|
|
||||||
if ( ! $hasLoaded)
|
|
||||||
{
|
|
||||||
throw new InvalidArgumentException('Failed to load XML');
|
|
||||||
}
|
|
||||||
|
|
||||||
$root = $dom->documentElement;
|
|
||||||
|
|
||||||
$data[$root->tagName] = [];
|
|
||||||
|
|
||||||
if ($root->hasChildNodes())
|
|
||||||
{
|
|
||||||
static::childNodesToArray($data[$root->tagName], $root->childNodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Transform the array into XML
|
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function toXML(array $data): string
|
|
||||||
{
|
|
||||||
$dom = new DOMDocument();
|
|
||||||
$dom->encoding = 'UTF-8';
|
|
||||||
|
|
||||||
static::arrayPropertiesToXmlNodes($dom, $dom, $data);
|
|
||||||
|
|
||||||
return $dom->saveXML();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse the xml document string to a php array
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function parse(): array
|
|
||||||
{
|
|
||||||
$xml = $this->getXML();
|
|
||||||
$data = static::toArray($xml);
|
|
||||||
return $this->setData($data)->getData();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Transform the array into XML
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function createXML(): string
|
|
||||||
{
|
|
||||||
return static::toXML($this->getData());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Strip whitespace from raw xml to remove irrelevant text nodes
|
|
||||||
*
|
|
||||||
* @param string $xml
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private static function stripXMLWhitespace(string $xml): string
|
|
||||||
{
|
|
||||||
// Get rid of unimportant text nodes by removing
|
|
||||||
// whitespace characters from between xml tags,
|
|
||||||
// except for the xml declaration tag, Which looks
|
|
||||||
// something like:
|
|
||||||
/* <?xml version="1.0" encoding="UTF-8"?> */
|
|
||||||
return preg_replace('/([^?])>\s+</', '$1><', $xml);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recursively create array structure based on xml structure
|
|
||||||
*
|
|
||||||
* @param array $root A reference to the current array location
|
|
||||||
* @param DOMNodeList $nodeList The current NodeList object
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private static function childNodesToArray(array &$root, DOMNodelist $nodeList): void
|
|
||||||
{
|
|
||||||
$length = $nodeList->length;
|
|
||||||
for ($i = 0; $i < $length; $i++)
|
|
||||||
{
|
|
||||||
$el = $nodeList->item($i);
|
|
||||||
$current =& $root[$el->nodeName];
|
|
||||||
|
|
||||||
// It's a top level element!
|
|
||||||
if (( ! $el->hasChildNodes()) || ($el->childNodes->item(0) instanceof \DomText))
|
|
||||||
{
|
|
||||||
$current = $el->textContent;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// An empty value at the current root
|
|
||||||
if ($current === NULL)
|
|
||||||
{
|
|
||||||
$current = [];
|
|
||||||
static::childNodesToArray($current, $el->childNodes);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$keys = array_keys($current);
|
|
||||||
|
|
||||||
// Wrap the array in a containing array
|
|
||||||
// if there are only string keys
|
|
||||||
if ( ! is_numeric($keys[0]))
|
|
||||||
{
|
|
||||||
// But if there is only one key, don't wrap it in
|
|
||||||
// an array, just recurse to parse the child nodes
|
|
||||||
if (count($current) === 1)
|
|
||||||
{
|
|
||||||
static::childNodesToArray($current, $el->childNodes);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$current = [$current];
|
|
||||||
}
|
|
||||||
|
|
||||||
$current[] = [];
|
|
||||||
$index = count($current) - 1;
|
|
||||||
|
|
||||||
static::childNodesToArray($current[$index], $el->childNodes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recursively create xml nodes from array properties
|
|
||||||
*
|
|
||||||
* @param DOMDocument $dom The current DOM object
|
|
||||||
* @param DOMNode $parent The parent element to append children to
|
|
||||||
* @param array $data The data for the current node
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private static function arrayPropertiesToXmlNodes(DOMDocument $dom, DOMNode $parent, array $data): void
|
|
||||||
{
|
|
||||||
foreach ($data as $key => $props)
|
|
||||||
{
|
|
||||||
// 'Flatten' the array as you create the xml
|
|
||||||
if (is_numeric($key))
|
|
||||||
{
|
|
||||||
foreach ($props as $k => $p)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$node = $dom->createElement($key);
|
|
||||||
|
|
||||||
if (\is_array($props))
|
|
||||||
{
|
|
||||||
static::arrayPropertiesToXmlNodes($dom, $node, $props);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
$tNode = $dom->createTextNode((string)$props);
|
|
||||||
$node->appendChild($tNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
$parent->appendChild($node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion;
|
namespace Aviat\Ion;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests;
|
namespace Aviat\Ion\Tests;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests;
|
namespace Aviat\Ion\Tests;
|
||||||
@ -20,9 +20,7 @@ use Aviat\Ion\Config;
|
|||||||
|
|
||||||
class ConfigTest extends Ion_TestCase {
|
class ConfigTest extends Ion_TestCase {
|
||||||
|
|
||||||
protected $config;
|
public function setUp()
|
||||||
|
|
||||||
public function setUp(): void
|
|
||||||
{
|
{
|
||||||
$this->config = new Config([
|
$this->config = new Config([
|
||||||
'foo' => 'bar',
|
'foo' => 'bar',
|
||||||
@ -36,7 +34,7 @@ class ConfigTest extends Ion_TestCase {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConfigHas(): void
|
public function testConfigHas()
|
||||||
{
|
{
|
||||||
$this->assertTrue($this->config->has('foo'));
|
$this->assertTrue($this->config->has('foo'));
|
||||||
$this->assertTrue($this->config->has(['a', 'b', 'c']));
|
$this->assertTrue($this->config->has(['a', 'b', 'c']));
|
||||||
@ -45,7 +43,7 @@ class ConfigTest extends Ion_TestCase {
|
|||||||
$this->assertFalse($this->config->has(['c', 'b', 'a']));
|
$this->assertFalse($this->config->has(['c', 'b', 'a']));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConfigGet(): void
|
public function testConfigGet()
|
||||||
{
|
{
|
||||||
$this->assertEquals('bar', $this->config->get('foo'));
|
$this->assertEquals('bar', $this->config->get('foo'));
|
||||||
$this->assertEquals('baz', $this->config->get('bar'));
|
$this->assertEquals('baz', $this->config->get('bar'));
|
||||||
@ -53,26 +51,26 @@ class ConfigTest extends Ion_TestCase {
|
|||||||
$this->assertNull($this->config->get(['apple', 'sauce', 'is']));
|
$this->assertNull($this->config->get(['apple', 'sauce', 'is']));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConfigSet(): void
|
public function testConfigSet()
|
||||||
{
|
{
|
||||||
$ret = $this->config->set('foo', 'foobar');
|
$ret = $this->config->set('foo', 'foobar');
|
||||||
$this->assertInstanceOf(Config::class, $ret);
|
$this->assertInstanceOf('Aviat\Ion\Config', $ret);
|
||||||
$this->assertEquals('foobar', $this->config->get('foo'));
|
$this->assertEquals('foobar', $this->config->get('foo'));
|
||||||
|
|
||||||
$this->config->set(['apple', 'sauce', 'is'], 'great');
|
$this->config->set(['apple', 'sauce', 'is'], 'great');
|
||||||
$apple = $this->config->get('apple');
|
$apple = $this->config->get('apple');
|
||||||
$this->assertEquals('great', $apple['sauce']['is'], 'Config value not set correctly');
|
$this->assertEquals('great', $apple['sauce']['is'], "Config value not set correctly");
|
||||||
|
|
||||||
$this->assertEquals('great', $this->config->get(['apple', 'sauce', 'is']), "Array argument get for config failed.");
|
$this->assertEquals('great', $this->config->get(['apple', 'sauce', 'is']), "Array argument get for config failed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConfigBadSet(): void
|
public function testConfigBadSet()
|
||||||
{
|
{
|
||||||
$this->expectException('InvalidArgumentException');
|
$this->expectException('InvalidArgumentException');
|
||||||
$this->config->set(NULL, FALSE);
|
$this->config->set(NULL, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataConfigDelete(): array
|
public function dataConfigDelete()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'top level delete' => [
|
'top level delete' => [
|
||||||
@ -132,7 +130,7 @@ class ConfigTest extends Ion_TestCase {
|
|||||||
/**
|
/**
|
||||||
* @dataProvider dataConfigDelete
|
* @dataProvider dataConfigDelete
|
||||||
*/
|
*/
|
||||||
public function testConfigDelete($key, array $assertKeys): void
|
public function testConfigDelete($key, $assertKeys)
|
||||||
{
|
{
|
||||||
$config = new Config([]);
|
$config = new Config([]);
|
||||||
$config->set(['apple', 'sauce', 'is'], 'great');
|
$config->set(['apple', 'sauce', 'is'], 'great');
|
||||||
@ -144,7 +142,7 @@ class ConfigTest extends Ion_TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetNonExistentConfigItem(): void
|
public function testGetNonExistentConfigItem()
|
||||||
{
|
{
|
||||||
$this->assertNull($this->config->get('foobar'));
|
$this->assertNull($this->config->get('foobar'));
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests\Di;
|
namespace Aviat\Ion\Tests\Di;
|
||||||
@ -33,13 +33,13 @@ class ContainerAwareTest extends Ion_TestCase {
|
|||||||
|
|
||||||
protected $aware;
|
protected $aware;
|
||||||
|
|
||||||
public function setUp(): void
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->container = new Container();
|
$this->container = new Container();
|
||||||
$this->aware = new Aware($this->container);
|
$this->aware = new Aware($this->container);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testContainerAwareTrait(): void
|
public function testContainerAwareTrait()
|
||||||
{
|
{
|
||||||
// The container was set in setup
|
// The container was set in setup
|
||||||
// check that the get method returns the same
|
// check that the get method returns the same
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests\Di;
|
namespace Aviat\Ion\Tests\Di;
|
||||||
@ -21,8 +21,6 @@ use Aviat\Ion\Di\Exception\ContainerException;
|
|||||||
use Aviat\Ion\Tests\Ion_TestCase;
|
use Aviat\Ion\Tests\Ion_TestCase;
|
||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
use Monolog\Handler\{TestHandler, NullHandler};
|
use Monolog\Handler\{TestHandler, NullHandler};
|
||||||
use Aviat\Ion\Di\ContainerInterface;
|
|
||||||
use Aviat\Ion\Di\Exception\NotFoundException;
|
|
||||||
|
|
||||||
class FooTest {
|
class FooTest {
|
||||||
|
|
||||||
@ -39,27 +37,27 @@ class FooTest2 {
|
|||||||
|
|
||||||
class ContainerTest extends Ion_TestCase {
|
class ContainerTest extends Ion_TestCase {
|
||||||
|
|
||||||
public function setUp(): void
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->container = new Container();
|
$this->container = new Container();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataGetWithException(): array
|
public function dataGetWithException()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'Bad index type: number' => [
|
'Bad index type: number' => [
|
||||||
'id' => 42,
|
'id' => 42,
|
||||||
'exception' => ContainerException::class,
|
'exception' => 'Aviat\Ion\Di\Exception\ContainerException',
|
||||||
'message' => 'Id must be a string'
|
'message' => 'Id must be a string'
|
||||||
],
|
],
|
||||||
'Bad index type: array' => [
|
'Bad index type: array' => [
|
||||||
'id' => [],
|
'id' => [],
|
||||||
'exception' => ContainerException::class,
|
'exception' => 'Aviat\Ion\Di\Exception\ContainerException',
|
||||||
'message' => 'Id must be a string'
|
'message' => 'Id must be a string'
|
||||||
],
|
],
|
||||||
'Non-existent id' => [
|
'Non-existent id' => [
|
||||||
'id' => 'foo',
|
'id' => 'foo',
|
||||||
'exception' => NotFoundException::class,
|
'exception' => 'Aviat\Ion\Di\Exception\NotFoundException',
|
||||||
'message' => "Item 'foo' does not exist in container."
|
'message' => "Item 'foo' does not exist in container."
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
@ -68,7 +66,7 @@ class ContainerTest extends Ion_TestCase {
|
|||||||
/**
|
/**
|
||||||
* @dataProvider dataGetWithException
|
* @dataProvider dataGetWithException
|
||||||
*/
|
*/
|
||||||
public function testGetWithException($id, $exception, $message): void
|
public function testGetWithException($id, $exception, $message)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -84,24 +82,24 @@ class ContainerTest extends Ion_TestCase {
|
|||||||
/**
|
/**
|
||||||
* @dataProvider dataGetWithException
|
* @dataProvider dataGetWithException
|
||||||
*/
|
*/
|
||||||
public function testGetNewWithException($id, $exception, $message): void
|
public function testGetNewWithException($id, $exception, $message)
|
||||||
{
|
{
|
||||||
$this->expectException($exception);
|
$this->expectException($exception);
|
||||||
$this->expectExceptionMessage($message);
|
$this->expectExceptionMessage($message);
|
||||||
$this->container->getNew($id);
|
$this->container->getNew($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataSetInstanceWithException(): array
|
public function dataSetInstanceWithException()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'Non-existent id' => [
|
'Non-existent id' => [
|
||||||
'id' => 'foo',
|
'id' => 'foo',
|
||||||
'exception' => NotFoundException::class,
|
'exception' => 'Aviat\Ion\Di\Exception\NotFoundException',
|
||||||
'message' => "Factory 'foo' does not exist in container. Set that first.",
|
'message' => "Factory 'foo' does not exist in container. Set that first.",
|
||||||
],
|
],
|
||||||
'Non-existent id 2' => [
|
'Non-existent id 2' => [
|
||||||
'id' => 'foobarbaz',
|
'id' => 'foobarbaz',
|
||||||
'exception' => NotFoundException::class,
|
'exception' => 'Aviat\Ion\Di\Exception\NotFoundException',
|
||||||
'message' => "Factory 'foobarbaz' does not exist in container. Set that first.",
|
'message' => "Factory 'foobarbaz' does not exist in container. Set that first.",
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@ -110,7 +108,7 @@ class ContainerTest extends Ion_TestCase {
|
|||||||
/**
|
/**
|
||||||
* @dataProvider dataSetInstanceWithException
|
* @dataProvider dataSetInstanceWithException
|
||||||
*/
|
*/
|
||||||
public function testSetInstanceWithException($id, $exception, $message): void
|
public function testSetInstanceWithException($id, $exception, $message)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -123,21 +121,21 @@ class ContainerTest extends Ion_TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetNew(): void
|
public function testGetNew()
|
||||||
{
|
{
|
||||||
$this->container->set('footest', static function($item) {
|
$this->container->set('footest', function($item) {
|
||||||
return new FooTest($item);
|
return new FooTest($item);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check that the item is the container, if called without arguments
|
// Check that the item is the container, if called without arguments
|
||||||
$footest1 = $this->container->getNew('footest');
|
$footest1 = $this->container->getNew('footest');
|
||||||
$this->assertInstanceOf(ContainerInterface::class, $footest1->item);
|
$this->assertInstanceOf('Aviat\Ion\Di\ContainerInterface', $footest1->item);
|
||||||
|
|
||||||
$footest2 = $this->container->getNew('footest', ['Test String']);
|
$footest2 = $this->container->getNew('footest', ['Test String']);
|
||||||
$this->assertEquals('Test String', $footest2->item);
|
$this->assertEquals('Test String', $footest2->item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetContainerInInstance(): void
|
public function testSetContainerInInstance()
|
||||||
{
|
{
|
||||||
$this->container->set('footest2', function() {
|
$this->container->set('footest2', function() {
|
||||||
return new FooTest2();
|
return new FooTest2();
|
||||||
@ -147,36 +145,36 @@ class ContainerTest extends Ion_TestCase {
|
|||||||
$this->assertEquals($this->container, $footest2->getContainer());
|
$this->assertEquals($this->container, $footest2->getContainer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetNewReturnCallable(): void
|
public function testGetNewReturnCallable()
|
||||||
{
|
{
|
||||||
$this->container->set('footest', static function($item) {
|
$this->container->set('footest', function($item) {
|
||||||
return static function() use ($item) {
|
return function() use ($item) {
|
||||||
return $item;
|
return $item;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check that the item is the container, if called without arguments
|
// Check that the item is the container, if called without arguments
|
||||||
$footest1 = $this->container->getNew('footest');
|
$footest1 = $this->container->getNew('footest');
|
||||||
$this->assertInstanceOf(ContainerInterface::class, $footest1());
|
$this->assertInstanceOf('Aviat\Ion\Di\ContainerInterface', $footest1());
|
||||||
|
|
||||||
$footest2 = $this->container->getNew('footest', ['Test String']);
|
$footest2 = $this->container->getNew('footest', ['Test String']);
|
||||||
$this->assertEquals('Test String', $footest2());
|
$this->assertEquals('Test String', $footest2());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetSet(): void
|
public function testGetSet()
|
||||||
{
|
{
|
||||||
$container = $this->container->set('foo', static function() {
|
$container = $this->container->set('foo', function() {
|
||||||
return static function() {};
|
return function() {};
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertInstanceOf(Container::class, $container);
|
$this->assertInstanceOf(Container::class, $container);
|
||||||
$this->assertInstanceOf(ContainerInterface::class, $container);
|
$this->assertInstanceOf('Aviat\Ion\Di\ContainerInterface', $container);
|
||||||
|
|
||||||
// The factory returns a callable
|
// The factory returns a callable
|
||||||
$this->assertTrue(is_callable($container->get('foo')));
|
$this->assertTrue(is_callable($container->get('foo')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLoggerMethods(): void
|
public function testLoggerMethods()
|
||||||
{
|
{
|
||||||
// Does the container have the default logger?
|
// Does the container have the default logger?
|
||||||
$this->assertFalse($this->container->hasLogger());
|
$this->assertFalse($this->container->hasLogger());
|
||||||
@ -191,8 +189,8 @@ class ContainerTest extends Ion_TestCase {
|
|||||||
$container = $this->container->setLogger($logger1);
|
$container = $this->container->setLogger($logger1);
|
||||||
$container2 = $this->container->setLogger($logger2, 'test');
|
$container2 = $this->container->setLogger($logger2, 'test');
|
||||||
|
|
||||||
$this->assertInstanceOf(ContainerInterface::class, $container);
|
$this->assertInstanceOf('Aviat\Ion\Di\ContainerInterface', $container);
|
||||||
$this->assertInstanceOf(Container::class, $container2);
|
$this->assertInstanceOf('Aviat\Ion\Di\Container', $container2);
|
||||||
|
|
||||||
$this->assertEquals($logger1, $this->container->getLogger('default'));
|
$this->assertEquals($logger1, $this->container->getLogger('default'));
|
||||||
$this->assertEquals($logger2, $this->container->getLogger('test'));
|
$this->assertEquals($logger2, $this->container->getLogger('test'));
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests;
|
namespace Aviat\Ion\Tests;
|
||||||
@ -26,7 +26,8 @@ class EnumTest extends Ion_TestCase {
|
|||||||
'FOOBAR' => 'baz'
|
'FOOBAR' => 'baz'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function setUp(): void {
|
public function setUp()
|
||||||
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->enum = new TestEnum();
|
$this->enum = new TestEnum();
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests\Exception;
|
namespace Aviat\Ion\Tests\Exception;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests;
|
namespace Aviat\Ion\Tests;
|
||||||
@ -21,7 +21,8 @@ use Aviat\Ion\Tests\FriendTestClass;
|
|||||||
|
|
||||||
class FriendTest extends Ion_TestCase {
|
class FriendTest extends Ion_TestCase {
|
||||||
|
|
||||||
public function setUp(): void {
|
public function setUp()
|
||||||
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$obj = new FriendTestClass();
|
$obj = new FriendTestClass();
|
||||||
$this->friend = new Friend($obj);
|
$this->friend = new Friend($obj);
|
||||||
|
@ -4,22 +4,25 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests;
|
namespace Aviat\Ion\Tests;
|
||||||
|
|
||||||
use function Aviat\Ion\_dir;
|
use function Aviat\Ion\_dir;
|
||||||
|
|
||||||
|
use Aura\Web\WebFactory;
|
||||||
|
use Aviat\Ion\Json;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Zend\Diactoros\ServerRequestFactory;
|
use Zend\Diactoros\ServerRequestFactory;
|
||||||
|
use Zend\Diactoros\Response as HttpResponse;
|
||||||
|
|
||||||
define('ROOT_DIR', realpath(__DIR__ . '/../') . '/');
|
define('ROOT_DIR', realpath(__DIR__ . '/../') . '/');
|
||||||
define('SRC_DIR', ROOT_DIR . 'src/');
|
define('SRC_DIR', ROOT_DIR . 'src/');
|
||||||
@ -31,10 +34,10 @@ define('TEST_VIEW_DIR', __DIR__ . '/test_views');
|
|||||||
*/
|
*/
|
||||||
class Ion_TestCase extends TestCase {
|
class Ion_TestCase extends TestCase {
|
||||||
// Test directory constants
|
// Test directory constants
|
||||||
public const ROOT_DIR = ROOT_DIR;
|
const ROOT_DIR = ROOT_DIR;
|
||||||
public const SRC_DIR = SRC_DIR;
|
const SRC_DIR = SRC_DIR;
|
||||||
public const TEST_DATA_DIR = TEST_DATA_DIR;
|
const TEST_DATA_DIR = TEST_DATA_DIR;
|
||||||
public const TEST_VIEW_DIR = TEST_VIEW_DIR;
|
const TEST_VIEW_DIR = TEST_VIEW_DIR;
|
||||||
|
|
||||||
protected $container;
|
protected $container;
|
||||||
protected static $staticContainer;
|
protected static $staticContainer;
|
||||||
@ -48,7 +51,7 @@ class Ion_TestCase extends TestCase {
|
|||||||
self::$session_handler = $session_handler;
|
self::$session_handler = $session_handler;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
public function setUp(): void
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
@ -97,7 +100,7 @@ class Ion_TestCase extends TestCase {
|
|||||||
// Set up DI container
|
// Set up DI container
|
||||||
$di = require('di.php');
|
$di = require('di.php');
|
||||||
$container = $di($config_array);
|
$container = $di($config_array);
|
||||||
$container->set('session-handler', static function() {
|
$container->set('session-handler', function() {
|
||||||
// Use mock session handler
|
// Use mock session handler
|
||||||
$session_handler = new TestSessionHandler();
|
$session_handler = new TestSessionHandler();
|
||||||
session_set_save_handler($session_handler, TRUE);
|
session_set_save_handler($session_handler, TRUE);
|
||||||
@ -113,7 +116,7 @@ class Ion_TestCase extends TestCase {
|
|||||||
* @param array $supers
|
* @param array $supers
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setSuperGlobals(array $supers = []): void
|
public function setSuperGlobals(array $supers = [])
|
||||||
{
|
{
|
||||||
$default = [
|
$default = [
|
||||||
'_SERVER' => $_SERVER,
|
'_SERVER' => $_SERVER,
|
||||||
@ -124,7 +127,7 @@ class Ion_TestCase extends TestCase {
|
|||||||
];
|
];
|
||||||
|
|
||||||
$request = call_user_func_array(
|
$request = call_user_func_array(
|
||||||
[ServerRequestFactory::class, 'fromGlobals'],
|
['Zend\Diactoros\ServerRequestFactory', 'fromGlobals'],
|
||||||
array_merge($default, $supers)
|
array_merge($default, $supers)
|
||||||
);
|
);
|
||||||
$this->container->setInstance('request', $request);
|
$this->container->setInstance('request', $request);
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests;
|
namespace Aviat\Ion\Tests;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests\Model;
|
namespace Aviat\Ion\Tests\Model;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests;
|
namespace Aviat\Ion\Tests;
|
||||||
@ -24,7 +24,8 @@ class StringWrapperTest extends TestCase {
|
|||||||
|
|
||||||
protected $wrapper;
|
protected $wrapper;
|
||||||
|
|
||||||
public function setUp(): void {
|
public function setUp()
|
||||||
|
{
|
||||||
$this->wrapper = new class {
|
$this->wrapper = new class {
|
||||||
use StringWrapper;
|
use StringWrapper;
|
||||||
};
|
};
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests;
|
namespace Aviat\Ion\Tests;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests\Transformer;
|
namespace Aviat\Ion\Tests\Transformer;
|
||||||
@ -25,7 +25,8 @@ class AbstractTransformerTest extends Ion_TestCase {
|
|||||||
protected $untransformer;
|
protected $untransformer;
|
||||||
|
|
||||||
|
|
||||||
public function setUp(): void {
|
public function setUp()
|
||||||
|
{
|
||||||
$this->transformer = new TestTransformer();
|
$this->transformer = new TestTransformer();
|
||||||
$this->untransformer = new TestTransformerUntransform();
|
$this->untransformer = new TestTransformerUntransform();
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests\Type;
|
namespace Aviat\Ion\Tests\Type;
|
||||||
@ -22,7 +22,8 @@ use Aviat\Ion\Tests\Ion_TestCase;
|
|||||||
class ArrayTypeTest extends Ion_TestCase {
|
class ArrayTypeTest extends Ion_TestCase {
|
||||||
use ArrayWrapper;
|
use ArrayWrapper;
|
||||||
|
|
||||||
public function setUp(): void {
|
public function setUp()
|
||||||
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests\Type;
|
namespace Aviat\Ion\Tests\Type;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests\View;
|
namespace Aviat\Ion\Tests\View;
|
||||||
@ -24,7 +24,8 @@ class HtmlViewTest extends HttpViewTest {
|
|||||||
|
|
||||||
protected $template_path;
|
protected $template_path;
|
||||||
|
|
||||||
public function setUp(): void {
|
public function setUp()
|
||||||
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->view = new TestHtmlView($this->container);
|
$this->view = new TestHtmlView($this->container);
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests\View;
|
namespace Aviat\Ion\Tests\View;
|
||||||
@ -26,7 +26,8 @@ class HttpViewTest extends Ion_TestCase {
|
|||||||
protected $view;
|
protected $view;
|
||||||
protected $friend;
|
protected $friend;
|
||||||
|
|
||||||
public function setUp(): void {
|
public function setUp()
|
||||||
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->view = new TestHttpView($this->container);
|
$this->view = new TestHttpView($this->container);
|
||||||
$this->friend = new Friend($this->view);
|
$this->friend = new Friend($this->view);
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests\View;
|
namespace Aviat\Ion\Tests\View;
|
||||||
@ -21,7 +21,8 @@ use Aviat\Ion\Tests\TestJsonView;
|
|||||||
|
|
||||||
class JsonViewTest extends HttpViewTest {
|
class JsonViewTest extends HttpViewTest {
|
||||||
|
|
||||||
public function setUp(): void {
|
public function setUp()
|
||||||
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->view = new TestJsonView($this->container);
|
$this->view = new TestJsonView($this->container);
|
||||||
|
@ -1,88 +0,0 @@
|
|||||||
<?php declare(strict_types=1);
|
|
||||||
/**
|
|
||||||
* Ion
|
|
||||||
*
|
|
||||||
* Building blocks for web development
|
|
||||||
*
|
|
||||||
* PHP version 7.2
|
|
||||||
*
|
|
||||||
* @package Ion
|
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
||||||
* @version 3.0.0
|
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests;
|
|
||||||
|
|
||||||
use Aviat\Ion\XML;
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
class XMLTest extends TestCase {
|
|
||||||
|
|
||||||
protected $xml;
|
|
||||||
protected $expectedXml;
|
|
||||||
protected $object;
|
|
||||||
protected $array;
|
|
||||||
|
|
||||||
public function setUp(): void {
|
|
||||||
$this->xml = file_get_contents(__DIR__ . '/test_data/XML/xmlTestFile.xml');
|
|
||||||
$this->expectedXml = file_get_contents(__DIR__ . '/test_data/XML/minifiedXmlTestFile.xml');
|
|
||||||
|
|
||||||
$this->array = [
|
|
||||||
'entry' => [
|
|
||||||
'foo' => [
|
|
||||||
'bar' => [
|
|
||||||
'baz' => 42
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'episode' => '11',
|
|
||||||
'status' => 'watching',
|
|
||||||
'score' => '7',
|
|
||||||
'storage_type' => '1',
|
|
||||||
'storage_value' => '2.5',
|
|
||||||
'times_rewatched' => '1',
|
|
||||||
'rewatch_value' => '3',
|
|
||||||
'date_start' => '01152015',
|
|
||||||
'date_finish' => '10232016',
|
|
||||||
'priority' => '2',
|
|
||||||
'enable_discussion' => '0',
|
|
||||||
'enable_rewatching' => '1',
|
|
||||||
'comments' => 'Should you say something?',
|
|
||||||
'tags' => 'test tag, 2nd tag'
|
|
||||||
]
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->object = new XML();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testToArray()
|
|
||||||
{
|
|
||||||
$this->assertEquals($this->array, XML::toArray($this->xml));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testParse()
|
|
||||||
{
|
|
||||||
$this->object->setXML($this->xml);
|
|
||||||
$this->assertEquals($this->array, $this->object->parse());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testToXML()
|
|
||||||
{
|
|
||||||
$this->assertEquals($this->expectedXml, XML::toXML($this->array));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateXML()
|
|
||||||
{
|
|
||||||
$this->object->setData($this->array);
|
|
||||||
$this->assertEquals($this->expectedXml, $this->object->createXML());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testToString()
|
|
||||||
{
|
|
||||||
$this->object->setData($this->array);
|
|
||||||
$this->assertEquals($this->expectedXml, $this->object->__toString());
|
|
||||||
$this->assertEquals($this->expectedXml, (string)$this->object);
|
|
||||||
}
|
|
||||||
}
|
|
@ -21,8 +21,8 @@ require 'Ion_TestCase.php';
|
|||||||
// Ini Settings
|
// Ini Settings
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
ini_set('session.use_cookies', 0);
|
ini_set('session.use_cookies', 0);
|
||||||
ini_set('session.use_only_cookies',0);
|
ini_set("session.use_only_cookies",0);
|
||||||
ini_set('session.use_trans_sid',1);
|
ini_set("session.use_trans_sid",1);
|
||||||
// Start session here to surpress error about headers not sent
|
// Start session here to surpress error about headers not sent
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
12
tests/di.php
12
tests/di.php
@ -11,16 +11,16 @@ use Aviat\Ion\Di\Container;
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Setup DI container
|
// Setup DI container
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
return static function(array $config_array = []) {
|
return function(array $config_array = []) {
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
|
|
||||||
$container->set('config', static function() {
|
$container->set('config', function() {
|
||||||
return new Config([]);
|
return new Config([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
$container->setInstance('config', new Config($config_array));
|
$container->setInstance('config', new Config($config_array));
|
||||||
|
|
||||||
$container->set('request', static function() {
|
$container->set('request', function() {
|
||||||
return ServerRequestFactory::fromGlobals(
|
return ServerRequestFactory::fromGlobals(
|
||||||
$_SERVER,
|
$_SERVER,
|
||||||
$_GET,
|
$_GET,
|
||||||
@ -30,17 +30,17 @@ return static function(array $config_array = []) {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$container->set('response', static function() {
|
$container->set('response', function() {
|
||||||
return new Response();
|
return new Response();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create session Object
|
// Create session Object
|
||||||
$container->set('session', static function() {
|
$container->set('session', function() {
|
||||||
return (new SessionFactory())->newInstance($_COOKIE);
|
return (new SessionFactory())->newInstance($_COOKIE);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create Html helper Object
|
// Create Html helper Object
|
||||||
$container->set('html-helper', static function() {
|
$container->set('html-helper', function() {
|
||||||
return (new HelperLocatorFactory)->newInstance();
|
return (new HelperLocatorFactory)->newInstance();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests;
|
namespace Aviat\Ion\Tests;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* Building blocks for web development
|
* Building blocks for web development
|
||||||
*
|
*
|
||||||
* PHP version 7.2
|
* PHP version 7.1
|
||||||
*
|
*
|
||||||
* @package Ion
|
* @package Ion
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2019 Timothy J. Warren
|
* @copyright 2015 - 2018 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.0.0
|
* @version 2.4.0
|
||||||
* @link https://git.timshomepage.net/aviat/ion
|
* @link https://git.timshomepage.net/timw4mail/ion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\Ion\Tests;
|
namespace Aviat\Ion\Tests;
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<entry><foo><bar><baz>42</baz></bar></foo><episode>11</episode><status>watching</status><score>7</score><storage_type>1</storage_type><storage_value>2.5</storage_value><times_rewatched>1</times_rewatched><rewatch_value>3</rewatch_value><date_start>01152015</date_start><date_finish>10232016</date_finish><priority>2</priority><enable_discussion>0</enable_discussion><enable_rewatching>1</enable_rewatching><comments>Should you say something?</comments><tags>test tag, 2nd tag</tags></entry>
|
|
@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<entry>
|
|
||||||
<foo>
|
|
||||||
<bar>
|
|
||||||
<baz>42</baz>
|
|
||||||
</bar>
|
|
||||||
</foo>
|
|
||||||
<episode>11</episode>
|
|
||||||
<status>watching</status>
|
|
||||||
<score>7</score>
|
|
||||||
<storage_type>1</storage_type>
|
|
||||||
<storage_value>2.5</storage_value>
|
|
||||||
<times_rewatched>1</times_rewatched>
|
|
||||||
<rewatch_value>3</rewatch_value>
|
|
||||||
<date_start>01152015</date_start>
|
|
||||||
<date_finish>10232016</date_finish>
|
|
||||||
<priority>2</priority>
|
|
||||||
<enable_discussion>0</enable_discussion>
|
|
||||||
<enable_rewatching>1</enable_rewatching>
|
|
||||||
<comments>Should you say something?</comments>
|
|
||||||
<tags>test tag, 2nd tag</tags>
|
|
||||||
</entry>
|
|
Loading…
Reference in New Issue
Block a user