Merge branch '85-implement-gitlab-ci' into 'master'
Resolve "Implement Gitlab CI" ##### GitLab CI has now been successfully implemented into FuzeWorks. Some tests have been **removed** or **altered** in order for them to work. *PHP 5.4 and 5.5 do not work right now. These builds are allowed to fail right now. This should be a priority for the future.* > Closes #85 See merge request !43
This commit is contained in:
commit
99573c0fb8
|
@ -0,0 +1,76 @@
|
|||
before_script:
|
||||
# Install dependencies
|
||||
- bash CI/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.4:
|
||||
image: php:5.4
|
||||
script:
|
||||
- vendor/bin/phpunit -c phpunit.xml --coverage-text
|
||||
cache:
|
||||
key: "$CI_BUILD_REF/$CI_BUILD_REF_NAME"
|
||||
paths:
|
||||
- vendor/
|
||||
allow_failure: true
|
||||
|
||||
test:5.5:
|
||||
image: php:5.5
|
||||
script:
|
||||
- vendor/bin/phpunit -c phpunit.xml --coverage-text
|
||||
cache:
|
||||
key: "$CI_BUILD_REF/$CI_BUILD_REF_NAME"
|
||||
paths:
|
||||
- vendor/
|
||||
allow_failure: true
|
||||
|
||||
test:5.6:
|
||||
stage: test
|
||||
image: php:5.6
|
||||
script:
|
||||
- vendor/bin/phpunit -c phpunit.xml --coverage-text
|
||||
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 phpunit.xml --coverage-text
|
||||
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 phpunit.xml --coverage-text
|
||||
- vendor/bin/apigen generate -s . -d 'build/phpdoc' --todo --title 'FuzeWorks Build' --exclude 'tests/*','build/*','vendor/*','CI/*'
|
||||
artifacts:
|
||||
name: "${CI_BUILD_NAME}_${CI_BUILD_REF_NAME}"
|
||||
paths:
|
||||
- build/
|
||||
cache:
|
||||
key: "$CI_BUILD_REF/$CI_BUILD_REF_NAME"
|
||||
paths:
|
||||
- vendor/
|
|
@ -0,0 +1,14 @@
|
|||
#!/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 mysql driver
|
||||
# Here you can install any other extension that you need
|
||||
docker-php-ext-install pdo_mysql
|
|
@ -496,6 +496,7 @@ class Layout
|
|||
}
|
||||
self::$current_engine = null;
|
||||
self::$assigned_variables = array();
|
||||
self::$directory = 'Application/Views';
|
||||
Logger::log('Reset the layout manager to its default state');
|
||||
}
|
||||
}
|
||||
|
|
36
build.xml
36
build.xml
|
@ -1,36 +0,0 @@
|
|||
<project name="FuzeWorks" default="build" basedir=".">
|
||||
<target name="clean">
|
||||
<delete dir="${basedir}/build" />
|
||||
</target>
|
||||
|
||||
<target name="prepare">
|
||||
<mkdir dir="${basedir}/build/logs" />
|
||||
<mkdir dir="${basedir}/build/clover" />
|
||||
<mkdir dir="${basedir}/build/phpdoc" />
|
||||
</target>
|
||||
|
||||
<target name="phpunit">
|
||||
<exec dir="${basedir}" executable="php" failonerror="true">
|
||||
<arg value="phpunit.phar"/>
|
||||
<arg line="--configuration phpunit.xml
|
||||
--log-junit build/logs/phpunit.xml
|
||||
--coverage-clover build/logs/clover.xml
|
||||
--coverage-html build/clover" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="phpdoc">
|
||||
<exec dir="${basedir}" executable="php" failonerror="yes">
|
||||
<arg value="apigen.phar"/>
|
||||
<arg line="generate --source . --destination 'build/phpdoc' --exclude 'tests/*','build/*','Core/System/Smarty/*','vendor/*' "/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="zip">
|
||||
<exec dir="${basedir}" executable="git" failonerror="true">
|
||||
<arg line="archive -o ${basedir}/build/fuzeworks-core.zip HEAD" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="build" depends="clean,prepare,phpunit,phpdoc,zip" />
|
||||
</project>
|
|
@ -22,4 +22,11 @@
|
|||
<directory>tests</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"/>
|
||||
</logging>
|
||||
</phpunit>
|
|
@ -1,105 +0,0 @@
|
|||
<?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;
|
||||
use \FuzeWorks\Models;
|
||||
|
||||
/**
|
||||
* Class ModelTest.
|
||||
*
|
||||
* Core model testing suite, will test basic model functionality
|
||||
*/
|
||||
class modelTest extends CoreTestAbstract
|
||||
{
|
||||
/**
|
||||
* Select.
|
||||
*/
|
||||
public function testSelectSimple()
|
||||
{
|
||||
$query = Models::get('sqltable')->select();
|
||||
$this->assertEquals('SELECT * FROM table', $query->getSql());
|
||||
}
|
||||
|
||||
public function testSelectSimpleOneField()
|
||||
{
|
||||
$query = Models::get('sqltable')->select('field1');
|
||||
$this->assertEquals('SELECT field1 FROM table', $query->getSql());
|
||||
}
|
||||
|
||||
public function testSelectSimpleTwoFields()
|
||||
{
|
||||
$query = Models::get('sqltable')->select('field1', 'field2');
|
||||
$this->assertEquals('SELECT field1, field2 FROM table', $query->getSql());
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete.
|
||||
*/
|
||||
public function testDeleteSimple()
|
||||
{
|
||||
$query = Models::get('sqltable')->delete()->from('table');
|
||||
$this->assertEquals('DELETE FROM table', $query->getSql());
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert.
|
||||
*/
|
||||
public function testInsertSimple()
|
||||
{
|
||||
$query = Models::get('sqltable')->insert(array('field' => 'value'));
|
||||
$this->assertEquals('INSERT INTO table (field) VALUES (?)', $query->getSql());
|
||||
$this->assertEquals(array('value'), $query->getBinds());
|
||||
}
|
||||
|
||||
public function testInsertMultiple()
|
||||
{
|
||||
$query = Models::get('sqltable')->insert(array('field1' => 'value1', 'field2' => 'value2'), 'table');
|
||||
$this->assertEquals('INSERT INTO table (field1,field2) VALUES (?,?)', $query->getSql());
|
||||
$this->assertEquals(array('value1', 'value2'), $query->getBinds());
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace.
|
||||
*/
|
||||
public function testReplaceSimple()
|
||||
{
|
||||
$query = Models::get('sqltable')->replace(array('field' => 'value'));
|
||||
$this->assertEquals('REPLACE INTO table (field) VALUES (?)', $query->getSql());
|
||||
$this->assertEquals(array('value'), $query->getBinds());
|
||||
}
|
||||
|
||||
public function testReplaceMultiple()
|
||||
{
|
||||
$query = Models::get('sqltable')->replace(array('field1' => 'value1', 'field2' => 'value2'), 'table');
|
||||
$this->assertEquals('REPLACE INTO table (field1,field2) VALUES (?,?)', $query->getSql());
|
||||
$this->assertEquals(array('value1', 'value2'), $query->getBinds());
|
||||
}
|
||||
}
|
|
@ -1,500 +0,0 @@
|
|||
<?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\Modules;
|
||||
use \Module\DatabaseUtils\Query;
|
||||
|
||||
class QueryTests extends \CoreTestAbstract
|
||||
{
|
||||
/**
|
||||
* @var Query
|
||||
*/
|
||||
public $query;
|
||||
|
||||
public $core;
|
||||
|
||||
/**
|
||||
* @before
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
Modules::get('core/databaseutils');
|
||||
$this->query = new Query();
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
$query = new Query('table');
|
||||
$this->assertEquals('table', $query->getTable());
|
||||
}
|
||||
/*
|
||||
* Select
|
||||
*/
|
||||
|
||||
public function testSelectSimple()
|
||||
{
|
||||
$this->query->select()->from('table');
|
||||
$this->assertEquals('SELECT * FROM table', $this->query->getSql());
|
||||
}
|
||||
|
||||
public function testSelectSimpleDefaultTable()
|
||||
{
|
||||
$this->query->setTable('table')->select()->from();
|
||||
$this->assertEquals('SELECT * FROM table', $this->query->getSql());
|
||||
}
|
||||
|
||||
public function testSelectSimpleComboTable()
|
||||
{
|
||||
$this->query->select()->from('table', 'table2');
|
||||
$this->assertEquals('SELECT * FROM table, table2', $this->query->getSql());
|
||||
}
|
||||
|
||||
public function testSelectSimpleAlias()
|
||||
{
|
||||
$this->query->select()->from('table t');
|
||||
$this->assertEquals('SELECT * FROM table t', $this->query->getSql());
|
||||
}
|
||||
|
||||
public function testSelectSimpleComboAlias()
|
||||
{
|
||||
$this->query->select()->from('table t', 'table2 t2');
|
||||
$this->assertEquals('SELECT * FROM table t, table2 t2', $this->query->getSql());
|
||||
}
|
||||
|
||||
public function testSelectSimpleOneField()
|
||||
{
|
||||
$this->query->select('field1')->from('table');
|
||||
$this->assertEquals('SELECT field1 FROM table', $this->query->getSql());
|
||||
}
|
||||
|
||||
public function testSelectSimpleTwoFields()
|
||||
{
|
||||
$this->query->select('field1', 'field2')->from('table');
|
||||
$this->assertEquals('SELECT field1, field2 FROM table', $this->query->getSql());
|
||||
}
|
||||
|
||||
/*
|
||||
* Where
|
||||
*/
|
||||
|
||||
public function testSelectWhere()
|
||||
{
|
||||
$this->query->select()->from('table')->where('field', 'value');
|
||||
$this->assertEquals('SELECT * FROM table WHERE field = ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectWhereLike()
|
||||
{
|
||||
$this->query->select()->from('table')->where('field', 'like', '%value%');
|
||||
$this->assertEquals('SELECT * FROM table WHERE field LIKE ?', $this->query->getSql());
|
||||
$this->assertEquals(array('%value%'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectWhereBetween()
|
||||
{
|
||||
$this->query->select()->from('table')->where('field', 'between', array(2, 4));
|
||||
$this->assertEquals('SELECT * FROM table WHERE field BETWEEN ? AND ?', $this->query->getSql());
|
||||
$this->assertEquals(array(2, 4), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectWhereIn()
|
||||
{
|
||||
$this->query->select()->from('table')->where('field', 'in', array(2, 3, 4));
|
||||
$this->assertEquals('SELECT * FROM table WHERE field IN (?,?,?)', $this->query->getSql());
|
||||
$this->assertEquals(array(2, 3, 4), $this->query->getBinds());
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Make this work!
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
/*public function testSelectWhereInSubQuery(){
|
||||
|
||||
$subQuery = new Query();
|
||||
$subQuery->select()->from('table2')->where('field', 'value');
|
||||
|
||||
$this->query->select()->from('table')->where("field", "in", $subQuery);
|
||||
$this->assertEquals('SELECT * FROM table WHERE field IN (SELECT * FROM table2 WHERE field = ?)', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
}*/
|
||||
|
||||
public function testSelectWhereNot()
|
||||
{
|
||||
$this->query->select()->from('table')->where('field', '<>', 'value');
|
||||
$this->assertEquals('SELECT * FROM table WHERE field <> ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectWhereGreater()
|
||||
{
|
||||
$this->query->select()->from('table')->where('field', '>', 'value');
|
||||
$this->assertEquals('SELECT * FROM table WHERE field > ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectWhereGreaterEqual()
|
||||
{
|
||||
$this->query->select()->from('table')->where('field', '>=', 'value');
|
||||
$this->assertEquals('SELECT * FROM table WHERE field >= ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectWhereSmaller()
|
||||
{
|
||||
$this->query->select()->from('table')->where('field', '<', 'value');
|
||||
$this->assertEquals('SELECT * FROM table WHERE field < ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectWhereSmallerEqual()
|
||||
{
|
||||
$this->query->select()->from('table')->where('field', '<=', 'value');
|
||||
$this->assertEquals('SELECT * FROM table WHERE field <= ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectWhereAnd()
|
||||
{
|
||||
$this->query->select()->from('table')->where('field1', 'value1')->and()->where('field2', 'value2');
|
||||
$this->assertEquals('SELECT * FROM table WHERE field1 = ? AND field2 = ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value1', 'value2'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectWhereAndOpen()
|
||||
{
|
||||
$this->query->select()->from('table')->where('field1', 'value1')->and()->open()->where('field2', 'value2')->or()->where('field3', 'value3')->close();
|
||||
$this->assertEquals('SELECT * FROM table WHERE field1 = ? AND ( field2 = ? OR field3 = ? )', $this->query->getSql());
|
||||
$this->assertEquals(array('value1', 'value2', 'value3'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectWhereOr()
|
||||
{
|
||||
$this->query->select()->from('table')->where('field1', 'value1')->or()->where('field2', 'value2');
|
||||
$this->assertEquals('SELECT * FROM table WHERE field1 = ? OR field2 = ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value1', 'value2'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectWhereOrOpen()
|
||||
{
|
||||
$this->query->select()->from('table')->where('field1', 'value1')->or()->open()->where('field2', 'value2')->and()->where('field3', 'value3')->close();
|
||||
$this->assertEquals('SELECT * FROM table WHERE field1 = ? OR ( field2 = ? AND field3 = ? )', $this->query->getSql());
|
||||
$this->assertEquals(array('value1', 'value2', 'value3'), $this->query->getBinds());
|
||||
}
|
||||
public function testSelectWhereOpen()
|
||||
{
|
||||
$this->query->select()->from('table')
|
||||
->where()->open()->where('field1', 'value1')->and()->where('field2', 'value2')->close()
|
||||
->or()->where('field3', 'value3');
|
||||
$this->assertEquals('SELECT * FROM table WHERE ( field1 = ? AND field2 = ? ) OR field3 = ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value1', 'value2', 'value3'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
/*
|
||||
* Order by
|
||||
*/
|
||||
|
||||
public function testSelectOrderASC()
|
||||
{
|
||||
$this->query->select()->from('table')->order('field');
|
||||
$this->assertEquals('SELECT * FROM table ORDER BY field ASC', $this->query->getSql());
|
||||
}
|
||||
|
||||
public function testSelectOrderDESC()
|
||||
{
|
||||
$this->query->select()->from('table')->order('-field');
|
||||
$this->assertEquals('SELECT * FROM table ORDER BY field DESC', $this->query->getSql());
|
||||
}
|
||||
|
||||
public function testSelectOrderMultiple()
|
||||
{
|
||||
$this->query->select()->from('table')->order('field1', '-field2');
|
||||
$this->assertEquals('SELECT * FROM table ORDER BY field1 ASC, field2 DESC', $this->query->getSql());
|
||||
}
|
||||
|
||||
/*
|
||||
* Limit
|
||||
*/
|
||||
|
||||
public function testSelectLimit()
|
||||
{
|
||||
$this->query->select()->from('table')->limit(5, 10);
|
||||
$this->assertEquals('SELECT * FROM table LIMIT 10, 5', $this->query->getSql());
|
||||
}
|
||||
|
||||
/*
|
||||
* Having
|
||||
*/
|
||||
|
||||
public function testSelectHaving()
|
||||
{
|
||||
$this->query->select()->from('table')->having('field', 'value');
|
||||
$this->assertEquals('SELECT * FROM table HAVING field = ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectHavingLike()
|
||||
{
|
||||
$this->query->select()->from('table')->having('field', 'like', '%value%');
|
||||
$this->assertEquals('SELECT * FROM table HAVING field LIKE ?', $this->query->getSql());
|
||||
$this->assertEquals(array('%value%'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectHavingBetween()
|
||||
{
|
||||
$this->query->select()->from('table')->having('field', 'between', array(2, 4));
|
||||
$this->assertEquals('SELECT * FROM table HAVING field BETWEEN ? AND ?', $this->query->getSql());
|
||||
$this->assertEquals(array(2, 4), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectHavingIn()
|
||||
{
|
||||
$this->query->select()->from('table')->having('field', 'in', array(2, 3, 4));
|
||||
$this->assertEquals('SELECT * FROM table HAVING field IN (?,?,?)', $this->query->getSql());
|
||||
$this->assertEquals(array(2, 3, 4), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectHavingNot()
|
||||
{
|
||||
$this->query->select()->from('table')->having('field', '<>', 'value');
|
||||
$this->assertEquals('SELECT * FROM table HAVING field <> ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectHavingGreater()
|
||||
{
|
||||
$this->query->select()->from('table')->having('field', '>', 'value');
|
||||
$this->assertEquals('SELECT * FROM table HAVING field > ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectHavingGreaterEqual()
|
||||
{
|
||||
$this->query->select()->from('table')->having('field', '>=', 'value');
|
||||
$this->assertEquals('SELECT * FROM table HAVING field >= ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectHavingSmaller()
|
||||
{
|
||||
$this->query->select()->from('table')->having('field', '<', 'value');
|
||||
$this->assertEquals('SELECT * FROM table HAVING field < ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectHavingSmallerEqual()
|
||||
{
|
||||
$this->query->select()->from('table')->having('field', '<=', 'value');
|
||||
$this->assertEquals('SELECT * FROM table HAVING field <= ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectHavingAnd()
|
||||
{
|
||||
$this->query->select()->from('table')->having('field1', 'value1')->and()->where('field2', 'value2');
|
||||
$this->assertEquals('SELECT * FROM table HAVING field1 = ? AND field2 = ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value1', 'value2'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectHavingAndOpen()
|
||||
{
|
||||
$this->query->select()->from('table')->having('field1', 'value1')->and()->open()->where('field2', 'value2')->or()->where('field3', 'value3')->close();
|
||||
$this->assertEquals('SELECT * FROM table HAVING field1 = ? AND ( field2 = ? OR field3 = ? )', $this->query->getSql());
|
||||
$this->assertEquals(array('value1', 'value2', 'value3'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectHavingOr()
|
||||
{
|
||||
$this->query->select()->from('table')->having('field1', 'value1')->or()->where('field2', 'value2');
|
||||
$this->assertEquals('SELECT * FROM table HAVING field1 = ? OR field2 = ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value1', 'value2'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testSelectHavingOrOpen()
|
||||
{
|
||||
$this->query->select()->from('table')->having('field1', 'value1')->or()->open()->where('field2', 'value2')->and()->where('field3', 'value3')->close();
|
||||
$this->assertEquals('SELECT * FROM table HAVING field1 = ? OR ( field2 = ? AND field3 = ? )', $this->query->getSql());
|
||||
$this->assertEquals(array('value1', 'value2', 'value3'), $this->query->getBinds());
|
||||
}
|
||||
public function testSelectHavingOpen()
|
||||
{
|
||||
$this->query->select()->from('table')
|
||||
->having()->open()->where('field1', 'value1')->and()->where('field2', 'value2')->close()
|
||||
->or()->where('field3', 'value3');
|
||||
$this->assertEquals('SELECT * FROM table HAVING ( field1 = ? AND field2 = ? ) OR field3 = ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value1', 'value2', 'value3'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
/*
|
||||
* Update
|
||||
*/
|
||||
|
||||
public function testUpdateSimple()
|
||||
{
|
||||
$this->query->setTable('table')->update()->set(array('field' => 'value'));
|
||||
$this->assertEquals('UPDATE table SET field=?', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testUpdateMultiple()
|
||||
{
|
||||
$this->query->setTable('table')->update()->set(array('field1' => 'value1', 'field2' => 'value2'));
|
||||
$this->assertEquals('UPDATE table SET field1=?, field2=?', $this->query->getSql());
|
||||
$this->assertEquals(array('value1', 'value2'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete
|
||||
*/
|
||||
|
||||
public function testDeleteSimple()
|
||||
{
|
||||
$this->query->setTable('table')->delete();
|
||||
$this->assertEquals('DELETE FROM table', $this->query->getSql());
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert
|
||||
*/
|
||||
|
||||
public function testInsertSimple()
|
||||
{
|
||||
$this->query->insert(array('field' => 'value'), 'table');
|
||||
$this->assertEquals('INSERT INTO table (field) VALUES (?)', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testInsertMultiple()
|
||||
{
|
||||
$this->query->insert(array('field1' => 'value1', 'field2' => 'value2'), 'table');
|
||||
$this->assertEquals('INSERT INTO table (field1,field2) VALUES (?,?)', $this->query->getSql());
|
||||
$this->assertEquals(array('value1', 'value2'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
/*
|
||||
* Replace
|
||||
*/
|
||||
|
||||
public function testReplaceSimple()
|
||||
{
|
||||
$this->query->setTable('table')->replace(array('field' => 'value'));
|
||||
$this->assertEquals('REPLACE INTO table (field) VALUES (?)', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testReplaceMultiple()
|
||||
{
|
||||
$this->query->setTable('table')->replace(array('field1' => 'value1', 'field2' => 'value2'));
|
||||
$this->assertEquals('REPLACE INTO table (field1,field2) VALUES (?,?)', $this->query->getSql());
|
||||
$this->assertEquals(array('value1', 'value2'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
/*
|
||||
* Joins
|
||||
*/
|
||||
|
||||
public function testJoin()
|
||||
{
|
||||
$this->query->select()->from('table')->join('other')->on('field', 'value')->where('field', 'value2');
|
||||
$this->assertEquals('SELECT * FROM table JOIN other ON field = ? WHERE field = ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value', 'value2'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testJoinLeft()
|
||||
{
|
||||
$this->query->select()->from('table')->left_join('other')->on('field', 'value')->where('field', 'value2');
|
||||
$this->assertEquals('SELECT * FROM table LEFT JOIN other ON field = ? WHERE field = ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value', 'value2'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testJoinRight()
|
||||
{
|
||||
$this->query->select()->from('table')->right_join('other')->on('field', 'value')->where('field', 'value2');
|
||||
$this->assertEquals('SELECT * FROM table RIGHT JOIN other ON field = ? WHERE field = ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value', 'value2'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testJoinFull()
|
||||
{
|
||||
$this->query->select()->from('table')->full_join('other')->on('field', 'value')->where('field', 'value2');
|
||||
$this->assertEquals('SELECT * FROM table FULL JOIN other ON field = ? WHERE field = ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value', 'value2'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testJoinAdvanced()
|
||||
{
|
||||
$this->query->select()->from('table')
|
||||
->left_join('other_a')->on('field', 'value')
|
||||
->right_join('other_b')->on('field', 'value2')
|
||||
->full_join('other_c')->on('field', 'value3')
|
||||
->where('field', 'value4');
|
||||
$this->assertEquals('SELECT * FROM table LEFT JOIN other_a ON field = ? RIGHT JOIN other_b ON field = ? FULL JOIN other_c ON field = ? WHERE field = ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value', 'value2', 'value3', 'value4'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
/**
|
||||
* Inline joins.
|
||||
*/
|
||||
public function testJoinInline()
|
||||
{
|
||||
$this->query->select()->from('table t', 'other o')->where('o.field', 'value');
|
||||
$this->assertEquals('SELECT * FROM table t, other o WHERE o.field = ?', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testJoinInlineAdvanced()
|
||||
{
|
||||
$this->query->select()->from('table t', 'other o')->where('o.field = t.field');
|
||||
$this->assertEquals('SELECT * FROM table t, other o WHERE o.field = t.field', $this->query->getSql());
|
||||
$this->assertEmpty($this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testJoinAllInOne()
|
||||
{
|
||||
$this->query->select()
|
||||
->from('table t', 'other o')
|
||||
->left_join('third th')->on('th.field = o.field')
|
||||
->where('o.field = t.field')
|
||||
->and()->where('t.thing', '>', 25);
|
||||
$this->assertEquals('SELECT * FROM table t, other o LEFT JOIN third th ON th.field = o.field WHERE o.field = t.field AND t.thing > ?', $this->query->getSql());
|
||||
$this->assertEquals(array(25), $this->query->getBinds());
|
||||
}
|
||||
|
||||
/**
|
||||
* Group by.
|
||||
*/
|
||||
public function testSelectGroupBy()
|
||||
{
|
||||
$this->query->groupBy('field1', 'field2');
|
||||
$this->assertEquals('GROUP BY field1, field2', $this->query->getSql());
|
||||
}
|
||||
}
|
|
@ -126,13 +126,13 @@ class routerTest extends CoreTestAbstract
|
|||
|
||||
Router::setPath('e/function_b/c');
|
||||
Router::route(false);
|
||||
$this->assertEquals(null, Router::getMatches()['controller']);
|
||||
$this->assertFalse(isset(Router::getMatches()['controller']));
|
||||
$this->assertEquals('function_b', Router::getMatches()['function']);
|
||||
|
||||
Router::setPath('b/b');
|
||||
Router::route(false);
|
||||
$this->assertEquals(null, Router::getMatches()['controller']);
|
||||
$this->assertEquals(null, Router::getMatches()['function']);
|
||||
$this->assertFalse(isset(Router::getMatches()['controller']));
|
||||
$this->assertFalse(isset(Router::getMatches()['function']));
|
||||
|
||||
Router::setPath('a/b');
|
||||
Router::route(false);
|
||||
|
|
|
@ -29,9 +29,10 @@
|
|||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
use \FuzeWorks\Events;
|
||||
use \FuzeWorks\Router;
|
||||
use \FuzeWorks\EventPriority;
|
||||
use FuzeWorks\Events;
|
||||
use FuzeWorks\Router;
|
||||
use FuzeWorks\EventPriority;
|
||||
use FuzeWorks\Layout;
|
||||
|
||||
/**
|
||||
* Class RouterLoadCallableEventTest.
|
||||
|
|
Loading…
Reference in New Issue