Implemented all changes requested during development

This commit is contained in:
Abel Hoogeveen 2019-03-15 17:29:08 +01:00
parent 46197d45b4
commit 702f2e8ba5
No known key found for this signature in database
GPG Key ID: 96C2234920BF4292
21 changed files with 246 additions and 248 deletions

View File

@ -1,6 +1,8 @@
before_script:
# Install dependencies
- bash tests/docker_install.sh > /dev/null
- set -xe
- apt-get update -yqq
- apt-get install git zip unzip -yqq
stages:
- build
@ -8,23 +10,13 @@ stages:
- deploy
build:composer:
image: php:7.1
image: php:7.2
stage: build
script:
script:
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install
cache:
key: "$CI_BUILD_REF/$CI_BUILD_REF_NAME"
paths:
- vendor/
test:7.0:
stage: test
image: php:7.0
script:
- vendor/bin/phpunit -c tests/phpunit.xml
cache:
key: "$CI_BUILD_REF/$CI_BUILD_REF_NAME"
key: "$CI_BUILD_REF_$CI_BUILD_REF_NAME"
paths:
- vendor/
@ -34,23 +26,57 @@ test:7.1:
script:
- vendor/bin/phpunit -c tests/phpunit.xml
cache:
key: "$CI_BUILD_REF/$CI_BUILD_REF_NAME"
key: "$CI_BUILD_REF_$CI_BUILD_REF_NAME"
paths:
- vendor/
test:7.2:
stage: test
image: php:7.2
script:
- vendor/bin/phpunit -c tests/phpunit.xml
cache:
key: "$CI_BUILD_REF_$CI_BUILD_REF_NAME"
paths:
- vendor/
test:7.3:
stage: test
image: php:7.3
script:
- vendor/bin/phpunit -c tests/phpunit.xml
cache:
key: "$CI_BUILD_REF_$CI_BUILD_REF_NAME"
paths:
- vendor/
test:coverage:
stage: test
image: php:7.2
script:
- pecl install xdebug
- docker-php-ext-enable xdebug
- vendor/bin/phpunit -c tests/phpunit.xml --coverage-text
cache:
key: "$CI_BUILD_REF_$CI_BUILD_REF_NAME"
paths:
- vendor/
release:
stage: deploy
image: php:7.1
image: php:7.2
only:
- master
script:
- vendor/bin/phpunit -c tests/phpunit.xml
- pecl install xdebug
- docker-php-ext-enable xdebug
- vendor/bin/phpunit -c tests/phpunit.xml --coverage-text
artifacts:
name: "${CI_BUILD_NAME}_${CI_BUILD_REF_NAME}"
paths:
- build/
expire_in: 3 weeks
cache:
key: "$CI_BUILD_REF/$CI_BUILD_REF_NAME"
key: "$CI_BUILD_REF_$CI_BUILD_REF_NAME"
paths:
- vendor/

View File

@ -1,8 +1,9 @@
language: php
php:
- 7
- 7.1
- 7.2
- 7.3
script:
- php vendor/bin/phpunit -v -c tests/phpunit.xml --coverage-text

View File

@ -18,14 +18,14 @@ PHP 7.1 or higher.
Installation
------------
The best way to install Web Project is using Composer. If you don't have Composer yet,
The best way to install this Application is using Composer. If you don't have Composer yet,
download it following [the instructions](https://doc.nette.org/composer). Then use command:
composer create-project fuzeworks/application path/to/install
cd path/to/install
Make directories `temp/` and `log/` writable.
Make sure directories `temp/` and `log/` are writable.
Web Server Setup

View File

@ -51,8 +51,14 @@ return [
*/
'csrf_protection' => true,
'csrf_token_name' => 'fw_csrf_token',
'csrf_cookie_name' => 'fw_csrf_cookie',
'csrf_expire' => 7200,
'csrf_regenerate' => TRUE,
'csrf_exclude_uris' => array(),
// CSRF Cookie information
'csrf_cookie_name' => 'fw_csrf_cookie',
'csrf_cookie_prefix' => '',
'csrf_cookie_domain' => '',
'csrf_cookie_path' => '/',
'csrf_cookie_secure' => false,
'csrf_cookie_httponly' => false
];

View File

@ -34,13 +34,23 @@
* @version Version 1.2.0
*/
return [
// General
'base_url' => '',
'serverName' => 'FuzeWorks',
'allow_get_input' => true,
'empty_global_arrays' => true,
'restore_global_arrays' => true,
'base_url' => '',
'permitted_uri_chars' => 'a-z 0-9~%.:_\-',
'charset' => 'UTF-8',
'compress_output' => false,
'xss_clean' => true,
// Cookie settings
'cookie_prefix' => 'FWZ_',
'xss_clean' => true
'cookie_domain' => '',
'cookie_path' => '/',
'cookie_secure' => false,
'cookie_httponly' => false,
];

View File

@ -0,0 +1,99 @@
<?php
/**
* FuzeWorks Application Skeleton.
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2019 TechFuze
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 0.0.1
*
* @version Version 1.2.0
*/
?>
<html>
<head>
<title>Page not found</title>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
background: #ecf0f1;
border-bottom: 1px solid #DDD;
padding: 100px 0 100px;
font-size: 16px;
}
#setupcontainer {
max-width: 950px;
margin-left: auto;
margin-right: auto;
}
.col-centered{
float: none;
margin: 0 auto;
}
</style>
</head>
<body>
<div id='setupcontainer'>
<div class='row'>
<div class='col-lg-12 col-md-4 col-sm-12'>
<div id='contentPanel' class="panel panel-default" style='display:none'>
<div id='1' class="panel-body" style='display:none'>
<p class="lead">Forbidden</p>
<p>
Access to this page was denied.
</p>
<p>
Our apologies for the inconvenience.
</p>
</div>
</div>
</div>
</div>
</div>
<footer>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script>
var currentPage = 0;
var currentProgress = 0;
start();
function start() {
$("#contentPanel").fadeIn(500);
$("#1").fadeIn(500);
}
</script>
</footer>
</body>
</html>

View File

@ -38,9 +38,22 @@ namespace Application\View;
use FuzeWorks\WebAppView;
/**
* Class ErrorHtmlView
*
* This view gets loaded upon a HTTP error. For example, the error404() method gets loaded when a page can't be
* found by the WebComponent. The error500 gets loaded upon a fatal error somewhere in the application.
*
* Important! The status header is already set by WebComponent. No need to do it again.
*/
class ErrorHtmlView extends WebAppView
{
public function error403()
{
return $this->layouts->get('errors/403');
}
public function error404()
{
return $this->layouts->get('errors/404');

View File

@ -37,15 +37,15 @@
use FuzeWorks\Priority;
use FuzeWorks\WebAppComponent;
require_once(dirname(__DIR__) . '/vendor/autoload.php');
require_once(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor/autoload.php');
// Open configurator
$configurator = new FuzeWorks\Configurator();
// Set up basic settings
$configurator->setTimeZone('Europe/Amsterdam');
$configurator->setTempDirectory(dirname(__DIR__) . '/temp');
$configurator->setLogDirectory(dirname(__DIR__). '/log');
$configurator->setTempDirectory(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'temp');
$configurator->setLogDirectory(dirname(__DIR__). DIRECTORY_SEPARATOR . 'log');
// Enable components
// WebComponent
@ -54,16 +54,16 @@ $webAppComponent->enableWebRequest();
$configurator->addComponent($webAppComponent);
// Add directories
$configurator->addDirectory(dirname(__FILE__) . '/Config', 'config', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . '/Helper', 'helpers', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . '/Library', 'libraries', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . '/Plugin', 'plugins', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . '/Controller', 'controllers', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . '/View', 'views', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . '/Model', 'models', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . '/Layout', 'layouts', Priority::NORMAL);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Config', 'config', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Helper', 'helpers', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Library', 'libraries', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Plugin', 'plugins', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Controller', 'controllers', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'View', 'views', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Model', 'models', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Layout', 'layouts', Priority::NORMAL);
// Debug
$configurator->enableDebugMode()->setDebugAddress('ALL');
$configurator->enableDebugMode()->setDebugAddress('127.0.0.1');
return $configurator->createContainer();

View File

@ -14,12 +14,13 @@
}
],
"require": {
"php": ">=7.1.0",
"fuzeworks/webappcomponent": "dev-master"
"php": ">=7.1.0",
"fuzeworks/webappcomponent": "1.2.0-RC3",
"ext-pdo": "*"
},
"require-dev": {
"phpunit/phpunit": "^7"
},
"minimum-stability": "dev",
"minimum-stability": "RC",
"prefer-stable": true
}

View File

@ -30,55 +30,23 @@
* @version Version 1.0.0
*/
use PHPUnit\Framework\TestCase;
use Application\Controller\Standard;
use FuzeWorks\Layout;
use FuzeWorks\Core;
use FuzeWorks\Factory;
use PHPUnit\Framework\TestCase;
/**
* Controller Standard Test.
* Class LoadFuzeWorksTest.
*
* Tests the 'standard' controller.
* @todo Implement a proper way to load the controller
* Tests if the application is able to open FuzeWorks and all it's classes.
* Does not test any internal workings of FuzeWorks
*/
class standardTest extends TestCase
class loadFuzeWorksTest extends TestCase
{
private $controller;
private $factory;
public function setUp()
public function testLoadCore()
{
require_once('application/Controller/controller.standard.php');
$this->controller = new Standard();
$this->factory = Factory::getInstance();
$this->assertInstanceOf('\FuzeWorks\Factory', Factory::getInstance());
}
public function testType()
{
$this->assertInstanceOf('\Application\Controller\Standard', $this->controller);
}
public function testIndex()
{
// First set a test file ready
$this->factory->layout->setDirectory(dirname(__FILE__) . '/testIndex/');
// Perform and retrieve the output
ob_start();
$this->controller->index();
$this->factory->output->_display();
$output = ob_get_contents();
ob_end_clean();
$this->assertEquals('Hello!', $output);
}
public function tearDown()
{
$this->factory->layout->reset();
$this->factory->output->set_output('');
}
}
}

View File

@ -31,15 +31,10 @@
*/
use FuzeWorks\Logger;
use Tracy\Debugger;
// Load the FuzeWorks container
$container = require(dirname(__DIR__) . '/application/bootstrap.php');
// Reset error and exception handlers
ob_start();
restore_error_handler();
restore_exception_handler();
Logger::disableHandlers();
// Display all errors
ini_set('display_errors', 1);
@ -49,7 +44,4 @@ error_reporting(E_ALL | E_STRICT);
isset($_SERVER['REMOTE_ADDR']) OR $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
// Set a logger which works better with the CLI interface
Logger::setLoggerTemplate('logger_cli');
//require_once('mocks/autoloader.php');
//spl_autoload_register('autoload');
Logger::setLoggerTemplate('logger_cli');

38
test/phpunit.xml Normal file
View File

@ -0,0 +1,38 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
bootstrap="autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
colors="false">
<testsuites>
<testsuite name="Application Suite">
<directory>./</directory>
</testsuite>
</testsuites>
<logging>
<log type="json" target="../build/phpunit/logfile.json"/>
<log type="junit" target="../build/phpunit/logfile.xml"/>
<log type="testdox-html" target="../build/phpunit/testdox.html"/>
<log type="testdox-text" target="../build/phpunit/testdox.txt"/>
</logging>
<filter>
<whitelist processUncoveredFilesFromWhitelist="false">
<directory suffix=".php">../</directory>
<exclude>
<directory suffix=".php">../vendor/</directory>
<directory suffix=".php">../test/</directory>
<directory suffix=".php">../www/</directory>
<directory suffix=".php">../build/</directory>
<directory suffix=".php">../log/</directory>
<directory suffix=".php">../temp/</directory>
</exclude>
</whitelist>
</filter>
</phpunit>

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -1,85 +0,0 @@
<?php
/**
* FuzeWorks Application Skeleton.
*
* The FuzeWorks MVC PHP FrameWork
*
* Copyright (C) 2016 TechFuze
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
*
* @link http://techfuze.net/fuzeworks
* @since Version 0.0.1
*
* @version Version 1.0.0
*/
use FuzeWorks\Core;
use PHPUnit\Framework\TestCase;
/**
* Class LoadFuzeWorksTest.
*
* Tests if the application is able to open FuzeWorks and all it's classes.
* Does not test any internal workings of FuzeWorks
*/
class loadFuzeWorksTest extends TestCase
{
public function testClassExists()
{
$this->assertTrue(class_exists('FuzeWorks\Core', false));
}
/**
* @depends testClassExists
*/
public function testLoadCore()
{
$core = new Core();
$this->assertInstanceOf('FuzeWorks\Core', $core);
}
/**
* @depends testLoadCore
*/
public function testCoreClasses()
{
// Assert
$this->assertTrue(class_exists('FuzeWorks\Core'));
$this->assertTrue(class_exists('FuzeWorks\Config'));
$this->assertTrue(class_exists('FuzeWorks\Logger'));
$this->assertTrue(class_exists('FuzeWorks\Events'));
$this->assertTrue(class_exists('FuzeWorks\Router'));
$this->assertTrue(class_exists('FuzeWorks\Layout'));
$this->assertTrue(class_exists('FuzeWorks\Models'));
$this->assertTrue(class_exists('FuzeWorks\Database'));
$this->assertTrue(class_exists('FuzeWorks\Factory'));
$this->assertTrue(class_exists('FuzeWorks\Helpers'));
$this->assertTrue(class_exists('FuzeWorks\Input'));
$this->assertTrue(class_exists('FuzeWorks\Language'));
$this->assertTrue(class_exists('FuzeWorks\Libraries'));
$this->assertTrue(class_exists('FuzeWorks\Output'));
$this->assertTrue(class_exists('FuzeWorks\Security'));
$this->assertTrue(class_exists('FuzeWorks\URI'));
$this->assertTrue(class_exists('FuzeWorks\UTF8'));
}
}

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -1,18 +0,0 @@
#!/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
apt-get update -yqq
apt-get install git zip unzip -yqq
# Install xdebug
pecl install xdebug
docker-php-ext-enable xdebug
# Install mysql driver
# Here you can install any other extension that you need
docker-php-ext-install pdo_mysql

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -1,42 +0,0 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
bootstrap="autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
colors="false">
<testsuites>
<testsuite name="Application Suite">
<directory>./</directory>
</testsuite>
</testsuites>
<logging>
<log type="json" target="../build/logs/logfile.json"/>
<log type="junit" target="../build/logs/logfile.xml" logIncompleteSkipped="false"/>
<log type="testdox-html" target="../build/logs/testdox.html"/>
<log type="testdox-text" target="../build/logs/testdox.txt"/>
<log type="coverage-html" target="../build/logs/coverage_html" lowUpperBound="35"
highLowerBound="70"/>
<log type="coverage-clover" target="../build/logs/clover.xml"/>
<log type="coverage-php" target="../build/logs/coverage.serialized"/>
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false"/>
</logging>
<filter>
<whitelist processUncoveredFilesFromWhitelist="false">
<directory suffix=".php">../application</directory>
<exclude>
<directory suffix=".php">../vendor/</directory>
<directory suffix=".php">../application/Config</directory>
<directory suffix=".php">../application/Language</directory>
<directory suffix=".php">../application/Views</directory>
<file>../application/bootstrap.php</file>
</exclude>
</whitelist>
</filter>
</phpunit>