Implemented unit tests for future applications.
This commit is contained in:
parent
634133f182
commit
93f0b62d0c
|
@ -1,6 +1,5 @@
|
|||
.gitattributes export-ignore
|
||||
.gitignore export-ignore
|
||||
.gitlab_ci.yml export-ignore
|
||||
CI/ export-ignore
|
||||
DCO export-ignore
|
||||
CONTRIBUTING.md export-ignore
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
/vendor
|
||||
/build
|
||||
composer.lock
|
|
@ -0,0 +1,56 @@
|
|||
before_script:
|
||||
# Install dependencies
|
||||
- bash tests/docker_install.sh > /dev/null
|
||||
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- deploy
|
||||
|
||||
build:composer:
|
||||
image: php:5.6
|
||||
stage: build
|
||||
script:
|
||||
- curl -sS https://getcomposer.org/installer | php
|
||||
- php composer.phar install
|
||||
cache:
|
||||
key: "$CI_BUILD_REF/$CI_BUILD_REF_NAME"
|
||||
paths:
|
||||
- vendor/
|
||||
|
||||
test:5.6:
|
||||
stage: test
|
||||
image: php:5.6
|
||||
script:
|
||||
- vendor/bin/phpunit -c tests/phpunit.xml
|
||||
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"
|
||||
paths:
|
||||
- vendor/
|
||||
|
||||
release:
|
||||
stage: deploy
|
||||
image: php:5.6
|
||||
only:
|
||||
- master
|
||||
script:
|
||||
- vendor/bin/phpunit -c tests/phpunit.xml
|
||||
artifacts:
|
||||
name: "${CI_BUILD_NAME}_${CI_BUILD_REF_NAME}"
|
||||
paths:
|
||||
- build/
|
||||
expire_in: 3 weeks
|
||||
cache:
|
||||
key: "$CI_BUILD_REF/$CI_BUILD_REF_NAME"
|
||||
paths:
|
||||
- vendor/
|
|
@ -30,7 +30,7 @@
|
|||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
require_once('../vendor/autoload.php');
|
||||
require_once(dirname(__DIR__) . '/vendor/autoload.php');
|
||||
|
||||
$configurator = new FuzeWorks\Configurator();
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
abstract class TestCase extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 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://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
use Application\Controller\Standard;
|
||||
use FuzeWorks\Layout;
|
||||
use FuzeWorks\Factory;
|
||||
|
||||
/**
|
||||
* Controller Standard Test.
|
||||
*
|
||||
* Tests the 'standard' controller.
|
||||
* @todo Implement a proper way to load the controller
|
||||
*/
|
||||
class standardTest extends TestCase
|
||||
{
|
||||
|
||||
private $controller;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
require_once('application/Controller/controller.standard.php');
|
||||
$this->controller = new Standard();
|
||||
}
|
||||
|
||||
public function testType()
|
||||
{
|
||||
$this->assertInstanceOf('\Application\Controller\Standard', $this->controller);
|
||||
}
|
||||
|
||||
public function testIndex()
|
||||
{
|
||||
// First set a test file ready
|
||||
Layout::setDirectory(dirname(__FILE__) . '/testIndex/');
|
||||
|
||||
// Perform and retrieve the output
|
||||
ob_start();
|
||||
$this->controller->index();
|
||||
Factory::getInstance()->output->_display();
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$this->assertEquals('Hello!', $output);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
Layout::reset();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
Hello!
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 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://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
use FuzeWorks\Core;
|
||||
|
||||
/**
|
||||
* 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'));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
|
@ -0,0 +1,58 @@
|
|||
<?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 0.0.1
|
||||
*/
|
||||
|
||||
use FuzeWorks\Logger;
|
||||
use Tracy\Debugger;
|
||||
|
||||
// Load the FuzeWorks container
|
||||
$container = require(dirname(__DIR__) . '/application/bootstrap.php');
|
||||
|
||||
// Load the test abstract
|
||||
require_once 'TestCase.php';
|
||||
|
||||
// Reset error and exception handlers
|
||||
ob_start();
|
||||
restore_error_handler();
|
||||
restore_exception_handler();
|
||||
|
||||
// Display all errors
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
|
||||
// Set localhost "remote" IP
|
||||
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');
|
|
@ -0,0 +1,18 @@
|
|||
#!/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
|
|
@ -0,0 +1,42 @@
|
|||
<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" logIncompleteSkipped="false"/>
|
||||
<log type="testdox-html" target="../build/phpunit/testdox.html"/>
|
||||
<log type="testdox-text" target="../build/phpunit/testdox.txt"/>
|
||||
<log type="coverage-html" target="../build/phpunit/coverage_html" lowUpperBound="35"
|
||||
highLowerBound="70"/>
|
||||
<log type="coverage-clover" target="../build/phpunit/coverage.xml"/>
|
||||
<log type="coverage-php" target="../build/phpunit/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>
|
Loading…
Reference in New Issue