aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilly Micieli <micieli@laposte.net>2019-06-06 20:03:25 +0200
committerWilly Micieli <micieli@laposte.net>2019-06-06 20:03:25 +0200
commitb66185948ddb2d9a9fbaedae8fc73fe92d36c6e8 (patch)
tree319f23159302c088e6bbac1690fc99d6fa06eda1
parentf282bd0241cb87ba6ca42997275d91eb14b60fbb (diff)
downloadimperium-b66185948ddb2d9a9fbaedae8fc73fe92d36c6e8.zip
imperium-b66185948ddb2d9a9fbaedae8fc73fe92d36c6e8.tar.gz
start refactoring
-rw-r--r--.env.example1
-rw-r--r--Makefile117
-rw-r--r--composer.json5
-rw-r--r--config/db.example.yaml10
-rw-r--r--db/migrations/20190409122351_routestable.php40
-rw-r--r--db/migrations/20190424135413_users.php33
-rw-r--r--db/seeds/UsersSeed.php20
-rw-r--r--dbs/migrations/20190409122351_routestable.php40
-rw-r--r--dbs/migrations/20190418153334_users.php40
-rw-r--r--helpers/helpers.php369
-rw-r--r--imperium/App.php98
-rw-r--r--imperium/Bases/Base.php65
-rw-r--r--imperium/Command/AddRoutes.php42
-rw-r--r--imperium/Command/App.php17
-rw-r--r--imperium/Command/FindRoute.php26
-rw-r--r--imperium/Command/RemoveRoutes.php52
-rw-r--r--imperium/Command/RouteInfo.php25
-rw-r--r--imperium/Command/RoutesList.php4
-rw-r--r--imperium/Command/UpdateRoutes.php171
-rw-r--r--imperium/Config/Config.php12
-rw-r--r--imperium/Connexion/Connect.php98
-rw-r--r--imperium/Exception/Kedavra.php13
-rw-r--r--imperium/Management.php27
-rw-r--r--imperium/Model/Model.php31
-rw-r--r--imperium/Routing/Route.php119
-rw-r--r--imperium/Routing/Router.php80
-rw-r--r--imperium/Tables/Column.php14
-rw-r--r--imperium/Tables/Table.php49
-rw-r--r--imperium/Users/Users.php6
-rw-r--r--imperium/Validator/Validator.php94
-rw-r--r--imperium/View/View.php2
-rw-r--r--logs/.gitignore2
-rw-r--r--phinx.php6
-rw-r--r--phpunit.xml2
-rw-r--r--tests/RouterTest.php66
-rw-r--r--tests/app/AppTest.php53
-rw-r--r--tests/collection/CollectionTest.php293
-rw-r--r--tests/config/ConfigTest.php44
-rw-r--r--tests/csrf/CsrfTest.php65
-rw-r--r--tests/dir/DirTest.php25
-rw-r--r--tests/flash/FlashTest.php66
-rw-r--r--tests/form/FormTest.php712
-rw-r--r--tests/hash/HashTest.php29
-rw-r--r--tests/mysql/app/AppTest.php812
-rw-r--r--tests/mysql/base/BaseTest.php98
-rw-r--r--tests/mysql/connect/ConnectTest.php52
-rw-r--r--tests/mysql/dumper/DumperTest.php15
-rw-r--r--tests/mysql/imperium/ImperiumTest.php284
-rw-r--r--tests/mysql/import/ImportTest.php19
-rw-r--r--tests/mysql/json/JsonTest.php90
-rw-r--r--tests/mysql/model/ModelTest.php325
-rw-r--r--tests/mysql/query/QueryTest.php135
-rw-r--r--tests/mysql/table/TableTest.php333
-rw-r--r--tests/mysql/users/UsersTest.php37
-rw-r--r--tests/pgsql/app/AppTest.php818
-rw-r--r--tests/pgsql/base/BaseTest.php109
-rw-r--r--tests/pgsql/connect/ConnectTest.php52
-rw-r--r--tests/pgsql/dumper/DumperTest.php15
-rw-r--r--tests/pgsql/imperium/ImperiumTest.php273
-rw-r--r--tests/pgsql/import/ImportTest.php19
-rw-r--r--tests/pgsql/json/JsonTest.php90
-rw-r--r--tests/pgsql/model/ModelTest.php333
-rw-r--r--tests/pgsql/query/QueryTest.php137
-rw-r--r--tests/pgsql/table/TableTest.php331
-rw-r--r--tests/pgsql/users/UsersTest.php37
-rw-r--r--tests/query/QueryTest.php265
-rw-r--r--tests/router/RouterTest.php52
-rw-r--r--tests/session/SessionTest.php44
-rw-r--r--tests/sqlite/app/AppTest.php811
-rw-r--r--tests/sqlite/base/BaseTest.php107
-rw-r--r--tests/sqlite/connect/ConnectTest.php52
-rw-r--r--tests/sqlite/dumper/DumperTest.php15
-rw-r--r--tests/sqlite/imperium/ImperiumTest.php245
-rw-r--r--tests/sqlite/import/ImportTest.php19
-rw-r--r--tests/sqlite/json/JsonTest.php90
-rw-r--r--tests/sqlite/model/ModelTest.php358
-rw-r--r--tests/sqlite/query/QueryTest.php131
-rw-r--r--tests/sqlite/table/TableTest.php291
-rw-r--r--tests/sqlite/users/UsersTest.php37
-rw-r--r--tests/trans/TransTest.php19
80 files changed, 1037 insertions, 8996 deletions
diff --git a/.env.example b/.env.example
index de22563..e69de29 100644
--- a/.env.example
+++ b/.env.example
@@ -1 +0,0 @@
-driver=mysql \ No newline at end of file
diff --git a/Makefile b/Makefile
index ebd3294..9f8e980 100644
--- a/Makefile
+++ b/Makefile
@@ -1,112 +1,15 @@
-.PHONY:mysql pgsql sqlite router form views cover clean dbs seed migrate disable enable send dir config session flash app trans csrf hash collection
+.PHONY: migrate seed router coverage
-BASE=zen
+P=./vendor/bin/phinx
+UNIT=./vendor/bin/phpunit
+C=--coverage-html coverage
-UNIT="./vendor/bin/phpunit"
-MYSQL_PASSWORD=root
-COVERAGE='--coverage-html '
+all: migrate router
+migrate:
+ $(P) $@ -e development
-ifeq (phinx,$(firstword $(MAKECMDGOALS)))
- # use the rest as arguments for "run"
- PHINX := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
- # ...and turn them into do-nothing targets
- $(eval $(PHINX):;@:)
-endif
+coverage:
+ php -S localhost:8000 -t $@
-ifeq (cover,$(firstword $(MAKECMDGOALS)))
- # use the rest as arguments for "run"
- DIR := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
- # ...and turn them into do-nothing targets
- $(eval $(DIR):;@:)
-endif
-
-ifeq (send,$(firstword $(MAKECMDGOALS)))
- # use the rest as arguments for "run"
- COMMIT := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
- # ...and turn them into do-nothing targets
- $(eval $(COMMIT):;@:)
-endif
-
-all: vendor mysql pgsql sqlite router form dir config session flash app trans csrf hash collection
-
-mysql:
- @install -D $@.yaml config/db.yaml
- @php shaolin db:seed
- @$(UNIT) tests/$@ $(COVERAGE) coverage/$@
-pgsql: seed
- @install -D $@.yaml config/db.yaml
- @$(UNIT) tests/$@ $(COVERAGE) coverage/$@
-sqlite: seed
- @install -D $@.yaml config/db.yaml
- @$(UNIT) tests/$@ $(COVERAGE) coverage/$@
router:
- @$(UNIT) tests/$@ $(COVERAGE) coverage/$@
-flash:
- @$(UNIT) tests/$@ $(COVERAGE) coverage/$@
-form:
- @install -D mysql.yaml config/db.yaml
- @$(UNIT) tests/$@ $(COVERAGE) coverage/$@
-dir:
- @$(UNIT) tests/$@ $(COVERAGE) coverage/$@
-config:
- @$(UNIT) tests/$@ $(COVERAGE) coverage/$@
-app:
- @$(UNIT) tests/$@
-seed: dbs migrate
-session:
- @$(UNIT) tests/$@ $(COVERAGE) coverage/$@
-csrf:
- @$(UNIT) tests/$@ $(COVERAGE) coverage/$@
-trans:
- @$(UNIT) tests/$@ $(COVERAGE) coverage/$@
-hash:
- @$(UNIT) tests/$@ $(COVERAGE) coverage/$@
-collection:
- @install -D mysql.yaml config/db.yaml
- @$(UNIT) tests/$@ $(COVERAGE) coverage/$@
-send: all
- git add .
- git commit -m "$(COMMIT)" -n
- git push origin --all
- git push origin --tags
-disable:
- sudo install -D xdebug_d.ini /etc/php/conf.d/xdebug.ini
-enable:
- sudo install -D xdebug.ini /etc/php/conf.d/xdebug.ini
-help: ## Display the help
- @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
-
-vendor: ## Configure the app
- @composer install
-
-migrate: migrate_mysql migrate_pgsql migrate_sqlite ## Run all migrations
-
-serve: ## Start the development server
- @clear
- @php -S localhost:8000 -d display_errors=1 -t public
-cover: ## Start a server to display the coverage
- @clear
- @php -S localhost:3000 -t coverage/$(DIR)
-
-phinx: ## Create migration and seed
- @vendor/bin/phinx create $(PHINX)table
- @vendor/bin/phinx seed:create $(PHINX)Seeds
-
-migrate_pgsql: ## Seed postgresql database
- @vendor/bin/phinx migrate
- @vendor/bin/phinx seed:run
-
-migrate_mysql: ## Seed mysql database
- @vendor/bin/phinx migrate
- @vendor/bin/phinx seed:run
-
-migrate_sqlite: ## Seed sqlite database
- @vendor/bin/phinx migrate
- @vendor/bin/phinx seed:run
-
-dbs: clean ## Create all databases
- @psql -c "create database $(BASE);" -U postgres
- @mysql -uroot -p$(MYSQL_PASSWORD) -e "CREATE DATABASE $(BASE);"
-clean: ## Remove all databases
- psql -c "DROP DATABASE IF EXISTS $(BASE);" -U postgres
- mysql -uroot -p$(MYSQL_PASSWORD) -e "DROP DATABASE IF EXISTS $(BASE);"
+ $(UNIT) $(C) \ No newline at end of file
diff --git a/composer.json b/composer.json
index 953e085..e47004d 100644
--- a/composer.json
+++ b/composer.json
@@ -34,7 +34,8 @@
"swiftmailer/swiftmailer": "^6.1",
"psr/http-server-middleware": "^1.0",
"symfony/console": "^4.2",
- "ext-gettext": "*"
+ "ext-gettext": "*",
+ "ext-PDO": "*"
},
"autoload-dev": {
"psr-4": {
@@ -44,7 +45,7 @@
"autoload": {
"psr-4": {
"Imperium\\": "imperium/",
- "App\\": "app/"
+ "________________________________________________________\\": "app/"
},
"files": [
"helpers/helpers.php"
diff --git a/config/db.example.yaml b/config/db.example.yaml
deleted file mode 100644
index d99d297..0000000
--- a/config/db.example.yaml
+++ /dev/null
@@ -1,10 +0,0 @@
-driver: mysql
-base: zen
-username: root
-password: root
-dump: 'db/dump'
-host: 'localhost'
-hidden_tables: ['phinxlog']
-hidden_bases: []
-debug: true
-port: 3306 \ No newline at end of file
diff --git a/db/migrations/20190409122351_routestable.php b/db/migrations/20190409122351_routestable.php
deleted file mode 100644
index 54ebc97..0000000
--- a/db/migrations/20190409122351_routestable.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-
-use Phinx\Migration\AbstractMigration;
-
-class Routestable extends AbstractMigration
-{
- /**
- * Change Method.
- *
- * Write your reversible migrations using this method.
- *
- * More information on writing migrations is available here:
- * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
- *
- * The following commands can be used in this method and Phinx will
- * automatically reverse them when rolling back:
- *
- * createTable
- * renameTable
- * addColumn
- * renameColumn
- * addIndex
- * addForeignKey
- *
- * Remember to call "create()" or "update()" and NOT "save()" when working
- * with the Table class.
- */
- public function change()
- {
- $this->table('routes')
- ->addColumn('name','string')
- ->addColumn('url','string')
- ->addColumn('controller','string')
- ->addColumn('action','string')
- ->addColumn('method','string')
- ->addIndex(['name','url'],['unique' => true])
- ->create();
- }
-}
diff --git a/db/migrations/20190424135413_users.php b/db/migrations/20190424135413_users.php
deleted file mode 100644
index 832dbd8..0000000
--- a/db/migrations/20190424135413_users.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-
-use Phinx\Migration\AbstractMigration;
-
-class Users extends AbstractMigration
-{
- /**
- * Change Method.
- *
- * Write your reversible migrations using this method.
- *
- * More information on writing migrations is available here:
- * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
- *
- * The following commands can be used in this method and Phinx will
- * automatically reverse them when rolling back:
- *
- * createTable
- * renameTable
- * addColumn
- * renameColumn
- * addIndex
- * addForeignKey
- *
- * Remember to call "create()" or "update()" and NOT "save()" when working
- * with the Table class.
- */
- public function change()
- {
-
- }
-}
diff --git a/db/seeds/UsersSeed.php b/db/seeds/UsersSeed.php
deleted file mode 100644
index b198011..0000000
--- a/db/seeds/UsersSeed.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-
-use Phinx\Seed\AbstractSeed;
-
-class UsersSeed extends AbstractSeed
-{
- /**
- * Run Method.
- *
- * Write your database seeder using this method.
- *
- * More information on writing seeders is available here:
- * http://docs.phinx.org/en/latest/seeding.html
- */
- public function run()
- {
- $this->table('users')->create();
- }
-}
diff --git a/dbs/migrations/20190409122351_routestable.php b/dbs/migrations/20190409122351_routestable.php
deleted file mode 100644
index 54ebc97..0000000
--- a/dbs/migrations/20190409122351_routestable.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-
-use Phinx\Migration\AbstractMigration;
-
-class Routestable extends AbstractMigration
-{
- /**
- * Change Method.
- *
- * Write your reversible migrations using this method.
- *
- * More information on writing migrations is available here:
- * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
- *
- * The following commands can be used in this method and Phinx will
- * automatically reverse them when rolling back:
- *
- * createTable
- * renameTable
- * addColumn
- * renameColumn
- * addIndex
- * addForeignKey
- *
- * Remember to call "create()" or "update()" and NOT "save()" when working
- * with the Table class.
- */
- public function change()
- {
- $this->table('routes')
- ->addColumn('name','string')
- ->addColumn('url','string')
- ->addColumn('controller','string')
- ->addColumn('action','string')
- ->addColumn('method','string')
- ->addIndex(['name','url'],['unique' => true])
- ->create();
- }
-}
diff --git a/dbs/migrations/20190418153334_users.php b/dbs/migrations/20190418153334_users.php
deleted file mode 100644
index a3f2878..0000000
--- a/dbs/migrations/20190418153334_users.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-
-use Phinx\Migration\AbstractMigration;
-
-class Users extends AbstractMigration
-{
- /**
- * Change Method.
- *
- * Write your reversible migrations using this method.
- *
- * More information on writing migrations is available here:
- * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
- *
- * The following commands can be used in this method and Phinx will
- * automatically reverse them when rolling back:
- *
- * createTable
- * renameTable
- * addColumn
- * renameColumn
- * addIndex
- * addForeignKey
- *
- * Remember to call "create()" or "update()" and NOT "save()" when working
- * with the Table class.
- */
- public function change()
- {
- $this->table('users')
- ->addColumn('username','string')
- ->addColumn('lastname','string')
- ->addColumn('email','string')
- ->addColumn('password','string')
- ->addIndex(['username','email'],['unique' => true])
- ->addTimestamps()
- ->create();
- }
-}
diff --git a/helpers/helpers.php b/helpers/helpers.php
index c041bac..f3ef0be 100644
--- a/helpers/helpers.php
+++ b/helpers/helpers.php
@@ -8,6 +8,7 @@ use Imperium\Config\Config;
use Imperium\Debug\Dumper;
use Imperium\Directory\Dir;
use Imperium\Dump\Dump;
+use Imperium\Exception\Kedavra;
use Imperium\Flash\Flash;
use Imperium\Routing\Router;
use Imperium\Security\Csrf\Csrf;
@@ -82,6 +83,9 @@ define('DELETE',22);
define('UPDATE',23);
define('INSERT',24);
+define('MYSQL_PORT',3306);
+define('POSTGRESQL_PORT',5432);
+
define('DISPLAY_TABLE',25);
define('DISPLAY_ARTICLE',26);
define('DISPLAY_CONTRIBUTORS',27);
@@ -96,7 +100,35 @@ define('QUERY_SECOND_TABLE','second_table');
define('QUERY_SECOND_PARAM','second_param');
define('QUERY_ORDER_KEY','key');
define('QUERY_ORDER','order');
+define('METHOD_SUPPORTED',['GET','POST','PUT','DELETE']);
+
+
+define('DB_DRIVER','driver');
+define('DB_NAME','base');
+define('DB_USERNAME','username');
+define('DB_PASSWORD','password');
+define('DB_HIDDEN_TABLES','hidden_tables');
+define('DISPLAY_BUGS','debug');
+
+if (not_exist('db'))
+{
+
+ /**
+ *
+ * get db config value
+ *
+ * @param string $key
+ *
+ * @return mixed
+ *
+ * @throws Kedavra
+ */
+ function db(string $key)
+ {
+ return config('db',$key);
+ }
+}
if (not_exist('redirect'))
{
/**
@@ -111,7 +143,7 @@ if (not_exist('redirect'))
* @throws Exception
*
*/
- function redirect(string $route_name,string $message ='',bool $success = true)
+ function redirect(string $route_name,string $message ='',bool $success = true): RedirectResponse
{
if (def($message))
{
@@ -122,6 +154,7 @@ if (not_exist('redirect'))
}
}
+
if (not_exist('current_user'))
{
/**
@@ -146,16 +179,29 @@ if (not_exist('route'))
* Get a route name
*
* @param string $name
- * @param string $method
- *
+ * @param array $args
* @return string
*
* @throws Exception
- *
*/
- function route(string $name,string $method = GET): string
+ function route(string $name,array $args = []): string
{
- return name($name,$method);
+ $x = app()->route()->query()->mode(SELECT)->from('routes')->where('name',EQUAL,$name)->use_fetch()->get();
+ if (def($args))
+ {
+ $url = rtrim(str_replace(stristr($x->url,':'),'',$x->url),'/');
+
+ foreach ($args as $v)
+ {
+ if (is_string($v))
+ append($url,"/$v");
+ else
+ append($url,'/'.$v);
+ }
+ return $url;
+
+ }
+ return $x->url;
}
}
@@ -449,7 +495,7 @@ if (not_exist('config'))
*
* @return mixed
*
- * @throws Exception
+ * @throws Kedavra
*
*/
function config(string $file,$key)
@@ -765,14 +811,14 @@ if (not_exist('true_or_false'))
{
case MYSQL:
return rand(0,1);
- break;
+ break;
case POSTGRESQL:
case SQLITE:
return rand(0,1) === 1 ? 'TRUE' : 'FALSE';
- break;
+ break;
default:
return '';
- break;
+ break;
}
}
@@ -798,6 +844,36 @@ if (not_exist('quote'))
}
}
+if (! function_exists('decrypt')) {
+ /**
+ * Decrypt the given value.
+ *
+ * @param string $value
+ * @param bool $unserialize
+ * @return mixed
+ * @throws Exception
+ */
+ function decrypt($value, $unserialize = true)
+ {
+ return app()->decrypt($value, $unserialize);
+ }
+}
+
+if (! not_exist('encrypt')) {
+ /**
+ * Encrypt the given value.
+ *
+ * @param mixed $value
+ * @param bool $serialize
+ * @return string
+ * @throws Exception
+ */
+ function encrypt($value, $serialize = true)
+ {
+ return app()->encrypt($value, $serialize);
+ }
+}
+
if (not_exist('app'))
{
/**
@@ -812,7 +888,8 @@ if (not_exist('app'))
*/
function app(): App
{
- return new App();
+ return new App();
+
}
}
@@ -910,7 +987,7 @@ if (not_exist('equal'))
*
* @return bool
*
- * @throws Exception
+ * @throws Kedavra
*
*/
function equal($parameter, $expected,$run_exception = false,string $message = ''): bool
@@ -993,7 +1070,7 @@ if (not_exist('is_false'))
*
* @return bool
*
- * @throws Exception
+ * @throws Kedavra
*
*/
function is_false($data,bool $run_exception = false,string $message =''): bool
@@ -1020,7 +1097,7 @@ if (not_exist('is_true'))
*
* @return bool
*
- * @throws Exception
+ * @throws Kedavra
*
*/
function is_true($data,bool $run_exception = false,string $message =''): bool
@@ -1029,7 +1106,7 @@ if (not_exist('is_true'))
$x = $data === true;
if ($run_exception && $x)
- throw new Exception($message);
+ throw new Kedavra($message);
return $x;
@@ -1051,7 +1128,7 @@ if (not_exist('different'))
*
* @return bool
*
- * @throws Exception
+ * @throws
*
*/
function different($parameter,$expected,$run_exception = false,string $message = ''): bool
@@ -1220,6 +1297,27 @@ if (not_exist('edit'))
}
}
+if (not_exist('route_name'))
+{
+ /**
+ *
+ * Display a route name
+ *
+ * @param string $name
+ * @param string $method
+ *
+ * @return string
+ *
+ * @throws Exception
+ *
+ */
+ function route_name(string $name,string $method = GET): string
+ {
+ $x = route($name,$method);
+ return $x->name;
+
+ }
+}
if(not_exist('navbar'))
{
/**
@@ -1276,7 +1374,7 @@ if(not_exist('navbar'))
$html.=' <li class="nav-item"><a class="nav-link" href="'.route($logout_route).'">'.strtoupper($logout_text).'</a></li>';
}
- }else{
+ }else{
$x = collection(explode('@',$file->get('login')));
@@ -2051,11 +2149,76 @@ if(not_exist('routes'))
function routes(OutputInterface $output,array $routes): void
{
-
- if (app()->table_exist(Router::ROUTES))
+ if ( def(request()->server->get('TMUX')))
{
if (def($routes))
{
+ $output->write("+----------+--------------------+-----------------------+-----------------------+-----------------------+\n");
+
+ foreach ($routes as $route)
+ {
+
+ $name = "<fg=blue;options=bold>$route->name</>";
+
+ $url = "<fg=magenta;options=bold>$route->url</>";
+ $controller = "<fg=green;options=bold>$route->controller</>";
+ $action = "<fg=yellow;options=bold>$route->action</>";
+ $method = "<fg=cyan;options=bold>$route->method</>";
+
+ if (length($route->method) == 6)
+ $output->write("| $method ");
+ elseif(length($route->method) == 4)
+ $output->write("| $method ");
+ elseif(length($route->method) == 3)
+ $output->write("| $method ");
+
+
+ if (length($route->name) < 5)
+ $output->write("| $name\t\t|");
+
+ elseif(length($route->name) > 10)
+ $output->write("| $name\t|");
+ else
+ $output->write("| $name\t\t|");
+
+
+ if (length($route->url) < 5)
+ $output->write(" $url\t\t\t|");
+ elseif(length($route->url) < 12)
+ $output->write(" $url\t\t|");
+ elseif(length($route->url)> 18 )
+ $output->write(" $url\t|");
+ else
+ $output->write(" $url\t|");
+
+
+ if (length($route->controller) < 7)
+ $output->write(" $controller\t\t|");
+ elseif (length($route->controller) < 10)
+ $output->write(" $controller\t|");
+ elseif (length($route->controller) > 10 && length($route->controller) < 15)
+ $output->write(" $controller\t|");
+ elseif (length($route->controller)> 15)
+ $output->write(" $controller\t|");
+ else
+ $output->write(" $controller\t|");
+
+ if (length($route->action) < 5)
+ $output->write(" $action\t\t\t|\n");
+ elseif(length($route->action) < 10)
+ $output->write(" $action\t\t|\n");
+ elseif(length($route->action) > 12)
+ $output->write(" $action\t|\n");
+ else
+ $output->write(" $action\t|\n");
+ $output->write("+----------+--------------------+-----------------------+-----------------------+-----------------------+\n");
+ }
+ }else{
+ $output->write("<error>We have not found routes</error>\n");
+ }
+ }else{
+ if (def($routes))
+ {
$output->write("+---------------+-------------------------------+---------------------------------------+---------------------------------------+-------------------------------+\n");
foreach ($routes as $route)
@@ -2071,9 +2234,9 @@ if(not_exist('routes'))
if (length($route->method) >4 )
- $output->write("| $method\t");
+ $output->write("| $method\t");
else
- $output->write("| $method\t\t");
+ $output->write("| $method\t\t");
if (length($route->name) < 5)
$output->write("| $name\t\t\t\t|");
@@ -2090,8 +2253,8 @@ if(not_exist('routes'))
$output->write(" $url\t\t\t\t|");
elseif(length($route->url)> 18 )
$output->write(" $url\t\t|");
- else
- $output->write(" $url\t\t\t|");
+ else
+ $output->write(" $url\t\t\t|");
if (length($route->controller) < 5)
$output->write(" $controller\t\t\t\t\t|");
@@ -2109,19 +2272,17 @@ if(not_exist('routes'))
elseif(length($route->action) < 10)
$output->write(" $action\t\t\t|\n");
elseif(length($route->action) > 12)
- $output->write(" $action\t\t|\n");
+ $output->write(" $action\t\t|\n");
else
- $output->write(" $action\t\t\t|\n");
+ $output->write(" $action\t\t\t|\n");
$output->write("+---------------+-------------------------------+---------------------------------------+---------------------------------------+-------------------------------+\n");
- }
+ }
}else{
- $output->write("<error>No routes was found</error>\n");
+ $output->write("<error>We have not found routes</error>\n");
}
-
- }else{
- $output->write("<error>The routes table was not fond</error>\n");
}
+
}
}
@@ -2616,60 +2777,6 @@ if (not_exist('is_admin'))
return false;
}
}
-if (not_exist('name'))
-{
- /**
- *
- * Return a route url by use it's name
- *
- * @param string $name The route name
- * @param string $method The route method
- *
- * @return string
- *
- * @throws Exception
- */
- function name(string $name,string $method = GET): string
- {
- $x = app()->model()->query()->from(Router::ROUTES)->mode(SELECT)->where('name',EQUAL,$name)->and('method',EQUAL,$method)->get();
- $host = \request()->getHost();
- foreach ($x as $route)
- {
- if (https())
- {
- return equal($route->url,'/') ? "https://$host" : "https://$host$route->url";
- }else{
- return equal($route->url,'/') ? "http://$host" : "http://$host$route->url";
- }
- }
- throw new Exception("The $name route was not found");
- }
-}
-
-if (not_exist('route_name'))
-{
- /**
- *
- * Display a route name
- *
- * @param string $name
- * @param string $method
- *
- * @return string
- *
- * @throws Exception
- *
- */
- function route_name(string $name,string $method = GET): string
- {
- $x = app()->model()->query()->from(Router::ROUTES)->mode(SELECT)->where('name',EQUAL,$name)->and('method',EQUAL,$method)->get();
- foreach ($x as $route)
- return $route->name;
-
- throw new Exception("The $name route name was not found");
- }
-}
-
if (not_exist('css'))
{
@@ -2759,6 +2866,14 @@ if (not_exist('server'))
}
}
+if (not_exist('phinx'))
+{
+ function phinx()
+ {
+
+ d(\request()->server->all());
+ }
+}
if (not_exist('post'))
{
/**
@@ -2825,7 +2940,6 @@ if (not_exist('collation'))
$connexion = $connect;
-
if($connexion->sqlite())
return $collation->collection();
@@ -3496,14 +3610,14 @@ if (not_exist('not_in'))
*
* @method not_in
*
- * @param array $array The array
- * @param mixed $value The value
- * @param bool $run_exception To run exception
- * @param string $message The exception message
+ * @param array $array The array
+ * @param mixed $value The value
+ * @param bool $run_exception To run exception
+ * @param string $message The exception message
*
* @return bool
*
- * @throws Exception
+ * @throws Kedavra
*
*/
function not_in(array $array, $value, bool $run_exception = false, string $message = ''): bool
@@ -3534,7 +3648,7 @@ if (not_exist('dumper'))
* @throws Exception
*
*/
- function dumper(bool $base, array $tables): bool
+ function dumper(bool $base, array $tables=[]): bool
{
return (new Dump($base,$tables))->dump();
}
@@ -3891,9 +4005,9 @@ if (not_exist('insert_into'))
if(different($v,$primary))
{
if (is_numeric($v))
- append($data,quote($v). ', ');
+ append($data, '? ,');
else
- append($data,$instance->quote($v) .', ') ;
+ append($data,"'?' ," ) ;
}
else
{
@@ -3913,6 +4027,75 @@ if (not_exist('insert_into'))
}
}
+
+if (not_exist('routes_add'))
+{
+ /**
+ *
+ * @param Model $model
+ * @param mixed ...$values
+ *
+ * @return bool
+ *
+ * @throws Exception
+ */
+ function routes_add(Model $model,array $values): bool
+ {
+ $instance = $model;
+
+
+ $x = collection($instance->columns())->join(',');
+
+ $data = "INSERT INTO routes ($x) VALUES (";
+
+ $primary = $instance->primary();
+
+ foreach ($values as $k=> $v)
+ {
+ if(different($v,$primary))
+ {
+ if (is_numeric($v))
+ append($data,quote($v). ', ');
+ else
+ append($data,$instance->quote($v) .', ') ;
+ }
+ else
+ {
+ if ($instance->is_mysql() || $instance->is_sqlite())
+ append($data,'NULL, ');
+ else
+ append($data,"DEFAULT, ");
+
+ }
+ }
+
+ $data = trim($data,', ');
+
+ append($data, ')');
+
+
+ return $instance->execute($data,'');
+
+ }
+}
+if (not_exist('controllers'))
+{
+ function controllers(): array
+ {
+ $dir = core_path(collection(config('app','dir'))->get('app')) . DIRECTORY_SEPARATOR . collection(config('app','dir'))->get('controller');
+
+ $controllers = collection(File::search("$dir" .DIRECTORY_SEPARATOR. '*.php'));
+
+ $data = collection();
+
+ if ($controllers)
+ {
+ foreach ($controllers as $controller)
+ $data->add(collection(explode('.',collection(explode(DIRECTORY_SEPARATOR,$controller))->last()))->begin());
+ }
+ return $data->collection();
+ }
+}
if (not_exist('glyph'))
{
/**
diff --git a/imperium/App.php b/imperium/App.php
index 62f6f92..8132ea8 100644
--- a/imperium/App.php
+++ b/imperium/App.php
@@ -10,6 +10,8 @@ namespace Imperium {
use Imperium\Config\Config;
use Imperium\Connexion\Connect;
use Imperium\Dump\Dump;
+ use Imperium\Routing\Route;
+ use Imperium\Validator\Validator;
use Imperium\Versioning\Git\Git;
use Imperium\Writing\Write;
use Imperium\File\File;
@@ -47,6 +49,7 @@ namespace Imperium {
class App extends Zen implements Management
{
+ use Route;
/**
*
* Connexion
@@ -100,10 +103,7 @@ namespace Imperium {
* @var array
*/
private $hidden_tables;
- /**
- * @var array
- */
- private $hidden_bases;
+
/**
* @var Table
@@ -113,6 +113,19 @@ namespace Imperium {
* @var Dotenv
*/
private $env;
+ /**
+ * @var string
+ */
+ private $username;
+ /**
+ * @var string
+ */
+ private $password;
+
+ /**
+ * @var bool
+ */
+ private $debug;
/**
@@ -702,34 +715,46 @@ namespace Imperium {
*/
public function __construct()
{
+ $this->driver = db(DB_DRIVER);
+ $this->base = db(DB_NAME);
+ $this->username = db(DB_USERNAME);
+ $this->password = db(DB_PASSWORD);
+ $this->hidden_tables = db(DB_HIDDEN_TABLES);
+ $this->debug = db(DISPLAY_BUGS);
- $file = 'db';
- $this->hidden_tables = config($file,'hidden_tables');
- $this->hidden_bases = config($file,'hidden_bases');
- if (equal(\config($file,'driver'),SQLITE))
- $this->connect = connect(SQLITE,config($file,'base'),'','','',\config($file,'dump'));
+ if (equal($this->driver,SQLITE))
+ $this->connect = connect(SQLITE,$this->base,'','','','dump');
else
- $this->connect = connect(config($file,'driver'),config($file,'base'),config($file,'username'),config($file,'password'),config($file,'host'),config($file,'dump'));
- $this->driver = $this->connect->driver();
+ $this->connect = connect($this->driver,$this->base,$this->username,$this->password,LOCALHOST,'dump');
+
$this->table = new Table($this->connect);
+
$this->query = new Query($this->table,$this->connect);
+
$this->base = new Base($this->connect,$this->table);
+
$this->users = new Users($this->connect);
+
$this->model = new Model($this->connect,$this->table);
+
$this->json = new Json('app.json');
+
$this->form = new Form();
if (equal(request()->getScriptName(),'./vendor/bin/phpunit'))
- $path = dirname(request()->server->get('SCRIPT_FILENAME'),3);
+ $path = dirname(request()->server->get('SCRIPT_FILENAME'),3);
else
$path = dirname(request()->server->get('DOCUMENT_ROOT'));
if (def($this->request()->server->get('PWD')))
$path = $this->request()->server->get('PWD');
+ is_true(File::not_exist("$path" .DIRECTORY_SEPARATOR .".env"),true,".env file was not found");
+
$this->env = Dotenv::create($path);
+
$this->env->load();
}
@@ -738,18 +763,17 @@ namespace Imperium {
*
* Run the application
*
- * @return string
+ * @return Response
*
* @throws Exception
*
*/
- public function run():string
+ public function run():Response
{
- if(config('db','debug'))
- {
+ if ($this->debug)
whoops();
- }
- return $this->router(ServerRequest::fromGlobals())->run();
+
+ return $this->router(ServerRequest::fromGlobals())->run()->send();
}
/**
@@ -1167,5 +1191,43 @@ namespace Imperium {
{
return new Git($repository_path);
}
+
+ /**
+ *
+ * Check the request
+ *
+ * @return RedirectResponse|Validator
+ *
+ */
+ public function validator()
+ {
+ return new Validator($this->request());
+ }
+
+ /**
+ * @return Model
+ * @throws Exception
+ */
+ public function route(): Model
+ {
+ return $this->routes();
+ }
+
+
+ /**
+ *
+ * Generate url string
+ *
+ * @param string $route
+ *
+ * @param array $args
+ * @return string
+ *
+ * @throws Exception
+ */
+ public function url(string $route,...$args): string
+ {
+ return Router::url($route,$args);
+ }
}
}
diff --git a/imperium/Bases/Base.php b/imperium/Bases/Base.php
index 9deeaa2..0e614ec 100644
--- a/imperium/Bases/Base.php
+++ b/imperium/Bases/Base.php
@@ -86,6 +86,31 @@ use Imperium\Tables\Table;
*/
private $all;
+
+ /**
+ *
+ * Base Constructor
+ *
+ * @method __construct
+ *
+ * @param Connect $connect
+ * @param Table $table
+ *
+ * @throws Exception
+ *
+ */
+ public function __construct(Connect $connect,Table $table )
+ {
+ $this->connexion = $connect;
+ $this->driver = $connect->driver();
+ $this->tables = $table->show();
+ $this->table = $table;
+
+ if(different($this->driver,SQLITE))
+ $this->all = $this->show();
+ }
+
+
/**
*
* Create records in all tables not hidden
@@ -173,7 +198,7 @@ use Imperium\Tables\Table;
$this->create($new_base);
- return (new Import($new_base))->import();
+ return (new Import())->import();
}
/**
@@ -328,10 +353,10 @@ use Imperium\Tables\Table;
switch ($this->driver)
{
case Connect::MYSQL:
- $not_define ? $data->add($this->connexion->execute("CREATE DATABASE $name;")) : $data->add($this->connexion->execute("CREATE DATABASE $name CHARACTER SET = '{$this->charset}' COLLATE = '{$this->collation}';"));
+ $not_define ? $data->add($this->connexion->execute("CREATE DATABASE ?;",$name)) : $data->add($this->connexion->execute("CREATE DATABASE $name CHARACTER SET = '?' COLLATE = '?';",$this->charset,$this->collation));
break;
case Connect::POSTGRESQL:
- $not_define ? $data->add($this->connexion->execute("CREATE DATABASE $name TEMPLATE template0;")): $data->add($this->connexion->execute("CREATE DATABASE $name ENCODING '{$this->charset}' LC_COLLATE='{$this->collation}' LC_CTYPE='{$this->collation}' TEMPLATE template0;"));
+ $not_define ? $data->add($this->connexion->execute("CREATE DATABASE ? TEMPLATE template0;",$name)): $data->add($this->connexion->execute("CREATE DATABASE $name ENCODING '?' LC_COLLATE='?' LC_CTYPE='?' TEMPLATE template0;",$this->charset,$this->collation,$this->collation));
break;
}
}
@@ -470,28 +495,6 @@ use Imperium\Tables\Table;
}
- /**
- *
- * Base Constructor
- *
- * @method __construct
- *
- * @param Connect $connect
- * @param Table $table
- *
- * @throws Exception
- *
- */
- public function __construct(Connect $connect,Table $table )
- {
- $this->connexion = $connect;
- $this->driver = $connect->driver();
- $this->tables = $table->show();
- $this->table = $table;
-
- if(different($this->driver,Connect::SQLITE))
- $this->all = $this->show();
- }
@@ -525,10 +528,9 @@ use Imperium\Tables\Table;
$this->check();
- if (not_def($this->collation))
- throw new Exception("We have not found required collation");
+ is_true(not_def($this->collation),true,"We have not found required collation");
- return equal(Connect::MYSQL,$this->driver) ? $this->connexion->execute("ALTER DATABASE $base COLLATE = '{$this->collation}'") : $this->connexion->execute("update pg_database set datcollate='{$this->collation}', datctype='{$this->collation}' where datname = '$base'");
+ return $this->connexion->mysql() ? $this->connexion->execute("ALTER DATABASE $base COLLATE = '?'",$this->collation) : $this->connexion->execute("update pg_database set datcollate='?', datctype='?' where datname = '$base'",$this->collation,$this->collation);
}
@@ -583,10 +585,9 @@ use Imperium\Tables\Table;
$this->check();
- if (not_def($this->charset))
- throw new Exception("We have not found required charset");
+ is_true(not_def($this->charset),true,"We have not found required charset");
- return equal(MYSQL,$this->driver) ? $this->connexion->execute("ALTER DATABASE $base CHARACTER SET $this->charset;") : $this->connexion->execute("update pg_database set encoding = pg_char_to_encoding('{$this->charset}') where datname = '$base'");
+ return $this->connexion->mysql() ? $this->connexion->execute("ALTER DATABASE $base CHARACTER SET ?;",$this->charset) : $this->connexion->execute("update pg_database set encoding = pg_char_to_encoding('?') where datname = '$base'",$this->charset);
}
/**
@@ -600,7 +601,7 @@ use Imperium\Tables\Table;
*/
public function check(): Base
{
- not_in([Connect::MYSQL, Connect::POSTGRESQL], $this->driver, true, "The current driver is not supported");
+ not_in([MYSQL, POSTGRESQL], $this->driver, true, "The current driver is not supported");
return $this;
}
diff --git a/imperium/Command/AddRoutes.php b/imperium/Command/AddRoutes.php
index 91db399..36834d3 100644
--- a/imperium/Command/AddRoutes.php
+++ b/imperium/Command/AddRoutes.php
@@ -2,9 +2,8 @@
namespace Imperium\Command {
-
- use Imperium\File\File;
- use Imperium\Routing\Router;
+ use Imperium\Collection\Collection;
+ use Imperium\Routing\Route;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -12,6 +11,8 @@ namespace Imperium\Command {
class AddRoutes extends Command
{
+ use Route;
+
protected static $defaultName = 'routes:add';
private $name;
@@ -20,6 +21,7 @@ namespace Imperium\Command {
private $action;
private $method;
+
/**
* @var array
*/
@@ -36,23 +38,12 @@ namespace Imperium\Command {
private function controllers(): array
{
- $dir = core_path(collection(config('app','dir'))->get('app')) . DIRECTORY_SEPARATOR . collection(config('app','dir'))->get('controller');
-
- $controllers = collection(File::search("$dir" .DIRECTORY_SEPARATOR. '*.php'));
-
- $data = collection();
-
- if ($controllers)
- {
- foreach ($controllers as $controller)
- $data->add(collection(explode('.',collection(explode(DIRECTORY_SEPARATOR,$controller))->last()))->begin());
- }
- return $data->collection();
+ return controllers();
}
- public function methods():array
+ public function methods():Collection
{
- return collection(Router::METHOD_SUPPORTED)->each('strtolower')->collection();
+ return collection(METHOD_SUPPORTED)->each('strtolower');
}
public function interact(InputInterface $input, OutputInterface $output)
{
@@ -65,16 +56,16 @@ namespace Imperium\Command {
$this->clean();
$question = new Question("<info>Set the route method : </info>");
- $question->setAutocompleterValues($this->methods());
+ $question->setAutocompleterValues($this->methods()->collection());
$this->method = strtoupper($helper->ask($input, $output, $question));
- while (not_in(Router::METHOD_SUPPORTED,$this->method))
+ while (not_in(METHOD_SUPPORTED,$this->method))
{
$this->clean();
- $verbs = collection(Router::METHOD_SUPPORTED)->each('strtolower')->join(', ');
- $output->write("<error>The method must be $verbs </error>\n");
+
+ $output->write("<error>The method must be {$this->methods()->join(', ')} </error>\n");
$question = new Question("<info>Set the route method : </info>");
- $question->setAutocompleterValues($this->methods());
+ $question->setAutocompleterValues($this->methods()->collection());
$this->method = strtoupper($helper->ask($input, $output, $question));
}
}while (is_null($this->method));
@@ -85,7 +76,7 @@ namespace Imperium\Command {
$this->name = $helper->ask($input, $output, $question);
- while (def(app()->model()->from('routes')->by('name',$this->name)))
+ while (def($this->routes()->by('name',$this->name)))
{
$this->clean();
$output->write("<error>The route name already exist</error>\n");
@@ -100,7 +91,7 @@ namespace Imperium\Command {
$this->url = $helper->ask($input, $output, $question);
- while (def(app()->model()->from('routes')->by('url',$this->url)))
+ while (def($this->routes()->by('url',$this->url)))
{
$this->clean();
$output->write("<error>The url already exist</error>\n");
@@ -139,8 +130,9 @@ namespace Imperium\Command {
$data = collection();
foreach ($this->routes as $route)
- $data->add(app()->model()->from(Router::ROUTES)->insert_new_record($route));
+ $data->add($this->save_route($route));
+ $this->clean();
if ($data->not_exist(false))
$output->write("<info>All routes has been successfully created</info>\n");
else
diff --git a/imperium/Command/App.php b/imperium/Command/App.php
index ba8964c..30589a5 100644
--- a/imperium/Command/App.php
+++ b/imperium/Command/App.php
@@ -7,6 +7,7 @@ namespace Imperium\Command {
use Exception;
use Imperium\Directory\Dir;
use Imperium\File\File;
+ use Imperium\Routing\Route;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -14,6 +15,7 @@ namespace Imperium\Command {
class App extends Command
{
+ use Route;
protected static $defaultName = 'app:create';
private $app_dir;
private $controller_dir;
@@ -143,7 +145,6 @@ namespace Imperium\Command {
public function execute(InputInterface $input, OutputInterface $output)
{
-
$file = 'config/db.yaml';
File::remove_if_exist($file);
@@ -188,7 +189,7 @@ return [
\"name\" => \$x->base(),
\"user\" => \$x->user(),
\"pass\" => \$x->password(),
- \"port\" => config('db','port'),
+ \"port\" => $this->port,
]
]
];");
@@ -290,7 +291,17 @@ return [
Dir::remove('tmp');
- return 0;
+ return $this->create_route_table();
+
+ }
+
+ /**
+ * all drivers supported to autocomplete driver
+ * @return array
+ */
+ private function drivers(): array
+ {
+ return [ MYSQL,POSTGRESQL,SQLITE];
}
}
diff --git a/imperium/Command/FindRoute.php b/imperium/Command/FindRoute.php
index 5e9008d..b1f2ba0 100644
--- a/imperium/Command/FindRoute.php
+++ b/imperium/Command/FindRoute.php
@@ -5,7 +5,7 @@ namespace Imperium\Command {
use Exception;
- use Imperium\Routing\Router;
+ use Imperium\Routing\Route;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -13,8 +13,13 @@ namespace Imperium\Command {
class FindRoute extends Command
{
+ use Route;
+
protected static $defaultName = 'routes:search';
+ /**
+ * @var string
+ */
private $search;
private function clean()
@@ -36,9 +41,10 @@ namespace Imperium\Command {
*/
public function interact(InputInterface $input, OutputInterface $output)
{
- $helper = $this->getHelper('question');
- if (app()->table_exist(Router::ROUTES))
+ if (def($this->routes()->all()))
{
+ $helper = $this->getHelper('question');
+
do {
do {
@@ -48,7 +54,7 @@ namespace Imperium\Command {
$this->search = $helper->ask($input, $output, $question);
}while (is_null($this->search));
- $routes = app()->model()->from(Router::ROUTES)->search($this->search);
+ $routes = $this->routes()->search($this->search);
routes($output,$routes);
$question = new Question("<info>Continue searching ? [Y/n] : </info>",'Y');
@@ -57,15 +63,19 @@ namespace Imperium\Command {
}while ($continue);
- }else{
- $output->write("<error>The table routes was not found</error>\n");
- return 1;
}
+
}
public function execute(InputInterface $input, OutputInterface $output)
{
- $output->write("<info>Bye</info>\n");
+ $this->clean();
+ if (def($this->routes()->all()))
+ {
+ $output->write("<info>Bye</info>\n");
+ }else{
+ $output->write("<error>We have not found routes</error>\n");
+ }
}
}
diff --git a/imperium/Command/RemoveRoutes.php b/imperium/Command/RemoveRoutes.php
index 2bc7cbb..0b001d4 100644
--- a/imperium/Command/RemoveRoutes.php
+++ b/imperium/Command/RemoveRoutes.php
@@ -4,7 +4,7 @@
namespace Imperium\Command {
- use Imperium\Routing\Router;
+ use Imperium\Routing\Route;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -14,8 +14,10 @@ namespace Imperium\Command {
{
protected static $defaultName = 'routes:destroy';
+ use Route;
+
private $name;
- private $id;
+
private function clean()
{
@@ -29,7 +31,7 @@ namespace Imperium\Command {
public function names(): array
{
$data = collection();
- foreach (app()->model()->query()->mode(SELECT)->from('routes')->only('name')->get() as $x)
+ foreach ($this->routes()->query()->mode(SELECT)->from('routes')->only('name')->get() as $x)
$data->add($x->name);
return $data->collection();
@@ -37,17 +39,9 @@ namespace Imperium\Command {
public function interact(InputInterface $input, OutputInterface $output)
{
- $helper = $this->getHelper('question');
-
- do {
- $this->clean();
- $question = new Question("<info>Please enter the route name : </info>");
- $question->setAutocompleterValues($this->names());
- $this->name = $helper->ask($input, $output, $question);
-
- }while (is_null($this->name));
- while (not_def($this->get($this->name)))
+ if (def($this->names()))
{
+ $helper = $this->getHelper('question');
do {
$this->clean();
@@ -55,24 +49,42 @@ namespace Imperium\Command {
$question->setAutocompleterValues($this->names());
$this->name = $helper->ask($input, $output, $question);
-
}while (is_null($this->name));
+ while (not_def($this->name($this->name)))
+ {
+
+ do {
+ $this->clean();
+ $question = new Question("<info>Please enter the route name : </info>");
+ $question->setAutocompleterValues($this->names());
+ $this->name = $helper->ask($input, $output, $question);
+
+
+ }while (is_null($this->name));
+ }
+
}
}
public function execute(InputInterface $input, OutputInterface $output)
{
- if (app()->model()->query()->from(Router::ROUTES)->mode(DELETE)->where('name',EQUAL,$this->name)->delete())
- $output->write("<info>The route has been deleted successfully</info>\n");
- else
- $output->write("<error>The route deletion has failed</error>\n");
+ $this->clean();
+ if (def($this->names()))
+ {
+ if ($this->routes()->query()->from('routes')->mode(DELETE)->where('name',EQUAL,$this->name)->delete())
+ $output->write("<info>The route has been deleted successfully</info>\n");
+ else
+ $output->write("<error>The route deletion has failed</error>\n");
+ }else{
+ $output->write("<error>We have not found routes</error>\n");
+ }
}
- private function get(string $name): array
+ private function name(string $name): array
{
- return app()->model()->from(Router::ROUTES)->by('name',$name);
+ return $this->routes()->by('name',$name);
}
}
} \ No newline at end of file
diff --git a/imperium/Command/RouteInfo.php b/imperium/Command/RouteInfo.php
index cc56bf5..b3c0f9b 100644
--- a/imperium/Command/RouteInfo.php
+++ b/imperium/Command/RouteInfo.php
@@ -5,7 +5,7 @@ namespace Imperium\Command {
use Exception;
- use Imperium\Routing\Router;
+ use Imperium\Routing\Route;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -13,6 +13,7 @@ namespace Imperium\Command {
class RouteInfo extends Command
{
+ use Route;
protected static $defaultName = 'routes:info';
private $search;
@@ -24,14 +25,14 @@ namespace Imperium\Command {
protected function configure()
{
- $this->setDescription('Find a route');
+ $this->setDescription('Display route info');
}
public function names(): array
{
$data = collection();
- foreach (app()->model()->query()->mode(SELECT)->from('routes')->only('name')->get() as $x)
+ foreach ($this->routes()->query()->from('routes')->mode(SELECT)->only('name')->get() as $x)
$data->add($x->name);
return $data->collection();
@@ -46,7 +47,8 @@ namespace Imperium\Command {
public function interact(InputInterface $input, OutputInterface $output)
{
$helper = $this->getHelper('question');
- if (app()->table_exist(Router::ROUTES))
+
+ if (def($this->names()))
{
do {
@@ -57,7 +59,7 @@ namespace Imperium\Command {
$this->search = $helper->ask($input, $output, $question);
}while (is_null($this->search));
- $routes = app()->model()->from(Router::ROUTES)->by('name',$this->search);
+ $routes = $this->routes()->by('name',$this->search);
routes($output,$routes);
$question = new Question("<info>Continue ? [Y/n] : </info>",'Y');
@@ -66,15 +68,20 @@ namespace Imperium\Command {
}while ($continue);
- }else{
- $output->write("<error>The table routes was not found</error>\n");
- return 1;
}
+
+
}
public function execute(InputInterface $input, OutputInterface $output)
{
- $output->write("<info>Bye</info>\n");
+ $this->clean();
+ if (def($this->names()))
+ {
+ $output->write("<info>Bye</info>\n");
+ }else {
+ $output->write("<error>We have not found routes</error>\n");
+ }
}
}
diff --git a/imperium/Command/RoutesList.php b/imperium/Command/RoutesList.php
index 9608a96..b230205 100644
--- a/imperium/Command/RoutesList.php
+++ b/imperium/Command/RoutesList.php
@@ -7,6 +7,7 @@ namespace Imperium\Command {
use Exception;
use Imperium\Connexion\Connect;
use Imperium\File\File;
+ use Imperium\Routing\Route;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -17,6 +18,7 @@ namespace Imperium\Command {
protected static $defaultName = 'routes:list';
+ use Route;
protected function configure()
{
@@ -31,7 +33,7 @@ namespace Imperium\Command {
*/
public function execute(InputInterface $input, OutputInterface $output)
{
- routes($output, app()->model()->from('routes')->all('id',ASC));
+ routes($output, $this->routes()->all('id',ASC));
}
diff --git a/imperium/Command/UpdateRoutes.php b/imperium/Command/UpdateRoutes.php
index 1c37bef..6108ec6 100644
--- a/imperium/Command/UpdateRoutes.php
+++ b/imperium/Command/UpdateRoutes.php
@@ -4,9 +4,8 @@
namespace Imperium\Command {
- use Imperium\File\File;
+ use Imperium\Routing\Route;
use Imperium\Routing\Router;
- use Sinergi\BrowserDetector\Os;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -14,6 +13,7 @@ namespace Imperium\Command {
class UpdateRoutes extends Command
{
+ use Route;
protected static $defaultName = 'routes:update';
private $name;
@@ -40,29 +40,18 @@ namespace Imperium\Command {
private function controllers(): array
{
- $dir = core_path(collection(config('app','dir'))->get('app')) . DIRECTORY_SEPARATOR . collection(config('app','dir'))->get('controller');
-
- $controllers = collection(File::search("$dir" .DIRECTORY_SEPARATOR. '*.php'));
-
- $data = collection();
-
- if ($controllers)
- {
- foreach ($controllers as $controller)
- $data->add(collection(explode('.',collection(explode(DIRECTORY_SEPARATOR,$controller))->last()))->begin());
- }
- return $data->collection();
+ return controllers();
}
private function methods():array
{
- return collection(Router::METHOD_SUPPORTED)->each('strtolower')->collection();
+ return collection(METHOD_SUPPORTED)->each('strtolower')->collection();
}
private function names(): array
{
$data = collection();
- foreach (app()->model()->query()->mode(SELECT)->from('routes')->only('name')->get() as $x)
+ foreach ($this->routes()->query()->mode(SELECT)->from('routes')->only('name')->get() as $x)
$data->add($x->name);
return $data->collection();
@@ -74,122 +63,128 @@ namespace Imperium\Command {
$helper = $this->getHelper('question');
- do{
+ if (def($this->names()))
+ {
- do {
- $this->clean();
- $question = new Question("<info>Please enter the route name : </info>",'__________');
- $question->setAutocompleterValues($this->names());
- $this->name = $helper->ask($input, $output, $question);
+ do{
- while (not_def($this->get($this->name)))
- {
+ do {
$this->clean();
$question = new Question("<info>Please enter the route name : </info>",'__________');
$question->setAutocompleterValues($this->names());
$this->name = $helper->ask($input, $output, $question);
- }
+ while (not_def($this->name($this->name)))
+ {
+ $this->clean();
+ $question = new Question("<info>Please enter the route name : </info>",'__________');
+ $question->setAutocompleterValues($this->names());
+ $this->name = $helper->ask($input, $output, $question);
+ }
- }while (is_null($this->name));
- $this->clean();
- $this->print($output);
- foreach ($this->get($this->name) as $route)
- {
- $this->id = $route->id;
- do {
- $question = new Question("<info>Change the method</info> <comment>[$route->method]</comment> : ",$route->method);
- $question->setAutocompleterValues($this->methods());
- $this->method = strtoupper($helper->ask($input, $output, $question));
+ }while (is_null($this->name));
- while (not_in(Router::METHOD_SUPPORTED,$this->method))
- {
- $verbs = collection(Router::METHOD_SUPPORTED)->each('strtolower')->join(', ');
- $output->write("<error>The method must be are $verbs </error>\n");
+ $this->clean();
+ $this->print($output);
+ foreach ($this->name($this->name) as $route)
+ {
+ $this->id = $route->id;
+ do {
$question = new Question("<info>Change the method</info> <comment>[$route->method]</comment> : ",$route->method);
-
$question->setAutocompleterValues($this->methods());
$this->method = strtoupper($helper->ask($input, $output, $question));
- }
- }while (is_null($this->method));
- do {
- $question = new Question("<info>Change the name</info> <comment>[$route->name]</comment> : ",$route->name);
+ while (not_in(METHOD_SUPPORTED,$this->method))
+ {
+ $verbs = collection(METHOD_SUPPORTED)->each('strtolower')->join(', ');
+ $output->write("<error>The method must be are $verbs </error>\n");
+ $question = new Question("<info>Change the method</info> <comment>[$route->method]</comment> : ",$route->method);
- $this->name = $helper->ask($input, $output, $question);
+ $question->setAutocompleterValues($this->methods());
+ $this->method = strtoupper($helper->ask($input, $output, $question));
+ }
+ }while (is_null($this->method));
- while (def($this->get($this->name)) && different($this->name,$route->name))
- {
- $output->write("<error>The route name already exist</error>\n");
+ do {
$question = new Question("<info>Change the name</info> <comment>[$route->name]</comment> : ",$route->name);
- $this->name = $helper->ask($input, $output, $question);
- }
- }while (is_null($this->name));
-
- do {
- $question = new Question("<info>Change the url</info> <comment>[$route->url]</comment> : ",$route->url);
+ $this->name = $helper->ask($input, $output, $question);
- $this->url = $helper->ask($input, $output, $question);
+ while (def($this->name($this->name)) && different($this->name,$route->name))
+ {
+ $output->write("<error>The route name already exist</error>\n");
+ $question = new Question("<info>Change the name</info> <comment>[$route->name]</comment> : ",$route->name);
+ $this->name = $helper->ask($input, $output, $question);
+ }
+ }while (is_null($this->name));
- while (def(app()->model()->from('routes')->by('url',$this->url))&& different($this->url,$route->url))
- {
+ do {
- $output->write("<error>The url already exist</error>\n");
$question = new Question("<info>Change the url</info> <comment>[$route->url]</comment> : ",$route->url);
+
$this->url = $helper->ask($input, $output, $question);
- }
- }while (is_null($this->url));
+ while (def($this->routes()->by('url',$this->url))&& different($this->url,$route->url))
+ {
- do {
- $question = new Question("<info>Change the controller</info> <comment>[$route->controller]</comment> : ",$route->controller);
- $question->setAutocompleterValues($this->controllers());
- $this->controller = $helper->ask($input, $output, $question);
- }while (is_null($this->controller));
+ $output->write("<error>The url already exist</error>\n");
+ $question = new Question("<info>Change the url</info> <comment>[$route->url]</comment> : ",$route->url);
+ $this->url = $helper->ask($input, $output, $question);
+ }
+ }while (is_null($this->url));
- do {
- $question = new Question("<info>Change the action</info> <comment>[$route->action]</comment> : ",$route->action);
- $this->action = $helper->ask($input, $output, $question);
- }while (is_null($this->action));
- }
+ do {
+ $question = new Question("<info>Change the controller</info> <comment>[$route->controller]</comment> : ",$route->controller);
+ $question->setAutocompleterValues($this->controllers());
+ $this->controller = $helper->ask($input, $output, $question);
+ }while (is_null($this->controller));
+
+ do {
+
+ $question = new Question("<info>Change the action</info> <comment>[$route->action]</comment> : ",$route->action);
+ $this->action = $helper->ask($input, $output, $question);
+ }while (is_null($this->action));
+ }
- $this->routes[] = ['id' => $this->id,'method' => $this->method,'name' => $this->name,'url'=> $this->url,'controller'=> $this->controller,'action'=> $this->action];
+ $this->routes[] = ['id' => $this->id,'method' => $this->method,'name' => $this->name,'url'=> $this->url,'controller'=> $this->controller,'action'=> $this->action];
- $question = new Question("<info>Update another route [Y/n] : </info>",'Y');
- $continue = strtoupper($helper->ask($input, $output, $question));
- $continue = $continue === 'Y';
- }while($continue);
+ $question = new Question("<info>Update another route [Y/n] : </info>",'Y');
+ $continue = strtoupper($helper->ask($input, $output, $question));
+ $continue = $continue === 'Y';
+ }while($continue);
+ }
}
public function execute(InputInterface $input, OutputInterface $output)
{
- $data = collection();
- foreach ($this->routes as $route)
+ if (def($this->names()))
{
- $data->add(app()->model()->from(Router::ROUTES)->update_record($route['id'],$route));
- }
-
-
- if ($data->not_exist(false))
- $output->write("<info>All routes has been successfully updated</info>\n");
- else
- $output->write("<error>The routes update has failed</error>\n");
+ $data = collection();
+ foreach ($this->routes as $route)
+ $data->add($this->update_route($route['id'],$route));
+ $this->clean();
+ if ($data->not_exist(false))
+ $output->write("<info>All routes has been successfully updated</info>\n");
+ else
+ $output->write("<error>The routes update has failed</error>\n");
+ }else{
+ $output->write("<error>We have not found routes</error>\n");
+ }
}
private function print(OutputInterface $output)
{
$this->clean();
- routes($output, $this->get($this->name));
+ routes($output, $this->name($this->name));
}
- private function get(string $name): array
+ private function name(string $name): array
{
- return app()->model()->from(Router::ROUTES)->by('name',$name);
+ return $this->routes()->by('name',$name);
}
}
}
diff --git a/imperium/Config/Config.php b/imperium/Config/Config.php
index 90016dc..c223449 100644
--- a/imperium/Config/Config.php
+++ b/imperium/Config/Config.php
@@ -2,8 +2,8 @@
namespace Imperium\Config {
- use Exception;
use Imperium\Directory\Dir;
+ use Imperium\Exception\Kedavra;
use Imperium\File\File;
use Symfony\Component\Yaml\Yaml;
@@ -43,7 +43,8 @@ namespace Imperium\Config {
*
* @return mixed
*
- * @throws Exception
+ * @throws Kedavra
+ *
*/
public function get(string $file,$key)
{
@@ -57,8 +58,9 @@ namespace Imperium\Config {
$data = collection(self::parseFile($x));
+
if (!$data->has_key($key))
- throw new Exception("The $key key was not found in the file $file at {$this->path()}");
+ throw new Kedavra("The $key key was not found in the file $file at {$this->path()}");
else
return $data->get($key);
}
@@ -67,7 +69,7 @@ namespace Imperium\Config {
/**
* @param string $file
*
- * @throws Exception
+ * @throws Kedavra
*
*/
private static function check(string $file)
@@ -77,7 +79,7 @@ namespace Imperium\Config {
}
/**
- * @throws Exception
+ * @throws Kedavra
*/
public static function init()
{
diff --git a/imperium/Connexion/Connect.php b/imperium/Connexion/Connect.php
index af2d052..09d91b6 100644
--- a/imperium/Connexion/Connect.php
+++ b/imperium/Connexion/Connect.php
@@ -5,8 +5,6 @@ namespace Imperium\Connexion {
use Exception;
use PDO;
use PDOException;
- use Imperium\Directory\Dir;
- use Symfony\Component\DependencyInjection\Tests\Compiler\D;
/**
*
@@ -141,10 +139,6 @@ namespace Imperium\Connexion {
*/
private $host;
- /**
- * @var string
- */
- private $queries;
/**
*
@@ -345,27 +339,28 @@ namespace Imperium\Connexion {
}
/**
- * @param string $request
*
+ * @param string $sql
+ * @param string[] $vars
* @return object
*
* @throws Exception
- *
*/
- public function fetch(string $request)
+ public function fetch(string $sql,string ...$vars)
{
- $query = $this->instance()->prepare($request);
+ $query = $this->instance()->prepare($sql);
- is_true(is_bool($query),true,$request);
+ is_true(is_bool($query),true,$sql);
- $query->execute();
+ $query->execute($vars);
- $data = $query->fetch($this->fetch_mode());
+ $x = $query->fetch($this->fetch_mode());
is_false($query->closeCursor(),true,"Fail to close the connection");
$query = null;
- return $data;
+
+ return $x;
}
/**
@@ -391,54 +386,57 @@ namespace Imperium\Connexion {
*
* @method request
*
- * @param string $request The sql query
- *
+ * @param string $sql
+ * @param string[] $vars
* @return array
*
* @throws Exception
- *
*/
- public function request(string $request): array
+ public function request(string $sql,string ...$vars): array
{
- $query = $this->instance()->prepare($request);
+ $query = $this->instance()->prepare($sql);
- $query->execute();
+ $query->execute($vars);
- is_true(is_bool($query),true,$request);
+ is_true(is_bool($query),true,$sql);
- $data = $query->fetchAll($this->fetch_mode());
+ $x = $query->fetchAll($this->fetch_mode());
is_false($query->closeCursor(),true,"Fail to close the connection");
$query = null;
- return $data;
+ return $x;
}
- /**
- *
- * Execute a query and return true on success or false on failure
- *
- * @method execute
- *
- * @param string $request The sql query
- *
- * @return bool
- *
- * @throws Exception
- *
- */
- public function execute(string $request): bool
+ /**
+ *
+ * Execute a query and return true on success or false on failure
+ *
+ * @method execute
+ *
+ * @param string $sql
+ * @param string[] $vars
+ *
+ * @return bool
+ *
+ * @throws Exception
+ *
+ */
+ public function execute(string $sql,string ...$vars): bool
{
- $query = $this->instance()->prepare($request);
+ $query = $this->instance()->prepare($sql);
- is_true(is_bool($query),true,$request);
- $data = $query->execute();
+ is_true(is_bool($query),true,$sql);
+
+ $x = $query->execute($vars);
is_false($query->closeCursor(),true,"Fail to close the connection");
+
$query = null;
- return $data;
+
+ return $x;
}
@@ -472,25 +470,7 @@ namespace Imperium\Connexion {
return $this->instance()->commit();
}
- /**
- *
- * Execute the queries
- *
- * @param string[] $queries
- *
- * @return Connect
- *
- * @throws Exception
- */
- public function queries(string ...$queries): Connect
- {
- $this->queries = $queries;
- foreach ($queries as $query)
- is_false($this->execute($query),true,$query);
-
- return $this;
- }
/**
*
* Abort the current transaction
diff --git a/imperium/Exception/Kedavra.php b/imperium/Exception/Kedavra.php
new file mode 100644
index 0000000..991b3d6
--- /dev/null
+++ b/imperium/Exception/Kedavra.php
@@ -0,0 +1,13 @@
+<?php
+
+
+namespace Imperium\Exception {
+
+
+ use Exception;
+
+ class Kedavra extends Exception
+ {
+
+ }
+} \ No newline at end of file
diff --git a/imperium/Management.php b/imperium/Management.php
index 20300bf..3ecf506 100644
--- a/imperium/Management.php
+++ b/imperium/Management.php
@@ -9,6 +9,7 @@ namespace Imperium {
use Imperium\Collection\Collection;
use Imperium\Config\Config;
use Imperium\Connexion\Connect;
+ use Imperium\Validator\Validator;
use Imperium\Versioning\Git\Git;
use Imperium\Writing\Write;
use Imperium\Flash\Flash;
@@ -678,6 +679,32 @@ namespace Imperium {
*/
public function response(): Response;
+
+ /**
+ * @return Model
+ */
+ public function route() : Model;
+
+ /**
+ *
+ * Check the request
+ *
+ * @return RedirectResponse|Validator
+ *
+ */
+ public function validator();
+
+ /**
+ *
+ * Generate url string
+ *
+ * @param string $route
+ * @param mixed $args
+ *
+ * @return string
+ */
+ public function url(string $route,...$args): string ;
+
// GETTER
// END GETTER
diff --git a/imperium/Model/Model.php b/imperium/Model/Model.php
index 55707df..5a089b3 100644
--- a/imperium/Model/Model.php
+++ b/imperium/Model/Model.php
@@ -6,6 +6,7 @@ namespace Imperium\Model {
use Exception;
use Imperium\App;
use Imperium\Connexion\Connect;
+ use Imperium\Exception\Kedavra;
use Imperium\Query\Query;
use Imperium\Request\Request;
use Imperium\Security\Csrf\Csrf;
@@ -137,9 +138,11 @@ namespace Imperium\Model {
* @method dump
*
* @param string ...$tables
+ *
* @return bool
*
* @throws Exception
+ *
*/
public function dump(string ...$tables): bool
{
@@ -157,7 +160,7 @@ namespace Imperium\Model {
*/
public function dump_base(): bool
{
- return dumper(true,[]);
+ return dumper(true);
}
/**
@@ -182,7 +185,7 @@ namespace Imperium\Model {
*
* @return string
*
- * @throws Exception
+ * @throws Kedavra
*
*/
public function current(): string
@@ -363,7 +366,7 @@ namespace Imperium\Model {
*/
public function search(string $value,bool $json_output = false)
{
- return $json_output ? collection($this->query()->from($this->current())->mode(Query::SELECT)->like($value)->get())->json() : $this->query()->from($this->current())->mode(Query::SELECT)->like($value)->get();
+ return $json_output ? collection($this->query()->from($this->current())->mode(SELECT)->like($value)->get())->json() : $this->query()->from($this->current())->mode(Query::SELECT)->like($value)->get();
}
/**
@@ -569,7 +572,7 @@ namespace Imperium\Model {
{
is_true(not_def($this->column,$this->expected,$this->condition),true,"The where clause was not found");
- return def($this->only) ? $this->query()->from($this->current())->mode(Query::SELECT)->where($this->column,$this->condition,$this->expected)->only($this->only)->get() : $this->query()->from($this->current())->mode(Query::SELECT)->where($this->column,$this->condition,$this->expected)->get();
+ return def($this->only) ? $this->query()->from($this->current())->mode(SELECT)->where($this->column,$this->condition,$this->expected)->only($this->only)->get() : $this->query()->from($this->current())->mode(Query::SELECT)->where($this->column,$this->condition,$this->expected)->get();
}
@@ -675,7 +678,7 @@ namespace Imperium\Model {
*/
public function news(string $order_column,int $limit,int $offset = 0): array
{
- return $this->query()->from($this->current())->mode(Query::SELECT)->limit($limit,$offset)->order_by($order_column)->get();
+ return $this->query()->from($this->current())->mode(SELECT)->limit($limit,$offset)->order_by($order_column)->get();
}
/**
@@ -692,7 +695,7 @@ namespace Imperium\Model {
*/
public function last(string $order_column,int $limit,int $offset = 0): array
{
- return $this->query()->from($this->current())->mode(Query::SELECT)->limit($limit,$offset)->order_by($order_column,ASC)->get();
+ return $this->query()->from($this->current())->mode(SELECT)->limit($limit,$offset)->order_by($order_column,ASC)->get();
}
/**
@@ -801,7 +804,7 @@ namespace Imperium\Model {
*/
public function remove(int $id): bool
{
- return $this->query()->from($this->current())->mode(Query::DELETE)->where($this->primary(),Query::EQUAL,$id)->delete();
+ return $this->query()->from($this->current())->mode(Query::DELETE)->where($this->primary(),EQUAL,$id)->delete();
}
/**
@@ -813,6 +816,7 @@ namespace Imperium\Model {
* @return bool
*
* @throws Exception
+ *
*/
public function insert_new_record(array $data): bool
{
@@ -975,27 +979,29 @@ namespace Imperium\Model {
*
* @param string $query
*
+ * @param array $data
* @return array
*
* @throws Exception
- *
*/
- public function request(string $query): array
+ public function request(string $query,array $data): array
{
- return $this->connexion->request($query);
+ return $this->connexion->request($query,$data);
}
/**
* @param string $request
*
+ * @param array $data
* @return object
*
* @throws Exception
*/
- public function fetch(string $request)
+ public function fetch(string $request,array $data)
{
- return $this->connexion->fetch($request);
+ return $this->connexion->fetch($request,$data);
}
+
/**
*
* Execute a custom query
@@ -1005,7 +1011,6 @@ namespace Imperium\Model {
* @return bool
*
* @throws Exception
- *
*/
public function execute(string $query): bool
{
diff --git a/imperium/Routing/Route.php b/imperium/Routing/Route.php
new file mode 100644
index 0000000..3cf29ef
--- /dev/null
+++ b/imperium/Routing/Route.php
@@ -0,0 +1,119 @@
+<?php
+
+
+namespace Imperium\Routing {
+
+
+ use Exception;
+ use Imperium\Connexion\Connect;
+ use Imperium\Model\Model;
+ use Imperium\Tables\Table;
+ use Symfony\Component\DependencyInjection\Tests\Compiler\E;
+
+ trait Route
+ {
+
+
+ /**
+ *
+ * The sql query to create the table
+ *
+ * @var string
+ *
+ */
+ protected $sql = "CREATE TABLE IF NOT EXISTS routes ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT(255) NOT NULL UNIQUE,url TEXT(255) NOT NULL UNIQUE, controller TEXT(255) NOT NULL,action TEXT(255) NOT NULL,method TEXT(255) NOT NULL);";
+
+
+ /**
+ *
+ * Get an instance of model
+ *
+ * @return Model
+ *
+ * @throws Exception
+ *
+ */
+ public function routes(): Model
+ {
+ return (new Model($this->routes_connect(),$this->routes_table()))->from('routes');
+ }
+
+
+ /**
+ *
+ * Create the routes table
+ *
+ * @return bool
+ *
+ * @throws Exception
+ *
+ */
+ protected function create_route_table(): bool
+ {
+ return $this->routes_table()->not_exist('routes') ? $this->routes_connect()->execute($this->sql) : true;
+ }
+
+
+ /**
+ *
+ * Add a new route
+ *
+ * @param array $data
+ *
+ * @return bool
+ *
+ * @throws Exception
+ *
+ */
+ public function save_route(array $data): bool
+ {
+ return routes_add($this->routes(),$data);
+ }
+
+
+ /**
+ *
+ * Update a route
+ *
+ * @param int $id
+ * @param array $data
+ *
+ * @return bool
+ *
+ * @throws Exception
+ *
+ */
+ public function update_route(int $id,array $data): bool
+ {
+ return $this->routes()->update_record($id,$data);
+ }
+
+ /**
+ *
+ * Get an instance of table
+ *
+ * @return Table
+ *
+ * @throws Exception
+ *
+ */
+ private function routes_table(): Table
+ {
+ return table($this->routes_connect());
+ }
+
+ /**
+ *
+ * Get an instance of connect
+ *
+ * @return Connect
+ *
+ * @throws Exception
+ *
+ */
+ private function routes_connect():Connect
+ {
+ return connect(SQLITE,'routes.sqlite3','','','','dump');
+ }
+ }
+} \ No newline at end of file
diff --git a/imperium/Routing/Router.php b/imperium/Routing/Router.php
index 75f019d..5160aaf 100644
--- a/imperium/Routing/Router.php
+++ b/imperium/Routing/Router.php
@@ -9,6 +9,7 @@ namespace Imperium\Routing {
use Imperium\Security\Auth\AuthMiddleware;
use Imperium\Security\Csrf\CsrfMiddleware;
use Psr\Http\Message\ServerRequestInterface;
+ use Symfony\Component\HttpFoundation\Response;
/**
@@ -26,31 +27,8 @@ namespace Imperium\Routing {
**/
class Router
{
- /**
- *
- * The post method key
- *
- * @var string
- *
- */
- const METHOD_POST = 'POST';
-
- /**
- *
- * The get method key
- *
- * @var string
- */
- const METHOD_GET = 'GET';
- /**
- *
- * All methods supported
- *
- * @var array
- *
- */
- const METHOD_SUPPORTED = ['DELETE', 'PATCH', 'POST', 'PUT', 'GET'];
+ use Route;
/**
*
@@ -129,16 +107,6 @@ namespace Imperium\Routing {
/**
*
- * Table to store routes
- *
- * @var string
- *
- */
- const ROUTES = 'routes';
-
-
- /**
- *
* The url
*
* @var string
@@ -231,6 +199,7 @@ namespace Imperium\Routing {
$this->method = $request->getMethod();
+ $this->create_route_table(); // to be sure
$this->url = $request->getUri()->getPath();
@@ -238,26 +207,26 @@ namespace Imperium\Routing {
}
-
/**
*
* Call the callable
*
- * @return mixed
+ * @return Response
*
* @throws Exception
*
*/
- public function run()
+ public function run():Response
{
- is_true(app()->table_not_exist(self::ROUTES),true,"The routes table was not found");
- foreach(app()->model()->from(self::ROUTES)->where('method',EQUAL,$this->method)->get() as $route)
+ is_true(equal($this->routes()->count('routes'),0),true,"The routes table is empty");
+
+ foreach($this->routes()->by('method',$this->method) as $route)
{
if ($this->match($route->url))
return $this->call($route);
}
- return to(name('404'));
+ return to(route('404'));
}
/**
@@ -278,22 +247,24 @@ namespace Imperium\Routing {
*
* Display a route url by this name
*
- * @param $name
+ * @param string $name
*
+ * @param array $args
* @return string
*
* @throws Exception
- *
*/
- public function url(string $name): string
+ public static function url(string $name,array $args=[]): string
{
- $x = app()->model()->query()->from(self::ROUTES)->where('name',EQUAL,$name)->use_fetch()->get();
-
- is_true(not_def($x),true,'Route was not found');
+ $x = route($name,$args);
- $host = request()->getHost();
+ if (php_sapi_name() != 'cli')
+ {
+ $host = request()->getHost();
- return https() ? "https://$host$x->url" : "http://$host$x->url";
+ return https() ? "https://$host/$x" : "http://$host/$x";
+ }
+ return $x;
}
@@ -352,11 +323,11 @@ namespace Imperium\Routing {
*
* @param $route
*
- * @return mixed
+ * @return Response
*
* @throws Exception
*/
- private function call($route)
+ private function call($route): Response
{
array_shift($this->args);
@@ -392,9 +363,14 @@ namespace Imperium\Routing {
{
$x = call_user_func_array([$controller, $action], $this->args);
call_user_func_array( [$controller, self::AFTER_ACTION],[]);
- return $x;
+
+ return (new Response())->setContent($x);
+
}
- return call_user_func_array([$controller, $action], $this->args);
+
+ $x = call_user_func_array([$controller, $action], $this->args);
+
+ return (new Response())->setContent($x);
}
diff --git a/imperium/Tables/Column.php b/imperium/Tables/Column.php
index a1e84be..5364647 100644
--- a/imperium/Tables/Column.php
+++ b/imperium/Tables/Column.php
@@ -751,14 +751,14 @@ namespace Imperium\Tables {
$command = "ALTER TABLE {$this->current()} ADD COLUMN ";
- different($size,0) ? append($command,"$name $type($size) ") : append($command,"$name $type ");
+ def($size) ? append($command,"? ?(?) ") : append($command,"? ? ");
if(is_false($nullable))
{
$this->connexion->postgresql() ? append($command,' NOT NULL DEFAULT 0') : append($command,' NOT NULL');
}
- return $this->connexion->execute($command);
+ return def($size) ? $this->connexion->execute($command,$name,$type,$size) : $this->connexion->execute($command,$name,$type);
}
@@ -916,11 +916,11 @@ namespace Imperium\Tables {
$x = $length ? "($length)" : '';
- return equal($old,$this->primary_key()) ? false : $this->connexion->execute("ALTER TABLE {$this->current()} CHANGE COLUMN $old $new_name $type$x ;");
+ return equal($old,$this->primary_key()) ? false : $this->connexion->execute("ALTER TABLE {$this->current()} CHANGE COLUMN ? ? ??;",$old,$new_name,$type,$x);
break;
case POSTGRESQL :
case SQLITE :
- return equal($old,$this->primary_key()) ? false : $this->connexion->execute( "ALTER TABLE {$this->current()} RENAME COLUMN $old TO $new_name;");
+ return equal($old,$this->primary_key()) ? false : $this->connexion->execute( "ALTER TABLE {$this->current()} RENAME COLUMN ? TO ?;",$old,$new_name);
break;
default:
return false;
@@ -954,7 +954,7 @@ namespace Imperium\Tables {
break;
case POSTGRESQL :
- foreach ($this->connexion->request("select data_type FROM information_schema.columns WHERE table_name ='{$this->current()}';") as $type)
+ foreach ($this->connexion->request("select data_type FROM information_schema.columns WHERE table_name =' {$this->current()}'") as $type)
{
$x = collection(explode('(', trim($type->data_type,')')));
$types->push($x->get(0));
@@ -1232,7 +1232,7 @@ namespace Imperium\Tables {
case POSTGRESQL :
- foreach ($this->connexion->request("select data_type FROM information_schema.columns WHERE table_name =' {$this->current()}';") as $type)
+ foreach ($this->connexion->request("select data_type FROM information_schema.columns WHERE table_name ='{$this->current()}';") as $type)
{
$x = collection(explode('(', trim($type->data_type,')')));
$x->has_key(1) ? $types->push($x->get(1)) : $types->push(0);
@@ -1275,11 +1275,9 @@ namespace Imperium\Tables {
case MYSQL :
equal($column,$primary) ? $data->add(false) : $data->add($this->connexion->execute("ALTER TABLE $table DROP $column"),$column);
break;
-
case POSTGRESQL :
equal($column,$primary) ? $data->add(false) : $data->add($this->connexion->execute("ALTER TABLE $table DROP COLUMN $column RESTRICT"),$column);
break;
-
default :
return false;
break;
diff --git a/imperium/Tables/Table.php b/imperium/Tables/Table.php
index a3bd0db..4731828 100644
--- a/imperium/Tables/Table.php
+++ b/imperium/Tables/Table.php
@@ -191,10 +191,10 @@ namespace Imperium\Tables {
switch ($this->driver)
{
case MYSQL :
- return $this->connexion->execute("ALTER TABLE {$this->current()} COLLATE {$this->collation};");
+ return $this->connexion->execute("ALTER TABLE {$this->current()} COLLATE ?;",$this->collation);
break;
case POSTGRESQL :
- return $this->connexion->execute("update pg_database set datcollate='{$this->collation}', datctype='{$this->collation}' where datname = '{$this->connexion->base()}'");
+ return $this->connexion->execute("update pg_database set datcollate='?', datctype='?' where datname = '{$this->connexion->base()}'",$this->collation,$this->collation);
break;
default :
return false;
@@ -218,10 +218,10 @@ namespace Imperium\Tables {
switch ($this->driver)
{
case MYSQL :
- return $this->connexion->execute("ALTER TABLE {$this->current()} CHARACTER SET = {$this->charset};");
+ return $this->connexion->execute("ALTER TABLE {$this->current()} CHARACTER SET = ?;",$this->charset);
break;
case POSTGRESQL :
- return $this->connexion->execute("update pg_database set encoding = pg_char_to_encoding('{$this->charset}') where datname = '{$this->connexion->base()}'");
+ return $this->connexion->execute("update pg_database set encoding = pg_char_to_encoding('?') where datname = '{$this->connexion->base()}'",$this->charset);
break;
default :
return false;
@@ -270,7 +270,7 @@ namespace Imperium\Tables {
return $this->connexion->execute("TRUNCATE TABLE $table");
break;
case POSTGRESQL :
- return $this->connexion->execute("TRUNCATE TABLE $table RESTART IDENTITY");
+ return $this->connexion->execute("TRUNCATE TABLE $table RESTART IDENTITY");
break;
case SQLITE :
return $this->connexion->execute("DELETE FROM $table") && $this->connexion->execute('VACUUM');
@@ -300,10 +300,10 @@ namespace Imperium\Tables {
switch ($this->driver)
{
case MYSQL;
- return $this->connexion->execute("ALTER TABLE {$this->current()} DROP CONSTRAINT $constraint;");
+ return $this->connexion->execute("ALTER TABLE {$this->current()} DROP CONSTRAINT ?;",$constraint);
break;
case SQLITE:
- return $this->connexion->execute("ALTER TABLE {$this->current()} ALTER COLUMN $column DROP $constraint;");
+ return $this->connexion->execute("ALTER TABLE {$this->current()} ALTER COLUMN ? DROP ?;",$column,$constraint);
break;
default:
return false;
@@ -364,14 +364,14 @@ namespace Imperium\Tables {
*
* @method import
*
- * @param string $base
* @return bool
*
* @throws Exception
+ *
*/
- public function import(string $base = ''): bool
+ public function import(): bool
{
- return (new Import($base))->import();
+ return (new Import())->import();
}
/**
@@ -587,16 +587,14 @@ namespace Imperium\Tables {
*
* @method dump
*
- * @param string $table The table name
- *
+ * @param string[] $tables
* @return bool
*
* @throws Exception
- *
*/
- public function dump(string $table = ''): bool
+ public function dump(string ...$tables): bool
{
- return def($table) ? dumper(false,[$table]) : dumper(false,[$this->current()]);
+ return def($tables) ? dumper(false,$tables) : dumper(false,[$this->current()]);
}
@@ -631,7 +629,7 @@ namespace Imperium\Tables {
*/
public function select(int $id): array
{
- return $this->connexion->request("SELECT * FROM {$this->current()} WHERE {$this->column->for($this->current())->primary_key()} = $id" );
+ return $this->connexion->request("SELECT * FROM {$this->current()} WHERE {$this->column->for($this->current())->primary_key()} = ?",$id );
}
@@ -673,7 +671,7 @@ namespace Imperium\Tables {
*/
public function remove(int $id): bool
{
- return $this->connexion->execute("DELETE FROM {$this->current()} WHERE {$this->column->for($this->current())->primary_key()} = $id");
+ return $this->connexion->execute("DELETE FROM {$this->current()} WHERE {$this->column->for($this->current())->primary_key()} = ?",$id);
}
@@ -703,7 +701,7 @@ namespace Imperium\Tables {
switch ($this->driver)
{
case MYSQL:
- return $this->connexion->execute("ALTER TABLE {$this->current()} CONVERT TO CHARACTER SET $charset COLLATE $collate");
+ return $this->connexion->execute("ALTER TABLE {$this->current()} CONVERT TO CHARACTER SET ? COLLATE ? ",$charset,$collate);
break;
case POSTGRESQL:
return $this->set_charset($charset)->change_charset() && $this->set_collation($collate)->change_collation();
@@ -926,7 +924,10 @@ namespace Imperium\Tables {
{
if ($ignoreValues->empty())
{
- $columns->push("$k =" .quote($value));
+ if ($columns->numeric($value))
+ $columns->push("$k = $value");
+ else
+ $columns->push("$k = {$this->connexion->instance()->quote($value)}");
}else
{
@@ -935,7 +936,7 @@ namespace Imperium\Tables {
if ($columns->numeric($value))
$columns->push("$k = $value");
else
- $columns->push("$k = ".quote($value));
+ $columns->push("$k = {$this->connexion->instance()->quote($value)}");
}
}
}
@@ -944,10 +945,10 @@ namespace Imperium\Tables {
$columns = $columns->join(', ');
- $command = "UPDATE {$this->current()} SET $columns WHERE $primary = $id";
+ $sql = "UPDATE {$this->current()} SET $columns WHERE $primary = $id";
- return $this->connexion->execute($command);
+ return $this->connexion->execute($sql);
}
/**
@@ -971,13 +972,13 @@ namespace Imperium\Tables {
switch ($this->driver)
{
case MYSQL :
- $data = $this->connexion->execute("RENAME TABLE {$this->current()} TO $new_name");
+ $data = $this->connexion->execute("RENAME TABLE {$this->current()} TO ?",$new_name);
assign($data,$this->table,$new_name);
return $data;
break;
case POSTGRESQL :
case SQLITE :
- $data = $this->connexion->execute("ALTER TABLE {$this->current()} RENAME TO $new_name");
+ $data = $this->connexion->execute("ALTER TABLE {$this->current()} RENAME TO ?",$new_name);
assign($data,$this->table,$new_name);
return $data;
break;
diff --git a/imperium/Users/Users.php b/imperium/Users/Users.php
index 521cfdd..b9674c3 100644
--- a/imperium/Users/Users.php
+++ b/imperium/Users/Users.php
@@ -186,7 +186,7 @@ namespace Imperium\Users {
$this->check($driver);
- return $this->connexion->mysql() ? $this->connexion->execute("CREATE USER '$this->username'@'localhost' IDENTIFIED BY '$this->password'") : $this->connexion->execute("CREATE ROLE $this->username PASSWORD '$this->password'");
+ return $this->connexion->mysql() ? $this->connexion->execute("CREATE USER '{$this->username}'@'localhost' IDENTIFIED BY '$this->password'") : $this->connexion->execute("CREATE ROLE $this->username PASSWORD '$this->password'");
}
/**
@@ -267,7 +267,7 @@ namespace Imperium\Users {
*/
public function check(string $driver): Users
{
- not_in([Connect::MYSQL, Connect::POSTGRESQL], $driver, true, "The $driver driver has not users");
+ not_in([MYSQL, POSTGRESQL], $driver, true, "The $driver driver has not users");
return $this;
}
@@ -284,7 +284,7 @@ namespace Imperium\Users {
*/
public function hidden_users():array
{
- return config('db','hidden_users');
+ return db('hidden_users');
}
}
}
diff --git a/imperium/Validator/Validator.php b/imperium/Validator/Validator.php
new file mode 100644
index 0000000..613131e
--- /dev/null
+++ b/imperium/Validator/Validator.php
@@ -0,0 +1,94 @@
+<?php
+
+
+namespace Imperium\Validator {
+
+
+ use Exception;
+ use Symfony\Component\HttpFoundation\RedirectResponse;
+ use Symfony\Component\HttpFoundation\Request;
+
+
+ class Validator
+ {
+
+ /**
+ * @var Request
+ */
+ private $request;
+
+ public function __construct(Request $request)
+ {
+ $this->request = $request;
+ }
+
+ /**
+ *
+ * Check if an email is valid
+ *
+ * @param string $key
+ * @return Validator|RedirectResponse
+ *
+ * @throws Exception
+ *
+ */
+ public function email(string $key)
+ {
+ $x = $this->data($key);
+
+ return not_def($x) || !filter_var($x,FILTER_VALIDATE_EMAIL) ? $this->back("The %s email is not valid",$x) : $this;
+ }
+
+ /**
+ *
+ * Check if values are defined
+ *
+ * @param string ...$args
+ *
+ * @return Validator|RedirectResponse
+ *
+ * @throws Exception
+ *
+ */
+ public function define(string ...$args)
+ {
+ foreach ($args as $arg)
+ {
+ if (not_def($arg))
+ return $this->back("The %s argument is missing",$arg);
+ }
+ return $this;
+ }
+
+ /**
+ * @param string $msg
+ * @param mixed ...$args
+ * @return string
+ * @throws Exception
+ */
+ private function message(string $msg,... $args): string
+ {
+ return trans($msg,$args);
+ }
+
+ /**
+ * @param $key
+ * @return mixed|string
+ */
+ private function data($key)
+ {
+ return $this->request->request->has($key) ? $this->request->request->get($key) : '';
+ }
+
+ /**
+ * @param string $message
+ * @param mixed ...$args
+ * @return RedirectResponse
+ * @throws Exception
+ */
+ private function back(string $message,...$args):RedirectResponse
+ {
+ return back($this->message($message,$args),false);
+ }
+ }
+} \ No newline at end of file
diff --git a/imperium/View/View.php b/imperium/View/View.php
index 38046f6..4eb9ae5 100644
--- a/imperium/View/View.php
+++ b/imperium/View/View.php
@@ -318,7 +318,7 @@ namespace Imperium\View {
$functions->add(new TwigFunction('user',
- function (): Collection
+ function ()
{
return current_user();
}
diff --git a/logs/.gitignore b/logs/.gitignore
new file mode 100644
index 0000000..d6b7ef3
--- /dev/null
+++ b/logs/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/phinx.php b/phinx.php
index ed153f1..c52d844 100644
--- a/phinx.php
+++ b/phinx.php
@@ -4,8 +4,8 @@ $x = app()->connect();
return [
"paths" => [
- "migrations" => "dbs/migrations",
- "seeds" => "dbs/seeds"
+ "migrations" => "db/migrations",
+ "seeds" => "db/seeds"
],
"environments" =>
[
@@ -18,7 +18,7 @@ return [
"name" => $x->base(),
"user" => $x->user(),
"pass" => $x->password(),
- "port" => config('db','port'),
+ "port" => 3306,
]
]
]; \ No newline at end of file
diff --git a/phpunit.xml b/phpunit.xml
index 4168aaa..c033270 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -18,7 +18,7 @@
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">imperium/</directory>
- <directory suffix=".php">app/</directory>
+ <directory suffix=".php">helpers/</directory>
</whitelist>
</filter>
</phpunit>
diff --git a/tests/RouterTest.php b/tests/RouterTest.php
new file mode 100644
index 0000000..a842bb6
--- /dev/null
+++ b/tests/RouterTest.php
@@ -0,0 +1,66 @@
+<?php
+
+
+namespace Testing {
+
+
+ use GuzzleHttp\Psr7\ServerRequest;
+ use Imperium\Exception\Kedavra;
+ use PHPUnit\Framework\TestCase;
+ use Symfony\Component\HttpFoundation\Response;
+
+ class RouterTest extends TestCase
+ {
+
+ private function router(string $url,string $method): Response
+ {
+ return app()->router(new ServerRequest($method,$url))->run();
+ }
+
+
+ /**
+ * @throws \Exception
+ */
+ public function test_get()
+ {
+ $this->assertTrue($this->router('/',GET)->isSuccessful());
+ }
+ public function test_post()
+ {
+ $this->expectException(Kedavra::class);
+
+ $this->assertFalse($this->router('/u/willy/p',POST)->isSuccessful());
+ }
+
+ public function test_redirect()
+ {
+ $response = $this->router('/alex/',GET)->send();
+ $this->assertEquals(302,$response->getStatusCode());
+ $this->assertTrue($response->isRedirection());
+ $this->assertTrue($response->isRedirect('/error'));
+ $this->assertTrue($response->isRedirect(route('404')));
+ }
+
+ public function test_params()
+ {
+ $this->assertEquals('/edit/willy/20',app()->url('u','willy',20));
+ }
+
+
+ public function test_url()
+ {
+ $this->assertEquals("/",app()->url('root'));
+ }
+
+ public function test_root()
+ {
+ $this->assertTrue($this->router('/',GET)->isOk());
+ }
+
+ public function test_content()
+ {
+ $this->assertStringContainsString('<h1>welcome</h1>',$this->router('/',GET)->getContent());
+ }
+
+ }
+} \ No newline at end of file
diff --git a/tests/app/AppTest.php b/tests/app/AppTest.php
deleted file mode 100644
index f0437e2..0000000
--- a/tests/app/AppTest.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-
-namespace Testing\app {
-
-
- use Exception;
- use PHPUnit\Framework\TestCase;
- use Symfony\Component\HttpFoundation\Request;
-
- class AppTest extends TestCase
- {
-
- /**
- * @throws \Exception
- */
- public function test_request()
- {
- $this->assertInstanceOf(Request::class,app()->request());
- }
-
-
- /**
- * @throws Exception
- */
- public function test_register()
- {
- $form = secure_register_form('/', '127.0.0.1', '127.0.0.1', 'username', 'username will be use','username can be empty', 'email', 'email will be use', 'email can be empty', 'password', 'password will be use', 'password not be empty', 'confirm the password','create account', 'register', true,['fr' => 'French','en' => 'English' ],
- 'select', 'lang will be use','error','select a time zone','success', 'time zone will be use', fa('fas','fa-key'), fa('fas','fa-user'), fa('fas','fas-envelope'),fa('fas','fa-user-plus'), fa('fas', 'fa-globe'));
-
- $this->assertStringContainsString('/',$form);
- $this->assertStringContainsString('username will be use',$form);
- $this->assertStringContainsString('time zone will be use',$form);
- $this->assertStringContainsString('az',$form);
- $this->assertStringContainsString('placeholder="username"',$form);
- $this->assertStringContainsString('placeholder="email"',$form);
- $this->assertStringContainsString('placeholder="email"',$form);
- $this->assertStringContainsString('placeholder="password"',$form);
- $this->assertStringContainsString('placeholder="confirm the password"',$form);
- $this->assertStringContainsString('<option value="fr">French</option>',$form);
- $this->assertStringContainsString('<option value="en">English</option>',$form);
- $this->assertStringContainsString('<option value="">select</option>',$form);
- $this->assertStringContainsString('<option value="">select a time zone</option>',$form);
-
- $form = secure_register_form('/', '27.0.0.1', '127.0.0.1', 'username', 'username will be use','username can be empty', 'email', 'email will be use', 'email can be empty', 'password', 'password will be use', 'password not be empty', 'confirm the password','create account', 'register', true,['fr' => 'French','en' => 'English' ],
- 'select', 'lang will be use','error','select a time zone','success', 'time zone will be use', fa('fas','fa-key'), fa('fas','fa-user'), fa('fas','fas-envelope'),fa('fas','fa-user-plus'), fa('fas', 'fa-globe'));
-
- $this->assertEquals('',$form);
- }
-
-
- }
-} \ No newline at end of file
diff --git a/tests/collection/CollectionTest.php b/tests/collection/CollectionTest.php
deleted file mode 100644
index 172c8ed..0000000
--- a/tests/collection/CollectionTest.php
+++ /dev/null
@@ -1,293 +0,0 @@
-<?php
-
-
-namespace Testing\collection {
-
-
- use Imperium\App;
- use Imperium\Collection\Collection;
- use Imperium\File\File;
- use Testing\DatabaseTest;
-
- class CollectionTest extends DatabaseTest
- {
-
-
- public function test_instance()
- {
- $data = [];
- $this->assertInstanceOf(Collection::class,collection());
- $this->assertInstanceOf(Collection::class,collection($data));
- $this->assertInstanceOf(Collection::class,collection(array('1',2,3,3,5)));
- }
-
- public function test_convert_to_json()
- {
- $this->assertTrue(collection($this->mysql()->show_databases())->convert_to_json('app.json'));
-
- $this->assertTrue(collection($this->mysql()->show_databases())->convert_to_json('app.json','bases'));
- }
-
- public function test_remove_values()
- {
- $data = [1,2,3,4,5,6,7,8,9];
- $this->assertNotContains('8',collection($data)->remove_values(8)->collection());
- $this->assertNotContains('9',collection($data)->remove_values(9)->collection());
- }
-
- public function test_json()
- {
- $filename = 'app.json';
- $this->assertNotEmpty(\collection($this->mysql()->show_databases())->convert_to_json($filename));
- $this->assertTrue(File::exist($filename));
- $this->assertNotEmpty(File::content($filename));
-
- $this->assertNotEmpty(\collection($this->mysql()->show_databases())->json());
- }
-
- public function test_data()
- {
- $data = \collection(App::ALL_TYPES);
- $types = App::NUMERIC_TYPES;
- $this->assertContains('int',$data->data($types));
- $this->assertContains('serial',$data->data($types));
- $this->assertNotContains('varchar',$data->data($types));
-
- }
-
- public function test_search()
- {
- $this->assertEquals('zen',\collection($this->mysql()->show_databases())->search('zen')->result());
- }
- public function test_count()
- {
- $this->assertNotEmpty(\collection($this->mysql()->show_databases())->count_values());
- }
- public function test_double()
- {
- $data = \collection();
-
- $data->double('mysql',$this->mysql()->users()->show(),'users')->double('mysql',$this->mysql()->table()->show(),'tables');
-
- $this->assertContains('root',$data->value('mysql','users'));
- $this->assertContains('model',$data->value('mysql','tables'));
-
- $data->clear()->double(0,$this->mysql()->model()->from('model')->all(),'model')->double(1,$this->mysql()->model()->from('users'),'users');
-
- $this->assertNotEmpty($data->value(0,'model'));
- $this->assertNotEmpty($data->value(1,'users'));
- }
- /**
- * @throws \Exception
- */
- public function test_change_value()
- {
- $data = [1,2,3,4,5,6,7,8,9];
- $this->assertNotContains('9',collection($data)->change_value(9,10));
- }
-
- public function test_push()
- {
- $data = collection();
-
- $data->push(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
- $this->assertEquals([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],$data->collection());
- $this->assertEquals([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],$data->collection());
- }
- public function test_stack()
- {
- $data = collection();
-
- $data->stack(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
- $this->assertEquals([20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1],$data->collection());
-
- }
-
- public function test_init()
- {
- $data = collection();
- $this->assertEquals(0,$data->init());
-
- }
-
-
- public function test_end()
- {
- $data = collection([1,2,3]);
-
- $this->assertEquals(3,$data->last());
- }
-
- public function test_key()
- {
- $data = collection([0 => 5]);
- $data->rewind();
- $this->assertEquals(0,$data->key());
- $this->assertEquals(5,$data->current());
- }
-
- public function test_start()
- {
- $data = collection([1,2,3]);
-
- $this->assertEquals(1,$data->begin());
- }
-
- public function test_length()
- {
- $data = collection();
- $this->assertEquals(0,$data->length());
-
- $data->push('123','124',50);
- $this->assertEquals(3,$data->length());
-
- }
-
-
-
- public function test_is()
- {
- $data = collection();
-
- $this->assertTrue($data->numeric('1'));
- $this->assertTrue($data->numeric(12));
- $this->assertTrue($data->string("azadz"));
- $this->assertTrue($data->string("lerfzz"));
- $this->assertTrue($data->empty());
- }
-
- public function test_get()
- {
- $data = collection();
-
- $data->add(10,'note')->add(15,'age')->add(25 ,'euros');
-
- $this->assertEquals(10,$data->get('note'));
- $this->assertEquals(15,$data->get('age'));
- $this->assertEquals(25,$data->get('euros'));
- }
-
- public function test_remove()
- {
- $data = collection();
-
- $data->add(10,'note')->add(15,'age')->add(25 ,'euros');
-
- $data->remove('note');
- $this->assertNotContains('note',$data->collection());
- }
-
- public function test_join()
- {
- $data = collection();
- $data->push('i am a boy','you a little girl');
- $this->assertEquals('i am a boy, you a little girl',$data->join(', '));
-
- $data->clear()->push('i am a boy','you a little girl');
- $this->assertEquals('i am a girl, you a little girl',$data->join(', ',true,'boy','girl'));
- }
-
- public function test_get_values()
- {
- $data = collection();
- $data->add('i','a')->add('am','b')->add('a','c')->add('boy','d');
- $this->assertEquals(['i','am','a','boy'],$data->values());
- $this->assertEquals(['a','b','c','d'],$data->keys());
- }
-
- public function test_for()
- {
- $data = collection(array('i','have','a','dog','and','i','eat','a','big','sandwich'));
- $data->rewind();
- while ($data->valid())
- {
- $this->assertNotEmpty($data->current());
- $data->next();
- }
-
- }
- public function test_array_prev()
- {
- $data = collection(['note' =>10 ,'age' => 18,'phone' => 564]);
- $this->assertEquals(10,$data->value_before_key('age'));
- $this->assertEquals(18,$data->value_before_key('phone'));
-
- $data = collection([10 , 18, 564]);
- $this->assertEquals(10,$data->value_before_key(18));
- $this->assertEquals(18,$data->value_before_key(564));
- $data = collection([10]);
- $this->assertEquals(10,$data->value_before_key(10));
-
- }
-
- public function test_reverse()
- {
- $data = collection(['boy','a','am','i']);
-
- $this->assertEquals(['i','am','a','boy'],$data->reverse());
- }
-
- public function test_each()
- {
- $data = collection(['boy','a','am','i']);
-
- $this->assertEquals(['BOY','A','AM','I'],$data->each('strtoupper')->collection());
- $this->assertEquals(['boy','a','am','i'],$data->each('strtoupper')->each('strtolower')->collection());
- }
-
- public function test_before_and_after()
- {
- $data = collection(['do','re','mi','fa','sol','la','si','do']);
- $data->rewind();
-
- $this->assertEquals('re',$data->after());
-
- $this->assertEquals('mi',$data->after());
-
- $this->assertEquals('fa',$data->after());
-
- $this->assertEquals('mi',$data->before());
-
- $this->assertEquals('re',$data->before());
-
-
- $this->assertEquals('do',$data->before());
- $data->next();
- $data->next();
- $data->next();
- $data->next();
- $this->assertEquals('sol',$data->current());
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_print()
- {
- $m = $this->mysql()->model()->from(current_table());
- $data = collection($m->all());
-
- $this->assertNotEmpty($data->print(true,$m->columns()));
- $this->assertNotEmpty($data->print(true));
- $this->assertNotEmpty($data->print(false,$m->columns(),true));
- $this->assertNotEmpty($data->print(false,[],true));
- $this->assertNotEmpty($data->print(false,[],false,'<header>','</header>','<h1>','text-uppercase','<hr>'));
-
- }
-
- public function test()
- {
-
- $data = \collection();
- $data->offsetSet('name','willy');
- $this->assertEquals('name',$data->offsetGet('willy'));
- $this->assertEquals(true,$data->offsetExists('willy'));
- $data->offsetUnset('willy');
- $this->assertEquals(false,$data->offsetExists('willy'));
-
- $this->assertEquals('',$data->offsetGet('willy'));
-
- }
- }
-} \ No newline at end of file
diff --git a/tests/config/ConfigTest.php b/tests/config/ConfigTest.php
deleted file mode 100644
index 0619dae..0000000
--- a/tests/config/ConfigTest.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-
-namespace Testing\config {
-
-
- use PHPUnit\Framework\TestCase;
-
- class ConfigTest extends TestCase
- {
-
- /**
- * @throws \Exception
- */
- public function test_get()
- {
- $this->assertEquals('zen',config('db.example','base'));
- $this->assertEquals('root',config('db.example','password'));
- $this->assertEquals('root',config('db.example','username'));
- $this->assertEquals(['phinxlog'],config('db.example','hidden_tables'));
- $this->assertEquals([],config('db.example','hidden_bases'));
- $this->assertEquals(true,config('form','save'));
- $this->assertEquals(2,config('form','padding'));
- }
-
- /**
- * @throws \Exception
- */
- public function test_not_fond_key()
- {
- $this->expectException(\Exception::class);
- config('form','azdazdadaz');
- }
-
- /**
- * @throws \Exception
- */
- public function test_exception()
- {
- $this->expectException(\Exception::class);
- config('a','a');
- config('views','a');
- }
- }
-} \ No newline at end of file
diff --git a/tests/csrf/CsrfTest.php b/tests/csrf/CsrfTest.php
deleted file mode 100644
index d07361d..0000000
--- a/tests/csrf/CsrfTest.php
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-
-namespace Testing\csrf {
-
-
- use Exception;
- use GuzzleHttp\Psr7\ServerRequest;
- use Imperium\Security\Csrf\Csrf;
- use PHPUnit\Framework\TestCase;
-
- class CsrfTest extends TestCase
- {
-
- /**
- * @var Csrf
- *
- */
- private $csrf;
- /**
- * @var ServerRequest
- */
- private $request;
-
- /**
- * @throws Exception
- */
- public function setUp():void
- {
- $this->csrf = new Csrf(app()->session());
- $this->request = new ServerRequest('POST',name('del',POST));
- }
-
- /**
- * @throws Exception
- */
- public function test()
- {
- $token = $this->csrf->token();
-
- $this->assertNotEmpty($token);
- }
-
- /**
- * @throws Exception
- */
- public function test_exec()
- {
- $this->expectException(Exception::class);
-
-
- app()->router($this->request,'Shaolin\Controllers','core')->run();
-
- }
-
- /**
- * @throws Exception
- */
- public function test_check()
- {
- $this->expectException(Exception::class);
- $this->csrf->check($this->request);
- }
-
- }
-} \ No newline at end of file
diff --git a/tests/dir/DirTest.php b/tests/dir/DirTest.php
deleted file mode 100644
index e5eb757..0000000
--- a/tests/dir/DirTest.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-namespace Testing\dir {
-
- use Imperium\File\File;
- use PHPUnit\Framework\TestCase;
- use Imperium\Directory\Dir;
-
- class DirTest extends TestCase
- {
- /**
- * @throws \Exception
- */
- public function test_dir_create_and_remove()
- {
- $dir = "code";
- $this->assertTrue(Dir::create($dir));
- $this->assertTrue(File::create("$dir/app.json"));
- $this->assertTrue(Dir::clear($dir));
- $this->assertTrue(File::not_exist("$dir/app.json"));
- $this->assertTrue(Dir::is($dir));
- $this->assertTrue(Dir::remove($dir));
- }
- }
-}
diff --git a/tests/flash/FlashTest.php b/tests/flash/FlashTest.php
deleted file mode 100644
index ff37dfe..0000000
--- a/tests/flash/FlashTest.php
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-
-namespace Testing\flash {
-
-
- use Imperium\Flash\Flash;
- use PHPUnit\Framework\TestCase;
-
- class FlashTest extends TestCase
- {
-
- /**
- * @var Flash
- */
- private $flash;
-
- public function setUp(): void
- {
- $this->flash = new Flash();
- }
-
- /**
- * @throws \Exception
- */
- public function test_get()
- {
- $this->flash->success('linux was found');
- $this->flash->failure('Windows is bad');
- $this->assertEquals('linux was found',$this->flash->get(Flash::SUCCESS_KEY));
- $this->assertEquals('',$this->flash->get(Flash::SUCCESS_KEY));
- $this->assertEquals('Windows is bad',$this->flash->get(Flash::FAILURE_KEY));
- $this->assertEquals('',$this->flash->get(Flash::FAILURE_KEY));
- }
-
- /**
- * @throws \Exception
- */
- public function test_display()
- {
- $this->flash->success('linux was found');
- $this->flash->failure('Windows is bad');
- $this->assertStringContainsString('linux was found',$this->flash->display(Flash::SUCCESS_KEY));
- $this->assertEquals('',$this->flash->display(Flash::SUCCESS_KEY));
- $this->assertStringContainsString('Windows is bad',$this->flash->display(Flash::FAILURE_KEY));
- $this->assertEquals('',$this->flash->display(Flash::FAILURE_KEY));
- }
-
-
- public function test_has()
- {
- $this->flash->success('a');
- $this->assertTrue($this->flash->has('success'));
- $this->assertFalse($this->flash->has('failure'));
- }
- /**
- * @throws \Exception
- */
- public function test_exception()
- {
- $this->expectException(\Exception::class);
-
- $this->flash->success('a');
- $this->flash->get('a');
- }
- }
-} \ No newline at end of file
diff --git a/tests/form/FormTest.php b/tests/form/FormTest.php
deleted file mode 100644
index aef6189..0000000
--- a/tests/form/FormTest.php
+++ /dev/null
@@ -1,712 +0,0 @@
-<?php
-
-namespace Testing\Form {
-
-
- use Exception;
- use Testing\DatabaseTest;
- use Imperium\Html\Form\Form;
-
- class FormTest extends DatabaseTest
- {
-
- /**
- * @var string
- *
- */
- private $table;
-
- public function setUp(): void
- {
- $this->table = 'model';
- }
-
- public function test_save()
- {
- $this->assertNotEmpty(form('a','a')->save()->input('text','username','username')->get());
- }
- public function test_start()
- {
- $class = 'form-horizontal';
-
- $form = form('a','a','','','POST',true)->get();
- $this->assertStringContainsString("enctype",$form);
- $this->assertStringContainsString('method="post"',$form);
- $this->assertStringContainsString('action="a"',$form);
- $this->assertStringContainsString('id="a"',$form);
- $this->assertStringNotContainsString($class,$form);
-
- $form = form('a','a',$class,'','POST',true)->get();
- $this->assertStringContainsString("enctype",$form);
- $this->assertStringContainsString('method="post"',$form);
- $this->assertStringContainsString('action="a"',$form);
- $this->assertStringContainsString('id="a"',$form);
- $this->assertStringContainsString($class,$form);
-
-
- $form = form('a','a','','','POST',false)->get();
- $this->assertStringNotContainsString("enctype",$form);
- $this->assertStringContainsString('method="post"',$form);
- $this->assertStringContainsString('action="a"',$form);
- $this->assertStringContainsString('id="a"',$form);
- $this->assertStringNotContainsString($class,$form);
-
- $form = form('a','a','',$class,'POST',false)->get();
- $this->assertStringNotContainsString("enctype",$form);
- $this->assertStringContainsString('method="post"',$form);
- $this->assertStringContainsString('action="a"',$form);
- $this->assertStringContainsString('id="a"',$form);
- $this->assertStringContainsString($class,$form);
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_hide()
- {
- $form = form('a','a','','','POST',false)->hide()->input(Form::HIDDEN,'id','')->end_hide()->get();
- $this->assertStringContainsString(Form::HIDE_CLASS,$form);
- $this->assertStringContainsString(Form::HIDDEN,$form);
- $this->assertStringEndsWith('</div></form>',$form);
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_file()
- {
- $ico = fa('fas','fa-file');
- $form = form('a','a','','','POST',false)->file('sql','sql file')->get();
- $this->assertStringContainsString('name="sql"',$form);
- $this->assertStringContainsString('sql file',$form);
- $this->assertStringNotContainsString($ico,$form);
-
- $form = form('a','a','','','POST',false)->file('sql','sql file',$ico)->get();
-
- $this->assertStringContainsString('name="sql"',$form);
- $this->assertStringContainsString('sql file',$form);
- $this->assertStringContainsString($ico,$form);
- }
-
- /**
- * @throws \Exception
- */
- public function test_textarea()
- {
- $form = form('a','a')->textarea('name','value','','',false)->get();
-
- $this->assertStringNotContainsString('autofocus',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringContainsString('10',$form);
-
- $form = form('a','a')->textarea('name','value','','',false)->get();
-
- $this->assertStringNotContainsString('autofocus',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringContainsString('10',$form);
-
- $form = form('a','a')->textarea('name','value','','',true)->get();
-
- $this->assertStringContainsString('autofocus',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringContainsString('10',$form);
-
- $form = form('a','a')->textarea('name','value','','',true)->get();
-
- $this->assertStringContainsString('autofocus',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringContainsString('10',$form);
-
-
- $form = form('a','a')->textarea('name','value','','',false)->get();
-
- $this->assertStringContainsString('placeholder="value"',$form);
- $this->assertStringNotContainsString('autofocus',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringContainsString('10',$form);
- }
-
- /**
- * @throws \Exception
- */
- public function test_validation()
- {
- $success ="success";
- $fail ="fail";
-
- $form = new Form();
-
- $x = $form->validate()->start('a','a','confirm','')->input(Form::TEXT,'name','name','',$success,$fail)->get();
-
- $this->assertStringContainsString('confirm',$x);
- $this->assertStringContainsString($success,$x);
- $this->assertStringContainsString($fail,$x);
-
- $form = new Form();
- $x = $form->validate()->start('a','a','confirm','',true)->select(false,'select',['a','a'],$success,$fail)->get();
-
- $this->assertStringContainsString('confirm',$x);
- $this->assertStringContainsString($success,$x);
- $this->assertStringContainsString($fail,$x);
-
- $form = new Form();
- $x = $form->validate()->start('a','a','confirm','form-control',true)->textarea('name','name',$success,$fail)->get();
- $this->assertStringContainsString('confirm',$x);
-
- $this->assertStringContainsString($success,$x);
- $this->assertStringContainsString($fail,$x);
- }
-
- public function test_execp()
- {
- $this->expectException(Exception::class);
-
- $x = new Form();
- $x->validate()->start('a','a')->textarea('a','a')->get();
- }
- public function test_reset()
- {
- $icon = fa('fas','fa-linux');
- $form = \form('a','a')->reset('reset')->get();
-
- $this->assertStringContainsString('reset',$form);
- $this->assertStringContainsString('btn btn-lg btn-danger',$form);
- $this->assertStringNotContainsString($icon,$form);
-
- $form = \form('a','a')->reset('reset',$icon)->get();
-
- $this->assertStringContainsString('reset',$form);
- $this->assertStringContainsString('btn btn-lg btn-danger',$form);
- $this->assertStringContainsString($icon,$form);
- }
-
- /**
- * @throws \Exception
- */
- public function test_input()
- {
- $icon = fa('fas','fa-linux');
-
- $form = form('a','a')->input(Form::TEXT,'name','name')->get();
-
- $this->assertStringContainsString('placeholder="name"',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringNotContainsString($icon,$form);
-
- $form = form('a','a')->input(Form::TEXT,'name','name',$icon)->get();
-
- $this->assertStringContainsString('placeholder="name"',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringContainsString($icon,$form);
-
- $form = form('a','a')->input(Form::TEXT,'name','name',$icon,'','','maximus',false,false,false)->get();
-
- $this->assertStringNotContainsString('required',$form);
- $this->assertStringNotContainsString('autofocus',$form);
- $this->assertStringNotContainsString('autocomplete="on"',$form);
- $this->assertStringContainsString('placeholder="name"',$form);
- $this->assertStringContainsString('maximus',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringContainsString($icon,$form);
-
- $form = form('a','a')->input(Form::TEXT,'name','name',$icon,'','','maximus',false,true,false)->get();
-
- $this->assertStringNotContainsString('required',$form);
- $this->assertStringContainsString('autofocus',$form);
- $this->assertStringNotContainsString('autocomplete="on"',$form);
- $this->assertStringContainsString('placeholder="name"',$form);
- $this->assertStringContainsString('maximus',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringContainsString($icon,$form);
-
- $form = form('a','a')->input(Form::TEXT,'name','name',$icon,'','','maximus',false,false,true)->get();
-
- $this->assertStringNotContainsString('required',$form);
- $this->assertStringNotContainsString('autofocus',$form);
- $this->assertStringContainsString('autocomplete="on"',$form);
- $this->assertStringContainsString('placeholder="name"',$form);
- $this->assertStringContainsString('maximus',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringContainsString($icon,$form);
-
-
- $form = form('a','a')->input(Form::TEXT,'name','name',$icon,'','','',false,true,true)->get();
-
- $this->assertStringNotContainsString('required',$form);
- $this->assertStringContainsString('autofocus',$form);
- $this->assertStringContainsString('autocomplete="on"',$form);
- $this->assertStringContainsString('placeholder="name"',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringContainsString($icon,$form);
-
-
-
- $form = form('a','a')->input(Form::TEXT,'name','name',$icon,'','','',true,false,false)->get();
-
- $this->assertStringContainsString('required',$form);
- $this->assertStringNotContainsString('autofocus',$form);
- $this->assertStringNotContainsString('autocomplete="on"',$form);
- $this->assertStringContainsString('placeholder="name"',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringContainsString($icon,$form);
-
-
-
- $form = form('a','a')->input(Form::TEXT,'name','name',$icon,'','','',true,false,true)->get();
-
- $this->assertStringContainsString('required',$form);
- $this->assertStringNotContainsString('autofocus',$form);
- $this->assertStringContainsString('autocomplete="on"',$form);
- $this->assertStringContainsString('placeholder="name"',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringContainsString($icon,$form);
-
- $form = form('a','a')->input(Form::TEXT,'name','name',$icon,'','','',true,true,false)->get();
-
- $this->assertStringContainsString('required',$form);
- $this->assertStringContainsString('autofocus',$form);
- $this->assertStringNotContainsString('autocomplete="on"',$form);
- $this->assertStringContainsString('placeholder="name"',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringContainsString($icon,$form);
-
- $form = form('a','a')->input(Form::TEXT,'name','name',$icon,'','','',true,true,true)->get();
-
- $this->assertStringContainsString('required',$form);
- $this->assertStringContainsString('autofocus',$form);
- $this->assertStringContainsString('autocomplete="on"',$form);
- $this->assertStringContainsString('placeholder="name"',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringContainsString($icon,$form);
-
-
- $form = form('a','a')->input(Form::TEXT,'name','name','','','','maximus',false,false,false)->get();
-
- $this->assertStringNotContainsString('required',$form);
- $this->assertStringNotContainsString('autofocus',$form);
- $this->assertStringNotContainsString('autocomplete="on"',$form);
- $this->assertStringContainsString('placeholder="name"',$form);
- $this->assertStringContainsString('maximus',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringNotContainsString($icon,$form);
-
- $form = form('a','a')->input(Form::TEXT,'name','name','','','','maximus',false,true,false)->get();
-
- $this->assertStringNotContainsString('required',$form);
- $this->assertStringContainsString('autofocus',$form);
- $this->assertStringNotContainsString('autocomplete="on"',$form);
- $this->assertStringContainsString('placeholder="name"',$form);
- $this->assertStringContainsString('maximus',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringNotContainsString($icon,$form);
-
- $form = form('a','a')->input(Form::TEXT,'name','name','','','','maximus',false,false,true)->get();
-
- $this->assertStringNotContainsString('required',$form);
- $this->assertStringNotContainsString('autofocus',$form);
- $this->assertStringContainsString('autocomplete="on"',$form);
- $this->assertStringContainsString('placeholder="name"',$form);
- $this->assertStringContainsString('maximus',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringNotContainsString($icon,$form);
-
-
- $form = form('a','a')->input(Form::TEXT,'name','name',$icon,'','','',false,true,true)->get();
-
- $this->assertStringNotContainsString('required',$form);
- $this->assertStringContainsString('autofocus',$form);
- $this->assertStringContainsString('autocomplete="on"',$form);
- $this->assertStringContainsString('placeholder="name"',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringContainsString($icon,$form);
-
-
-
- $form = form('a','a')->input(Form::TEXT,'name','name',$icon,'','','',true,false,false)->get();
-
- $this->assertStringContainsString('required',$form);
- $this->assertStringNotContainsString('autofocus',$form);
- $this->assertStringNotContainsString('autocomplete="on"',$form);
- $this->assertStringContainsString('placeholder="name"',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringContainsString($icon,$form);
-
-
-
- $form = form('a','a')->input(Form::TEXT,'name','name','','','','',true,false,true)->get();
-
- $this->assertStringContainsString('required',$form);
- $this->assertStringNotContainsString('autofocus',$form);
- $this->assertStringContainsString('autocomplete="on"',$form);
- $this->assertStringContainsString('placeholder="name"',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringNotContainsString($icon,$form);
-
- $form = form('a','a')->input(Form::TEXT,'name','name','','','','',true,true,false)->get();
-
- $this->assertStringContainsString('required',$form);
- $this->assertStringContainsString('autofocus',$form);
- $this->assertStringNotContainsString('autocomplete="on"',$form);
- $this->assertStringContainsString('placeholder="name"',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringNotContainsString($icon,$form);
-
- $form = form('a','a')->input(Form::TEXT,'name','name','','','','',true,true,true)->get();
-
- $this->assertStringContainsString('required',$form);
- $this->assertStringContainsString('autofocus',$form);
- $this->assertStringContainsString('autocomplete="on"',$form);
- $this->assertStringContainsString('placeholder="name"',$form);
- $this->assertStringContainsString('name="name"',$form);
- $this->assertStringNotContainsString($icon,$form);
- }
- /**
- * @throws \Exception
- */
- public function test_size()
- {
-
- $class = collection(config('form','class'))->get('submit');
- $form = form('a','a')->large()->input(Form::TEXT,'sql','sql file')->submit('a','submit')->get();
- $this->assertStringContainsString(Form::LARGE_CLASS,$form);
- $this->assertStringNotContainsString(Form::SMALL_CLASS,$form);
- $this->assertStringContainsString($class,$form);
-
- $form = form('a','a')->small()->input(Form::TEXT,'sql','sql file')->submit('a','a')->get();
- $this->assertStringContainsString(Form::SMALL_CLASS,$form);
- $this->assertStringNotContainsString(Form::LARGE_CLASS,$form);
- $this->assertStringContainsString($class,$form);
-
- $form = form('a','a')->large()->select(true,'table',[1,2,3])->get();
- $this->assertStringContainsString(Form::LARGE_CLASS,$form);
- $this->assertStringNotContainsString(Form::SMALL_CLASS,$form);
-
- $form = form('a','a')->small()->select(false,'table',[1,2,3])->get();
- $this->assertStringContainsString(Form::SMALL_CLASS,$form);
- $this->assertStringNotContainsString(Form::LARGE_CLASS,$form);
-
- $form = form('a','a')->large()->textarea('table','a',10,10)->get();
- $this->assertStringContainsString(Form::LARGE_CLASS,$form);
- $this->assertStringNotContainsString(Form::SMALL_CLASS,$form);
-
- $form = form('a','a')->small()->textarea('table','a',10,10)->get();
- $this->assertStringContainsString(Form::SMALL_CLASS,$form);
- $this->assertStringNotContainsString(Form::LARGE_CLASS,$form);
-
- $form = form('a','a')->large()->file('table','a')->get();
- $this->assertStringContainsString(Form::LARGE_CLASS,$form);
- $this->assertStringNotContainsString(Form::SMALL_CLASS,$form);
-
- $form = form('a','a')->small()->file('table','a')->get();
- $this->assertStringContainsString(Form::SMALL_CLASS,$form);
- $this->assertStringNotContainsString(Form::LARGE_CLASS,$form);
-
-
- $form = form('a','a')->large(false)->input(Form::TEXT,'sql','sql file')->get();
- $this->assertStringContainsString(Form::BASIC_CLASS,$form);
- $this->assertStringNotContainsString(Form::LARGE_CLASS,$form);
- $this->assertStringNotContainsString(Form::SMALL_CLASS,$form);
-
- $form = form('a','a')->small(false)->input(Form::TEXT,'sql','sql file')->get();
- $this->assertStringContainsString(Form::BASIC_CLASS,$form);
- $this->assertStringNotContainsString(Form::LARGE_CLASS,$form);
- $this->assertStringNotContainsString(Form::SMALL_CLASS,$form);
- $form = form('a','a')->large(false)->select(true,'table',[1,2,3])->get();
- $this->assertStringContainsString(Form::BASIC_CLASS,$form);
- $this->assertStringNotContainsString(Form::LARGE_CLASS,$form);
- $this->assertStringNotContainsString(Form::SMALL_CLASS,$form);
-
- $form = form('a','a')->small(false)->select(false,'table',[1,2,3])->get();
- $this->assertStringContainsString(Form::BASIC_CLASS,$form);
- $this->assertStringNotContainsString(Form::LARGE_CLASS,$form);
- $this->assertStringNotContainsString(Form::SMALL_CLASS,$form);
-
- $form = form('a','a')->large(false)->textarea('table','a',10,10)->get();
- $this->assertStringContainsString(Form::BASIC_CLASS,$form);
- $this->assertStringNotContainsString(Form::LARGE_CLASS,$form);
- $this->assertStringNotContainsString(Form::SMALL_CLASS,$form);
-
- $form = form('a','a')->small(false)->textarea('table','a',10,10)->get();
- $this->assertStringContainsString(Form::BASIC_CLASS,$form);
- $this->assertStringNotContainsString(Form::LARGE_CLASS,$form);
- $this->assertStringNotContainsString(Form::SMALL_CLASS,$form);
-
- $form = form('a','a')->large(false)->file('table','a')->get();
- $this->assertStringContainsString(Form::BASIC_CLASS,$form);
- $this->assertStringNotContainsString(Form::LARGE_CLASS,$form);
- $this->assertStringNotContainsString(Form::SMALL_CLASS,$form);
-
- $form = form('a','a')->small(false)->file('table','a')->get();
- $this->assertStringContainsString(Form::BASIC_CLASS,$form);
- $this->assertStringNotContainsString(Form::LARGE_CLASS,$form);
- $this->assertStringNotContainsString(Form::SMALL_CLASS,$form);
- }
-
- public function test_checkbox()
- {
- $form = form('a','a')->checkbox('super','check me')->get();
- $this->assertStringContainsString('name="super"',$form);
- $this->assertStringContainsString('check me',$form);
- $this->assertStringNotContainsString('checked',$form);
-
- $form = form('a','a')->checkbox('super','check me')->get();
- $this->assertStringContainsString('name="super"',$form);
- $this->assertStringContainsString('check me',$form);
- $this->assertStringNotContainsString('checked',$form);
-
- $form = form('a','a')->checkbox('super','check me',true)->get();
- $this->assertStringContainsString('name="super"',$form);
- $this->assertStringContainsString('check me',$form);
- $this->assertStringContainsString('checked',$form);
- }
-
- public function test_button()
- {
- $form = form('a','a')->button(Form::SUBMIT,'submit')->get();
-
- $this->assertStringContainsString('type="submit"',$form);
- $form = form('a','a')->button(Form::RESET,'submit')->get();
-
- $this->assertStringContainsString('type="reset"',$form);
- $form = form('a','a')->button(Form::BUTTON,'submit')->get();
-
- $this->assertStringContainsString('type="button"',$form);
- }
-
-
-
- public function test_select()
- {
- $icon = fa('fas','fa-trash');
-
- $form = form('a','a')->select(true,'age',[15,18,19],'','','',false,false)->get();
-
- $this->assertStringNotContainsString('required',$form);
- $this->assertStringNotContainsString($icon,$form);
- $this->assertStringNotContainsString('multiple',$form);
- $this->assertStringContainsString('name="age"',$form);
- $this->assertStringContainsString('<option value="0">15</option>',$form);
- $this->assertStringContainsString('<option value="1">18</option>',$form);
- $this->assertStringContainsString('<option value="2">19</option>',$form);
-
- $form = form('a','a')->select(false,'age',[15,18,19],$icon,'','',false,false)->get();
-
- $this->assertStringNotContainsString('required',$form);
- $this->assertStringContainsString($icon,$form);
- $this->assertStringNotContainsString('multiple',$form);
- $this->assertStringContainsString('name="age"',$form);
- $this->assertStringContainsString('<option value="15">15</option>',$form);
- $this->assertStringContainsString('<option value="18">18</option>',$form);
-
-
- $form = form('a','a')->select(true,'age', [15,18,19], '' , '' , '' , false, false)->get();
-
- $this->assertStringNotContainsString('required',$form);
- $this->assertStringNotContainsString($icon,$form);
- $this->assertStringNotContainsString('multiple',$form);
- $this->assertStringContainsString('name="age"',$form);
- $this->assertStringContainsString('<option value="0">15</option>',$form);
- $this->assertStringContainsString('<option value="1">18</option>',$form);
- $this->assertStringContainsString('<option value="2">19</option>',$form);
-
- $form = form('a','a')->select(false,'age', [15,18,19], $icon , '' , '',false, false)->get();
-
- $this->assertStringNotContainsString('required',$form);
- $this->assertStringContainsString($icon,$form);
- $this->assertStringNotContainsString('multiple',$form);
- $this->assertStringContainsString('name="age"',$form);
- $this->assertStringContainsString('<option value="15">15</option>',$form);
- $this->assertStringContainsString('<option value="18">18</option>',$form);
-
- $form = form('a','a')->select(false,'age', [15,18,19], $icon , '' , '' , true, false)->get();
-
- $this->assertStringNotContainsString('required',$form);
- $this->assertStringContainsString($icon,$form);
- $this->assertStringContainsString('multiple',$form);
- $this->assertStringContainsString('name="age"',$form);
- $this->assertStringContainsString('<option value="15">15</option>',$form);
- $this->assertStringContainsString('<option value="18">18</option>',$form);
- $this->assertStringContainsString('<option value="19">19</option>',$form);
-
- $form = form('a','a')->select(false,'age', [15,18,19], $icon , '' , '', true, false)->get();
-
- $this->assertStringNotContainsString('required',$form);
- $this->assertStringContainsString($icon,$form);
- $this->assertStringContainsString('multiple',$form);
- $this->assertStringContainsString('name="age"',$form);
- $this->assertStringContainsString('<option value="15">15</option>',$form);
- $this->assertStringContainsString('<option value="18">18</option>',$form);
-
- $form = form('a','a')->select(false,'age', [15,18,19], $icon , '' , '' , true, true)->get();
-
- $this->assertStringContainsString('required',$form);
- $this->assertStringContainsString($icon,$form);
- $this->assertStringContainsString('multiple',$form);
- $this->assertStringContainsString('name="age"',$form);
- $this->assertStringContainsString('<option value="15">15</option>',$form);
- $this->assertStringContainsString('<option value="18">18</option>',$form);
- $this->assertStringContainsString('<option value="19">19</option>',$form);
-
- $form = form('a','a')->select(false,'age', [15,18,19], $icon , '' , '', true, true)->get();
-
- $this->assertStringContainsString('required',$form);
- $this->assertStringContainsString($icon,$form);
- $this->assertStringContainsString('multiple',$form);
- $this->assertStringContainsString('name="age"',$form);
- $this->assertStringContainsString('<option value="15">15</option>',$form);
- $this->assertStringContainsString('<option value="18">18</option>',$form);
-
-
-
- }
-
- public function test_radio()
- {
-
- $form = form('a','a')->radio('super','check me','a',true)->get();
-
- $this->assertStringContainsString('name="super"',$form);
- $this->assertStringContainsString('check me',$form);
- $this->assertStringContainsString('checked="checked"',$form);
-
- $form = form('a','a')->radio('super','check me','a')->get();
- $this->assertStringContainsString('name="super"',$form);
- $this->assertStringContainsString('check me',$form);
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_generate()
- {
-
- $icon = fa('fas','fa-rocket');
- $form = form('a','a')->generate(2,$this->table,'append',"submit-id");
-
- $this->assertStringContainsString('id="submit-id"',$form);
- $this->assertStringContainsString('id="a"',$form);
- $this->assertStringContainsString('append',$form);
- $this->assertNotEmpty($form);
-
- $form = form('a','a')->generate(2,$this->table,'append',"submit-id",$icon);
-
- $this->assertStringContainsString('id="submit-id"',$form);
- $this->assertStringContainsString('id="a"',$form);
- $this->assertStringContainsString('append',$form);
- $this->assertStringContainsString($icon,$form);
- $this->assertNotEmpty($form);
-
- $form = form('a','a')->generate(2,$this->table,'append',"submit-id",$icon,Form::EDIT,1);
-
- $this->assertStringContainsString('id="submit-id"',$form);
- $this->assertStringContainsString('id="a"',$form);
- $this->assertStringContainsString('append',$form);
- $this->assertStringContainsString($icon,$form);
- $this->assertNotEmpty($form);
-
-
- $form = form('a','a')->generate(2,$this->table,'append',"submit-id",$icon,Form::EDIT,1);
-
- $this->assertStringContainsString('id="submit-id"',$form);
- $this->assertStringContainsString('id="a"',$form);
- $this->assertStringContainsString('append',$form);
- $this->assertStringContainsString($icon,$form);
- $this->assertNotEmpty($form);
-
- }
-
- public function test_redirect()
- {
- $icon = fa('fas','fa-trash');
- $form = \form('a','a')->redirect('a',['a' => 2])->get();
- $this->assertStringNotContainsString($icon,$form);
- $this->assertStringContainsString('name="a"',$form);
- $this->assertStringContainsString('location',$form);
-
- $form = \form('a','a')->redirect('a',['a' => 2],$icon)->get();
- $this->assertStringContainsString($icon,$form);
- $this->assertStringContainsString('location',$form);
- $this->assertStringContainsString('name="a"',$form);
- }
-
- public function test_pagination()
- {
- $icon = fa('fas','fa-search');
- $form = \form('a','a')->pagination($icon,'pag')->get();
- $this->assertStringContainsString($icon,$form);
- $this->assertStringContainsString('pag',$form);
- }
- public function test_search()
- {
- $icon = fa('fas','fa-search');
- $form = \form('a','a')->search('search',$icon)->get();
- $this->assertStringContainsString('placeholder="search"',$form);
- $this->assertStringContainsString($icon,$form);
- $this->assertStringContainsString('&q=',$form);
- }
- public function test_group()
- {
- $form = form('a','a')->group(['login','email'],'/login','/email')->get();
- $this->assertStringContainsString('href="/login"',$form);
- $this->assertStringContainsString('login',$form);
- $this->assertStringContainsString('email',$form);
- $this->assertStringContainsString('href="/email"',$form);
- }
- public function test_link()
- {
- $icon = fa('fas','fa-home');
- $form = \form('a','a')->link('/','home')->get();
- $this->assertStringContainsString('home',$form);
- $this->assertStringContainsString('href="/"',$form);
- $this->assertStringNotContainsString($icon,$form);
-
- $form = \form('a','a')->link('/','home',$icon)->get();
- $this->assertStringContainsString($icon,$form);
- $this->assertStringContainsString('home',$form);
- $this->assertStringContainsString('href="/"',$form);
-
- }
-
- public function test_padding()
- {
-
- $marge = config('form','padding');
- $form = form('a','a')->padding($marge)->input('text','name','username')->get();
- $this->assertStringContainsString("pt-$marge pb-$marge",$form);
- }
- public function test_margin()
- {
- $marge = config('form','margin');
- $form = form('a','a')->margin($marge)->input('text','name','username')->get();
- $this->assertStringContainsString("mt-$marge mb-$marge",$form);
- }
-
- public function test_margin_and_padding()
- {
- $marge = config('form','margin');
- $padding = config('form','padding');
- $form = form('a','a')->margin()->padding()->input('text','name','username')->get();
- $this->assertStringContainsString("mt-$marge mb-$marge pt-$padding pb-$padding",$form);
- }
- /**
- * @throws \Exception
- */
- public function test_exception()
- {
-
- $this->expectException(\Exception::class);
- (new Form())->validate()->padding()->get();
- (new Form())->validate()->margin()->get();
- form('a','a')->validate()->textarea('name','a')->get();
- form('a','a')->validate()->input(Form::TEXT,'a','a')->get();
- form('a','a')->validate()->select(true,'a',['1',2,3])->get();
- form('a','adz')->validate()->textarea('a','adza')->get();
- form('a','adz')->generate(2,$this->table,$this->mysql()->table(),'submit',id(),'',500,1);
- form('a','adz')->generate(2,$this->table,$this->mysql()->table(),'submit',id(),'',500);
- }
-
- }
-}
diff --git a/tests/hash/HashTest.php b/tests/hash/HashTest.php
deleted file mode 100644
index 551d301..0000000
--- a/tests/hash/HashTest.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-
-namespace Testing\hash;
-
-
-use Imperium\Security\Hashing\Hash;
-use PHPUnit\Framework\TestCase;
-
-class HashTest extends TestCase
-{
-
- /**
- * @throws \Exception
- */
- public function test_hash()
- {
- $this->assertNotEmpty(bcrypt('a'));
-
- $this->assertFalse(check('a',bcrypt('aa')));
-
- $this->assertFalse(check('alex',bcrypt('alexandra')));
-
- $this->assertTrue(check('linux',bcrypt('linux')));
-
- $this->assertFalse(Hash::need_rehash(bcrypt('aze')));
-
- }
-} \ No newline at end of file
diff --git a/tests/mysql/app/AppTest.php b/tests/mysql/app/AppTest.php
deleted file mode 100644
index 3b57ec8..0000000
--- a/tests/mysql/app/AppTest.php
+++ /dev/null
@@ -1,812 +0,0 @@
-<?php
-
-namespace Testing\mysql\app {
-
- use Exception;
- use Imperium\Bases\Base;
- use Imperium\Collection\Collection;
- use Imperium\Connexion\Connect;
- use Imperium\App;
- use Imperium\Json\Json;
- use Imperium\Model\Model;
- use Imperium\Query\Query;
- use Imperium\Tables\Table;
- use Imperium\Users\Users;
- use Intervention\Image\ImageManager;
- use Sinergi\BrowserDetector\Os;
- use Sinergi\BrowserDetector\Device;
- use Sinergi\BrowserDetector\Browser;
- use Testing\DatabaseTest;
- use Whoops\Run;
-
- /**
- *
- */
- class AppTest extends DatabaseTest
- {
-
-
-
- /**
- * @throws Exception
- */
- public function test_app()
- {
-
- $this->assertInstanceOf(App::class,app());
- }
-
- /**
- *
- */
- public function test_env()
- {
-
- $this->assertEquals('mysql',env('driver'));
-
- }
-
- /**
- *
- */
- public function test_not_exist()
- {
- $this->assertTrue(not_exist(faker()->name));
- $this->assertFalse(not_exist('def'));
- }
-
- /**
- *
- */
- public function test_ago()
- {
- $this->assertNotEmpty(ago('fr',now()));
- $this->assertNotEmpty(ago('en',now()));
- $this->assertNotEmpty(ago('de',now()));
- }
-
- /**
- *
- */
- public function test_image()
- {
- $this->assertInstanceOf(ImageManager::class,image());
- $this->assertInstanceOf(ImageManager::class,image("imagick"));
- }
-
- /**
- *
- */
- public function test_loaded()
- {
- $this->assertTrue(mysql_loaded());
- $this->assertTrue(pgsql_loaded());
- $this->assertTrue(sqlite_loaded());
- }
-
- /**
- * @throws Exception
- */
- public function test_quote()
- {
- $word = "l'agent à été l'as du voyage d'affaire`";
-
- $this->assertNotEquals($word,quote($word));
- }
-
-
-
- /**
- * @throws Exception
- */
- public function test_execute()
- {
- $this->assertTrue(execute("SELECT * FROM model","SELECT * FROM base","SELECT * FROM helpers"));
-
- }
-
- /**
- * @throws Exception
- */
- public function test_req()
- {
- $this->assertNotEmpty(req("SELECT * FROM model","SELECT * FROM base","SELECT * FROM helpers"));
- }
-
- /**
- *
- */
- public function test_assign()
- {
- $var = 'i am a';
-
- assign(false,$var," man");
-
- $this->assertEquals($var,$var);
-
- assign(true,$var," man");
-
- $this->assertEquals(" man",$var);
- }
-
- /**
- * @throws Exception
- */
- public function test_query()
- {
- $this->assertInstanceOf(Query::class,\query($this->mysql()->table(),$this->mysql()->connect()));
-
- $this->assertInstanceOf(Model::class,\model($this->mysql()->connect(),$this->mysql()->table()));
-
- $this->assertInstanceOf(Table::class,table($this->mysql()->connect()));
-
- }
-
- public function test_awesome()
- {
- $this->assertNotEmpty(awesome());
- $this->assertNotEmpty(foundation());
- $this->assertNotEmpty(bootswatch('lumen'));
- $this->assertNotEmpty(bootswatch('bootstrap'));
- }
-
- /**
- *
- */
- public function test_today_and_future()
- {
- $this->assertNotEmpty(today());
- $this->assertNotEmpty(future('second',1));
- $this->assertNotEmpty(future('seconds',1));
- $this->assertNotEmpty(future('minute',1));
- $this->assertNotEmpty(future('minutes',1));
- $this->assertNotEmpty(future('hour',1));
- $this->assertNotEmpty(future('hours',1));
- $this->assertNotEmpty(future('day',1));
- $this->assertNotEmpty(future('days',1));
- $this->assertNotEmpty(future('week',1));
- $this->assertNotEmpty(future('weeks',1));
- $this->assertNotEmpty(future('month',1));
- $this->assertNotEmpty(future('months',1));
- $this->assertNotEmpty(future('year',1));
- $this->assertNotEmpty(future('years',1));
- $this->assertNotEmpty(future('centuries',1));
- $this->assertNotEmpty(future('century',1));
- $this->assertNotEmpty(future('a',1));
- }
-
- /**
- *
- */
- public function test_lines()
- {
- $this->assertNotEmpty(lines('README.md'));
- }
-
- /**
- *
- */
- public function test_slug()
- {
- $this->assertEquals('linux-is-better',\slug('LINUX IS BETTER'));
- $this->assertEquals('the-planet-is-dead',\slug('The planet IS DEAD'));
- $this->assertEquals('the-planet-is-dead',\slug('The*planet*IS*DEAD','*'));
- $this->assertEquals('the-planet-is-dead',\slug('The--planet--IS--DEAD','--'));
- }
-
- /**
- *
- */
- public function test_pair()
- {
- $this->assertTrue(is_pair(0));
- $this->assertFalse(is_pair(1));
- $this->assertTrue(is_pair(2));
- $this->assertFalse(is_pair(3));
- $this->assertTrue(is_pair(4));
- $this->assertFalse(is_pair(5));
- $this->assertTrue(is_pair(6));
- $this->assertFalse(is_pair(7));
- $this->assertTrue(is_pair(8));
- $this->assertFalse(is_pair(9));
- $this->assertTrue(is_pair(10));
- }
-
- /**
- * @throws Exception
- */
- public function test_equal()
- {
- $this->assertTrue(equal('a','a'));
- $this->assertTrue(equal(10,10)) ;
- $this->assertFalse(equal(5,3));
- $this->assertFalse(equal('om','psg'));
- }
-
- /**
- * @throws Exception
- */
- public function test_equal_exe()
- {
- $msg = "matrix";
-
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
-
- equal('a','a',true,$msg);
- equal(true,true,true,$msg);
- equal(false,false,true,$msg);
- equal(1,1,true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_is_not_false()
- {
- $this->assertTrue(is_not_false(true));
- $this->assertTrue(is_not_false('a'));
- $this->assertTrue(is_not_false(5));
- $this->assertFalse(is_not_false(false));
- }
-
- /**
- * @throws Exception
- */
- public function test_is_not_false_exe()
- {
- $msg = "matrix";
-
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
-
- is_not_false('a',true,$msg);
- is_not_false(5,true,$msg);
- is_not_false(true,true,$msg);
-
- }
-
-
- /**
- * @throws Exception
- */
- public function test_is_not_true()
- {
- $this->assertTrue(is_not_true(false));
- $this->assertTrue(is_not_true('a'));
- $this->assertTrue(is_not_true(5));
- $this->assertFalse(is_not_true(true));
- }
-
-
- /**
- * @throws Exception
- */
- public function test_is_not_true_exe()
- {
- $msg = "matrix";
-
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
-
- is_not_true(false,true,$msg);
- is_not_true(5,true,$msg);
- is_not_true('adza',true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_is_false()
- {
- $this->assertTrue(is_false(false));
- $this->assertFalse(is_false(true));
- }
-
- /**
- * @throws Exception
- */
- public function test_is_false_exe()
- {
- $msg = "matrix";
-
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
-
- is_false(false,true,$msg);
-
- }
-
-
- /**
- * @throws Exception
- */
- public function test_is_true()
- {
- $this->assertTrue(is_true(true));
- $this->assertFalse(is_true(false));
- }
-
- /**
- * @throws Exception
- */
- public function test_is_true_exe()
- {
- $msg = "matrix";
-
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
-
- is_true(true,true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_different()
- {
- $this->assertTrue(different(true,false));
- $this->assertTrue(different(5,false));
- $this->assertTrue(different(5,52));
- $this->assertFalse(different(false,false));
- }
-
- /**
- * @throws Exception
- */
- public function test_different_exe()
- {
- $msg = "matrix";
-
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
-
- different(false,true,true,$msg);
- different(5,true,true,$msg);
- different(5,8,true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_base_to_json()
- {
- $this->assertTrue(bases_to_json('app.json'));
- }
-
- /**
- * @throws Exception
- */
- public function test_user_to_json()
- {
- $this->assertTrue(users_to_json('app.json'));
- }
-
- /**
- * @throws Exception
- */
- public function test_table_to_json()
- {
- $this->assertTrue(tables_to_json('app.json'));
- }
-
- /**
- * @throws Exception
- */
- public function test_sql_to_json()
- {
- $this->assertTrue(sql_to_json('app.json',["show databases","show tables","select host, User from mysql.user",$this->mysql()->query()->mode(Query::SELECT)->from('base')->where('id',Query::INFERIOR,5)->sql()],['bases','tables',"user","base_records"]));
- }
-
- /**
- * @throws Exception
- */
- public function test_length()
- {
- $this->assertEquals(5,length('trois'));
- $this->assertEquals(4,length([1,2,3,4]));
- }
-
- /**
- * @throws Exception
- */
- public function test_connect_instance()
- {
- $this->assertInstanceOf(Connect::class,\connect(Connect::MYSQL,'zen','root','root',Connect::LOCALHOST,'dump'));
- $this->assertInstanceOf(Connect::class,\connect(Connect::POSTGRESQL,'zen','postgres','postgres',Connect::LOCALHOST,'dump'));
- $this->assertInstanceOf(Connect::class,\connect(Connect::SQLITE,'zen','','',Connect::LOCALHOST,'dump'));
- }
-
- /**
- *
- */
- public function test_json_instance()
- {
- $this->assertInstanceOf(Json::class,json('app.json'));
- }
-
- /**
- *
- */
- public function test_collection_instance()
- {
- $this->assertInstanceOf(Collection::class,collection());
- }
-
- /**
- *
- */
- public function test_def()
- {
- $a ='';
- $this->assertFalse(def($a));
- $this->assertTrue(not_def($a));
- $a = 'aaz';
- $this->assertTrue(def($a));
- $this->assertFalse(not_def($a));
- }
-
- /**
- *
- */
- public function test_zones()
- {
- $this->assertContains('Europe/Paris',zones(''));
- $this->assertContains('a',zones('a'));
- }
-
- /**
- * @throws Exception
- */
- public function test_table_select()
- {
- $select = tables_select('base','?=','/');
- $this->assertStringContainsString('base',$select);
- $this->assertStringContainsString('?=',$select);
- $this->assertStringContainsString('/',$select);
- }
-
- /**
- *
- */
- public function test_true_or_false()
- {
- $this->assertNotEmpty(true_or_false(Connect::POSTGRESQL));
-
- }
-
- /**
- * @throws Exception
- */
- public function test_users_select()
- {
- $select = users_select('?=','','choose',false);
-
- $this->assertStringContainsString('?=',$select);
- $this->assertStringContainsString('/',$select);
- $this->assertStringContainsString('root',$select);
-
- $select = users_select('?=','root','choose',true);
- $this->assertStringContainsString('location',$select);
-
- }
-
- /**
- * @throws Exception
- */
- public function test_base_select()
- {
- $select = bases_select('?=','','choose',false);
-
- $this->assertStringContainsString('?=',$select);
- $this->assertStringContainsString('/',$select);
- $this->assertStringContainsString('zen',$select);
-
- $select = bases_select('?=','','choose',true);
- $this->assertStringContainsString('location',$select);
-
-
- }
-
- /**
- * @throws Exception
- */
- public function test_html()
- {
- $html = ['title','article','aside','footer','header','h1','h2','h3','h4','h5','h6','nav','section','div','p','li','ol','ul','pre'];
- foreach($html as $elem)
- {
- $this->assertEquals("<$elem>a</$elem>",html($elem,'a'));
- $this->assertEquals("<$elem class=\"a\">a</$elem>",html($elem,'a','a'));
- $this->assertEquals("<$elem class=\"a\" id=\"a\">a</$elem>",html($elem,'a','a','a'));
-
- }
-
- $this->assertEquals('<link href="a" rel="stylesheet">',html('link','a'));
- $this->assertEquals('<pre><code>a</code></pre>',html('code','a'));
- $this->assertEquals('<meta csrf="fr-latin9">',html('meta','csrf="fr-latin9"'));
- $this->assertEquals('<img src="a">',html('img','a'));
- $this->assertEquals('<img src="a" class="a">',html('img','a','a'));
-
- }
-
- /**
- *
- */
- public function test_id()
- {
- $this->assertNotEmpty(id());
- $this->assertNotEmpty(id('a'));
- }
-
-
- /**
- *
- */
- public function test_submit()
- {
-
- $this->assertFalse(submit('a'));
- $_POST['a'] = 'legend';
- $this->assertTrue(submit('a'));
-
- $this->assertFalse(submit('a',false));
- $_GET['a'] = 'legend';
- $this->assertTrue(submit('a',false));
- }
-
- /**
- *
- */
- public function test_push()
- {
- $a = [];
- push($a,1,2,3);
- $this->assertEquals([1,2,3],$a);
- }
-
- /**
- *
- */
- public function test_stack()
- {
- $a = [];
- stack($a,1,2,3);
- $this->assertEquals([3,2,1],$a);
- }
-
- /**
- *
- */
- public function test_has()
- {
- $this->assertTrue(has(1,[2,1,3]));
- $this->assertTrue(has(50,[2,1,3,50]));
- $this->assertFalse(has(4,[2,1,3]));
- $this->assertFalse(has(5,[2,1,3,50]));
- }
-
- /**
- *
- */
- public function test_values()
- {
- $this->assertEquals(['i','am','a','god'],values([0=> 'i',1 => 'am',3 => 'a' , 4=> 'god']));
- }
-
- /**
- *
- */
- public function test_keys()
- {
- $this->assertEquals([0,1,3,4],keys([0=> 'i',1 => 'am',3 => 'a' , 4=> 'god']));
- }
-
- /**
- *
- */
- public function test_merge()
- {
- $a = [1,2,3];
- merge($a,[4,5],[6,7,8],[9,10]);
- $this->assertEquals([1,2,3,4,5,6,7,8,9,10],$a);
- }
-
- /**
- * @throws Exception
- */
- public function test_collation()
- {
- $this->assertNotEmpty(collation($this->mysql()->connect()));
- }
-
- /**
- * @throws Exception
- */
- public function test_charset()
- {
- $this->assertNotEmpty(charset($this->mysql()->connect()));
- }
-
- /**
- * @throws Exception
- */
- public function test_base()
- {
- $this->assertInstanceOf(Base::class,base($this->mysql()->connect(),$this->mysql()->table()));
- $this->assertInstanceOf(Base::class,base($this->postgresql()->connect(),$this->postgresql()->table()));
-
- }
-
- /**
- * @throws Exception
- */
- public function test_user()
- {
- $this->assertInstanceOf(Users::class,user($this->mysql()->connect()));
- $this->assertInstanceOf(Users::class,user($this->postgresql()->connect()));
- }
-
-
-
- /**
- *
- */
- public function test_os()
- {
- $this->assertInstanceOf(Os::class,os());
- $this->assertEquals(Os::UNKNOWN,os(true));
- }
-
- /**
- *
- */
- public function test_device()
- {
- $this->assertInstanceOf(Device::class,\device());
- $this->assertEquals(Device::UNKNOWN,device(true));
- }
-
- /**
- *
- */
- public function test_browser()
- {
- $this->assertInstanceOf(Browser::class,browser());
- $this->assertEquals(Browser::UNKNOWN,browser(true));
- }
-
- /**
- *
- */
- public function test_is_browser()
- {
- $this->assertFalse(is_browser('Firefox'));
- }
-
- /**
- *
- */
- public function test_is_mobile()
- {
- $this->assertFalse(is_mobile());
- }
-
- /**
- * @throws Exception
- */
- public function test_superior()
- {
- $this->assertTrue(\superior(1,0));
- $this->assertFalse(\superior(0,5));
- }
-
- /**
- * @throws Exception
- */
- public function test_superior_exe()
- {
- $msg = 'matrix';
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
- superior(5,2,true,$msg);
- superior(8,4,true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_superior_or_equal()
- {
- $this->assertTrue(superior_or_equal(1,0));
- $this->assertTrue(superior_or_equal(1,1));
- $this->assertFalse(superior_or_equal(0,5));
- $this->assertFalse(superior_or_equal(4,5));
- }
-
- /**
- * @throws Exception
- */
- public function test_superior_or_equal_exe()
- {
- $msg = 'matrix';
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
- superior_or_equal(5,2,true,$msg);
- superior_or_equal(5,5,true,$msg);
- superior_or_equal(8,4,true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_inferior()
- {
- $this->assertTrue(inferior(0,4));
- $this->assertTrue(inferior(1,5));
- $this->assertFalse(inferior(60,5));
- $this->assertFalse(inferior(50,5));
- }
-
- /**
- * @throws Exception
- */
- public function test_inferior_exe()
- {
- $msg = 'matrix';
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
- inferior(22,50,true,$msg);
- inferior(2,50,true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_inferior_or_equal()
- {
- $this->assertTrue(inferior_or_equal(1,1));
- $this->assertTrue(inferior_or_equal(1,5));
- $this->assertFalse(inferior_or_equal(5,0));
- $this->assertFalse(inferior_or_equal(10,5));
- }
-
- /**
- * @throws Exception
- */
- public function test_inferior_or_equal_exe()
- {
- $msg = 'matrix';
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
- inferior_or_equal(5,5,true,$msg);
- inferior_or_equal(5,50,true,$msg);
- }
-
- /**
- *
- */
- public function test_whoops()
- {
- $this->assertInstanceOf(Run::class,whoops());
- }
-
- /**
- * @throws Exception
- */
- public function test_value_before_a_key()
- {
- $a = [0 => "a",2 => 'b',3 => 'c',508 =>'d',4 => 'e' ];
- $this->assertEquals('a',before_key($a,2));
- $this->assertEquals('c',before_key($a,508));
- $this->assertEquals('d',before_key($a,4));
- }
- }
-}
diff --git a/tests/mysql/base/BaseTest.php b/tests/mysql/base/BaseTest.php
deleted file mode 100644
index 1c05022..0000000
--- a/tests/mysql/base/BaseTest.php
+++ /dev/null
@@ -1,98 +0,0 @@
-<?php
-namespace Testing\mysql\base {
-
-
- use Exception;
- use Testing\DatabaseTest;
-
- class BaseTest extends DatabaseTest
- {
-
- public function setUp(): void
- {
-
- $this->table = 'base';
- }
-
- public function test_show()
- {
- $this->assertContains($this->base,$this->mysql()->show_databases());
- $this->assertContains($this->base,$this->mysql()->bases()->show());
- $this->assertTrue($this->mysql()->base_exist($this->base));
-
- }
-
-
- /**
- * @throws Exception
- */
- public function test_multiples()
- {
- $this->assertTrue($this->mysql()->bases()->create_multiples('a','b','c'));
- $this->assertTrue($this->mysql()->bases()->drop_multiples('a','b','c'));
-
- }
- /**
- * @throws \Exception
- */
- public function test_has()
- {
- $this->assertTrue($this->mysql()->bases()->has());
- $this->assertTrue($this->mysql()->has_bases());
- }
-
- /**
- * @throws \Exception
- */
- public function test_create()
- {
- $base = 'application';
-
- $this->assertTrue($this->mysql()->bases()->remove('alex','marion','sandra'));
- $this->assertTrue($this->mysql()->bases()->set_charset('utf8')->set_collation('utf8_general_ci')->create('alex','marion','sandra'));
- $this->assertTrue($this->mysql()->bases()->remove('alex','marion','sandra'));
-
- $this->assertTrue($this->mysql()->bases()->create($base));
- $this->assertTrue($this->mysql()->bases()->drop($base));
-
- }
-
- /**
- * @throws Exception
- */
- public function test_hidden()
- {
- $this->assertEquals([],$this->mysql()->bases()->hidden_bases());
-
- $this->assertNotEmpty($this->mysql()->bases()->hidden_tables());
- $this->assertEmpty($this->mysql()->bases()->hidden_bases());
- }
- /**
- * @throws \Exception
- */
- public function test_charset()
- {
- $this->assertNotEmpty($this->mysql()->collations());
- $this->assertNotEmpty($this->mysql()->charsets());
-
- $this->assertNotEmpty($this->mysql()->bases()->collations());
- $this->assertNotEmpty($this->mysql()->bases()->charsets());
- }
-
-
- public function test_exec()
- {
- $this->expectException(Exception::class);
-
- $this->mysql()->bases()->change_collation();
- $this->mysql()->bases()->change_charset();
- $bidon = faker()->text(5);
-
-
- $this->mysql()->bases()->set_collation($bidon)->change_collation();
- $this->mysql()->bases()->set_charset($bidon)->change_charset();
- }
-
-
- }
-}
diff --git a/tests/mysql/connect/ConnectTest.php b/tests/mysql/connect/ConnectTest.php
deleted file mode 100644
index c8e83c1..0000000
--- a/tests/mysql/connect/ConnectTest.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-
-namespace Testing\mysql\connect {
-
-
- use Imperium\Connexion\Connect;
- use Testing\DatabaseTest;
-
- class ConnectTest extends DatabaseTest
- {
-
-
-
- /**
- * @throws \Exception
- */
- public function test_transaction()
- {
- $m_queries = app()->connect();
-
- $table = 'base';
-
- $data = ['id',faker()->name,faker()->numberBetween(1,100),faker()->randomNumber(8),faker()->firstNameFemale,faker()->text(10),faker()->date(),faker()->date()];
-
- $all_mysql = $this->mysql()->model()->count($table);
-
- $m_queries->queries(insert_into($table,$data));
-
-
-
- $m = $this->mysql()->connect()->transaction();
-
- $this->assertTrue($m->commit());
- $this->assertTrue(different($this->mysql()->model()->count($table),$all_mysql));
- }
-
- public function test_not()
- {
-
- $this->assertTrue($this->mysql()->connect()->not(SQLITE));
- $this->assertTrue($this->mysql()->connect()->not(POSTGRESQL));
- $this->assertFalse($this->mysql()->connect()->not(MYSQL));
- $this->assertTrue($this->mysql()->connect()->mysql());
-
- }
-
-
-
-
-
- }
-} \ No newline at end of file
diff --git a/tests/mysql/dumper/DumperTest.php b/tests/mysql/dumper/DumperTest.php
deleted file mode 100644
index 3a69e8f..0000000
--- a/tests/mysql/dumper/DumperTest.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-namespace Testing\mysql\dumper {
-
- use Testing\DatabaseTest;
-
- class DumperTest extends DatabaseTest
- {
- public function test_dump()
- {
- $this->assertTrue($this->mysql()->dump(true));
- $this->assertTrue($this->mysql()->dump(false,'base','helper'));
- }
- }
-}
diff --git a/tests/mysql/imperium/ImperiumTest.php b/tests/mysql/imperium/ImperiumTest.php
deleted file mode 100644
index 0ada4b4..0000000
--- a/tests/mysql/imperium/ImperiumTest.php
+++ /dev/null
@@ -1,284 +0,0 @@
-<?php
-
-namespace Testing\mysql\imperium {
-
-
- use Exception;
- use Imperium\Collection\Collection;
- use Imperium\App;
- use Imperium\Tables\Table;
-
- use Imperium\Users\Users;
- use Testing\DatabaseTest;
-
-
- class ImperiumTest extends DatabaseTest
- {
- /**
- * @var string
- */
- private $table;
-
- /**
- * @throws Exception
- */
- public function setUp():void
- {
- $this->table = 'base';
- }
-
- /**
- * @throws Exception
- */
- public function test_find()
- {
- $x = $this->mysql()->find($this->table,50);
- $this->assertIsNotString($x);
- $this->assertIsNotArray($x);
-
- $x = $this->mysql()->find_or_fail($this->table,50);
- $this->assertIsNotString($x);
- $this->assertIsNotArray($x);
-
- }
- /**
- * @throws Exception
- */
- public function test_all()
- {
- $this->assertNotEmpty($this->mysql()->all($this->table,'id'));
- }
-
- /**
- * @throws Exception
- */
- public function test_show_columns_type()
- {
- $this->assertNotEmpty($this->mysql()->show_columns_types($this->table));
- }
-
- /**
- * @throws Exception
- */
- public function test_append_column()
- {
- $this->assertTrue($this->mysql()->append_column($this->table,'salary',App::INT,0,false,true));
- $this->assertTrue($this->mysql()->remove_column($this->table,'salary'));
- }
-
- public function test_save()
- {
- $number = 5;
- for ($i = 0; $i != $number; ++$i)
- {
-
- $data= [
- 'id' => 'id',
- 'name' => faker()->name,
- 'age' => faker()->numberBetween(1,100),
- 'phone' => faker()->randomNumber(8),
- 'sex' => faker()->firstNameMale,
- 'status' => faker()->text(20),
- 'days' => faker()->date(),
- 'date' => faker()->date()
- ];
- $this->assertTrue($this->mysql()->update_record(5,$data,$this->table));
- $this->assertTrue($this->mysql()->save($this->table,$data));
- }
- }
-
- public function test_remove_by_id()
- {
- $this->assertTrue($this->mysql()->remove_record($this->table,50));
- }
- /**
- * @throws \Exception
- */
- public function test_json()
- {
- $filename = 'app.json';
- $this->assertTrue($this->mysql()->json()->set_name($filename)->add($this->mysql()->show_databases(),'database')->generate());
-
- $this->assertTrue($this->mysql()->bases_users_tables_to_json($filename));
- $this->assertTrue($this->mysql()->bases_users_tables_to_json($filename));
-
- $query = "SELECT * FROM $this->table";
- $this->assertTrue($this->mysql()->json()->sql($this->mysql()->connect(), $query,'records')->generate());
-
-
- $this->assertTrue($this->mysql()->sql_to_json($filename,$query));
-
- $this->assertTrue($this->mysql()->create_json($filename,$this->mysql()->show_databases()));
-
- $this->assertTrue($this->mysql()->json()->set_name($filename)->add($this->mysql()->show_databases())->generate());
- $this->assertNotEmpty($this->mysql()->json()->decode($filename));
- $this->assertNotEmpty($this->mysql()->json_decode($filename));
-
-
-
- }
-
- public function test_change_base()
- {
- $this->assertTrue($this->mysql()->change_base_charset('utf8'));
- }
-
- public function test_get_host()
- {
- $this->assertEquals('localhost',$this->mysql()->connect()->host());
- }
-
- /**
- * @throws \Exception
- */
- public function test_remove_column()
- {
- $this->assertFalse($this->mysql()->table()->column()->for($this->table)->drop('id'));
-
- $this->assertTrue($this->mysql()->table()->column()->for($this->table)->drop('date'));
-
- $this->assertFalse($this->mysql()->table()->column()->for($this->table)->exist('date'));
- }
-
-
-
- /**
- * @throws \Exception
- */
- public function test_show_users()
- {
- $this->assertNotEmpty($this->mysql()->show_users());
-
- $this->assertContains('root',$this->mysql()->show_users());
- $this->assertTrue($this->mysql()->user_exist('root'));
-
- }
-
-
-
- /**
- * @throws \Exception
- */
- public function test_add_databases()
- {
- $name = 'alexandra';
- $this->assertTrue($this->mysql()->add_database($name,'utf8','utf8_general_ci'));
- $this->assertTrue($this->mysql()->remove_database($name));
-
-
- $this->assertTrue($this->mysql()->add_database($name));
- $this->assertTrue($this->mysql()->remove_database($name));
-
-
- }
- /**
- * @throws \Exception
- */
- public function test_exist()
- {
- $this->assertTrue($this->mysql()->table_exist($this->table));
-
-
- }
-
-
-
- /**
- * @throws \Exception
- */
- public function test_remove_user()
- {
- $first = 'dupond';
- $second = 'dupont';
- $this->assertTrue(add_user($first,$first));
- $this->assertTrue(add_user($second,$second));
- $this->assertTrue(remove_users($first,$second));
- }
-
- /**
- * @throws \Exception
- */
-
- public function test_pass()
- {
- $this->assertTrue($this->mysql()->change_user_password(self::MYSQL_USER,self::MYSQL_PASS));
- }
- /**
- * @throws \Exception
- */
- public function test_show_columns()
- {
- $this->assertNotEmpty($this->mysql()->table()->column()->for($this->table)->types());
-
- $this->assertNotEmpty($this->mysql()->show_columns($this->table));
- }
-
- /**
- * @throws \Exception
- */
- public function test_has()
- {
- $this->assertTrue($this->mysql()->has_column($this->table,'id'));
-
- $this->assertFalse($this->mysql()->has_column($this->table,'utf8_general_ci'));
-
- $this->assertTrue($this->mysql()->users()->has());
-
- $this->assertTrue($this->mysql()->has_users());
-
- $this->assertTrue($this->mysql()->has_tables());
-
- $this->assertTrue($this->mysql()->has_bases());
-
- }
-
- /**
- * @throws Exception
- */
- public function test_seed()
- {
- $this->assertTrue($this->mysql()->seed_database());
- }
-
- /**
- * @throws Exception
- */
- public function test_add_user()
- {
- $this->assertTrue($this->mysql()->add_user('linux','linux'));
-
- $this->assertTrue($this->mysql()->remove_user('linux'));
- }
-
-
- /**
- * @throws Exception
- */
- public function test_change()
- {
- $this->assertTrue($this->mysql()->change_base_collation('utf8_general_ci'));
-
- $this->assertTrue($this->mysql()->change_table_charset($this->table,"utf8"));
-
- $this->assertTrue($this->mysql()->change_table_collation($this->table,"utf8_general_ci"));
- }
-
- public function test_collection()
- {
- $this->assertInstanceOf(Collection::class,$this->mysql()->collection());
-
- $this->assertEquals([],$this->mysql()->collection()->collection());
-
- $this->assertEquals(['3'],$this->mysql()->collection(['3'])->collection());
- }
-
- /**
- * @throws Exception*/
- public function test_user()
- {
- $this->assertInstanceOf(Users::class,$this->mysql()->users());
- $this->assertNotEmpty($this->mysql()->users()->show());
- }
-
- }
-}
diff --git a/tests/mysql/import/ImportTest.php b/tests/mysql/import/ImportTest.php
deleted file mode 100644
index 3df32a3..0000000
--- a/tests/mysql/import/ImportTest.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-namespace Testing\mysql\import {
-
- use Testing\DatabaseTest;
-
- /**
- *
- */
- class ImportTest extends DatabaseTest
- {
-
- public function test_import()
- {
- $base = "marion";
- $this->assertTrue($this->mysql()->bases()->copy($base));
- }
- }
-}
diff --git a/tests/mysql/json/JsonTest.php b/tests/mysql/json/JsonTest.php
deleted file mode 100644
index 9a591b4..0000000
--- a/tests/mysql/json/JsonTest.php
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-
-namespace Testing\mysql\json {
-
-
- use Exception;
- use Testing\DatabaseTest;
-
- class JsonTest extends DatabaseTest
- {
-
- public function setUp():void
- {
- $this->table = 'model';
- }
-
- /**
- * @throws \Exception
- */
- public function test_create()
- {
- $json = json('app.json');
- $json->add($this->mysql()->show_databases(),'bases')->add($this->mysql()->show_users(),'users');
-
- $this->assertTrue($json->generate());
- }
-
- public function test_json_encode_exception()
- {
- $this->expectException(Exception::class);
- $this->mysql()->json()->set_name('app.json')->encode(78995);
- }
-
- public function test_json()
- {
- $this->assertNotEmpty($this->mysql()->json()->set_name('app.json')->add(['a' => 1],'fantasy')->encode());
-
- }
- /**
- * @throws \Exception
- */
- public function test_bases_to_json()
- {
-
- $this->assertTrue(bases_to_json('base.json'));
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_sql()
- {
- $json = json('sql.json');
- $this->assertTrue($json->sql($this->mysql()->connect(),"SELECT * FROM $this->table")->generate());
- }
- /**
- * @throws \Exception
- */
- public function test_user_to_json()
- {
- $this->assertTrue(users_to_json('app.json'));
- }
-
- /**
- * @throws \Exception
- */
- public function test_tables_to_json()
- {
- $this->assertTrue(tables_to_json('tables.json'));
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_decode()
- {
- $x = '{"users":["mysql.session","mysql.sys","root"],"bases":["information_schema","mysql","performance_schema","sys","zen"]}';
- $json = json($x);
- $this->assertNotEmpty($json->decode());
-
- $json = json('d.json');
- $json->add($this->mysql()->show_users(),'users')->add($this->mysql()->show_databases(),'bases')->add($this->mysql()->show_tables(),'tables')->generate();
-
- $this->assertNotEmpty($json->decode());
-
- }
- }
-} \ No newline at end of file
diff --git a/tests/mysql/model/ModelTest.php b/tests/mysql/model/ModelTest.php
deleted file mode 100644
index ebd4596..0000000
--- a/tests/mysql/model/ModelTest.php
+++ /dev/null
@@ -1,325 +0,0 @@
-<?php
-
-namespace Testing\mysql\model {
-
- use Exception;
- use Imperium\Connexion\Connect;
- use Imperium\Model\Model;
- use PDO;
- use Imperium\Query\Query;
- use Testing\DatabaseTest;
-
- class ModelTest extends DatabaseTest
- {
-
- /**
- * @var Model
- */
- private $model;
-
- /**
- * @var string
- */
- private $table;
-
- /**
- * @throws Exception
- */
- public function setUp():void
- {
- $this->table = 'model';
- $this->model = $this->mysql()->model()->from($this->table);
- }
-
- public function test_only()
- {
- $this->assertNotEmpty($this->model->where('id', EQUAL,55)->only('name')->get());
-
- }
-
- /**
- * @throws Exception
- */
- public function test_search()
- {
- $this->assertNotEmpty($this->model->search('a'));
- $this->assertNotEmpty($this->model->search(4));
- }
-
- /**
- * @throws Exception
- */
- public function test_news_and_last()
- {
- $this->assertNotEmpty($this->model->news('id',20));
- $this->assertNotEmpty($this->model->news('id',20,5));
-
- $this->assertNotEmpty($this->model->last('id',20));
- $this->assertNotEmpty($this->model->last('id',20,5));
-
- }
- public function test_cool()
- {
- $bool = $this->model
- ->set('id','id')
- ->set('phone',faker()->randomNumber(8))
- ->set('name', faker()->name)
- ->set('date', faker()->date())
- ->set('sex', 'F')
- ->set('days', faker()->date())
- ->set('age', faker()->numberBetween(1,100))
- ->set('status','dead')
- ->save();
- $this->assertTrue($bool);
- }
-
- public function test_get_query()
- {
- $this->assertInstanceOf(Query::class,$this->model->query());
- }
-
-
- public function test_all()
- {
- $this->assertNotEmpty($this->model->all());
-
- }
-
- public function test_edit()
- {
-
- $form = edit($this->table,5,'/',id(),'update','');
- $this->assertNotEmpty($form);
-
- }
-
- public function test_primary()
- {
- $this->assertEquals('id',$this->model->primary());
- }
-
- public function test_create()
- {
-
- $form = create($this->table,'/',id(),'create','');
- $this->assertNotEmpty($form);
- }
-
- /**
- * @throws Exception
- */
- public function test_truncate()
- {
- $empty = 'the table is empty';
- $success = 'records was found';
-
- $sql ='';
-
- $this->assertTrue($this->model->truncate($this->table));
-
- $result = query_result($this->table,SELECT,$this->model->all('id'),$success,$empty,$empty,$sql);
-
- $this->assertCount(0,$this->model->all());
- $this->assertStringContainsString($empty,$result);
- $this->assertTrue( $this->model->is_empty($this->table));
-
- }
-
- /**
- * @throws Exception
- */
- public function test_insert()
- {
-
-
- $number = 5;
- for ($i = 0; $i != $number; ++$i)
- {
- $data = [
- 'id' => 'id',
- 'name' => faker()->name,
- 'age' => faker()->numberBetween(1,100),
- 'phone' => faker()->randomNumber(8),
- 'sex' => faker()->firstNameMale,
- 'status' => faker()->text(20),
- 'days' => faker()->date(),
- 'date' => faker()->date()
- ];
-
- $this->assertTrue($this->model->insert_new_record($data));
- }
-
- $this->assertCount($number,$this->model->all());
- $this->assertEquals($number,$this->model->count($this->table));
-
- }
-
-
-
- /**
- * @throws \Exception
- */
- public function test_show_tables()
- {
- $this->assertContains($this->table,$this->model->show_tables());
-
- }
-
- /**
- * @throws Exception
- */
- public function test_is()
- {
- $this->assertTrue($this->model->is_mysql());
- $this->assertFalse($this->model->is_postgresql());
- $this->assertFalse($this->model->is_sqlite());
-
- }
-
- /**
- * @throws Exception
- *
- */
- public function test_request()
- {
-
- $req = "select * from $this->table";
- $this->assertNotEmpty($this->model->request($req));
- }
-
-
- /**
- * @throws Exception
- */
- public function test_seed()
- {
- $this->assertTrue($this->model->seed(100));
- }
- /**
- * @throws Exception
- */
- public function test_execute()
- {
- $req = "select * from $this->table";
- $this->assertTrue($this->model->execute($req));
- }
-
- /**
- * @throws Exception
- */
- public function test_pdo()
- {
- $this->assertInstanceOf(PDO::class,$this->mysql()->connect()->instance());
- $this->assertInstanceOf(PDO::class,$this->mysql()->model()->pdo());
- }
-
- /**
- * @throws \Exception
- */
- public function test_find_or_fail()
- {
- $this->expectException(Exception::class);
- $this->model->find_or_fail(800);
-
- }
-
- /**
- * @throws Exception
- */
- public function test_remove()
- {
- $this->assertTrue($this->model->remove(4));
- }
-
-
- /**
- * @throws Exception
- */
-
- public function test_update()
- {
-
- $data = [
- 'id' => 'id',
- 'name' => faker()->name,
- 'age' => faker()->numberBetween(1,100),
- 'phone' => faker()->randomNumber(8),
- 'sex' => faker()->firstNameMale,
- 'status' => faker()->text(20),
- 'days' => faker()->date(),
- 'date' => faker()->date()
- ];
-
- $this->assertTrue($this->model->update_record(4,$data));
- }
-
-
-
- /**
- * @throws Exception
- */
- public function test_save()
- {
- $number = 5;
- for ($i = 0; $i != $number; ++$i)
- {
-
- $data = [
- 'id' => 'id',
- 'name' => faker()->name,
- 'age' => faker()->numberBetween(1,100),
- 'phone' => faker()->randomNumber(8),
- 'sex' => faker()->firstNameMale,
- 'status' => faker()->text(20),
- 'days' => faker()->date(),
- 'date' => faker()->date()
- ];
- $this->assertTrue($this->model->insert_new_record($data));
-
- }
- $this->assertCount(109,$this->model->all('id'));
- }
-
- /**
- * @throws Exception
- */
- public function test_found()
- {
- $this->assertEquals(12,$this->model->found());
- }
-
-
-
-
- /**
- * @throws Exception
- */
- public function test_get_instance()
- {
- $expected = PDO::class;
- $x = new Connect(Connect::MYSQL,'',self::MYSQL_USER,self::MYSQL_PASS,Connect::LOCALHOST,'dump');
- $this->assertInstanceOf($expected,$x->instance());
-
- $x = new Connect(Connect::MYSQL,$this->base,self::MYSQL_USER,self::MYSQL_PASS,Connect::LOCALHOST,'dump');
- $this->assertInstanceOf($expected,$x->instance());
-
- $this->expectException(Exception::class);
-
- $x = new Connect(Connect::MYSQL,'',self::POSTGRESQL_USER,self::POSTGRESQL_PASS,Connect::LOCALHOST,'dump');
- $x->instance();
- $x = new Connect(Connect::MYSQL,$this->base,self::POSTGRESQL_USER,self::POSTGRESQL_PASS,Connect::LOCALHOST,'dump');
- $x->instance();
- }
-
- public function test_dump()
- {
- $this->assertTrue($this->mysql()->model()->dump($this->table));
- $this->assertTrue($this->mysql()->model()->dump_base());
- }
- public function test_import()
- {
- $this->assertTrue($this->mysql()->model()-> dump($this->table));
-
- }
- }
-}
diff --git a/tests/mysql/query/QueryTest.php b/tests/mysql/query/QueryTest.php
deleted file mode 100644
index e022aaf..0000000
--- a/tests/mysql/query/QueryTest.php
+++ /dev/null
@@ -1,135 +0,0 @@
-<?php
-
-namespace Testing\mysql\query {
-
-
- use Exception;
- use Imperium\Query\Query;
- use Symfony\Component\DependencyInjection\Tests\Compiler\E;
- use Testing\DatabaseTest;
-
-
- class QueryTest extends DatabaseTest
- {
-
-
- /**
- * @var Query
- */
- private $query;
- /**
- * @var string
- */
- private $second_table;
-
-
- public function setUp():void
- {
- $this->table = 'query';
- $this->second_table = 'helpers';
- $this->query = $this->mysql()->query()->from($this->table);
-
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_where()
- {
-
- $this->assertNotEmpty($this->query->mode(SELECT)->where('id','=',5)->only('date')->sql());
-
-
- $b = '1988-07-15 00:00:00';
- $e = '2010-07-30 00:00:00';
-
- $this->assertNotEmpty($this->query->mode(Query::SELECT)->where('id','!=',1)->get());
-
- $this->assertNotEmpty($this->query->mode(Query::SELECT)->where('name','!=','will')->get());
-
- $this->assertNotEmpty($this->query->mode(Query::SELECT)->like('a')->get());
-
-
- $this->assertNotEmpty($this->query->mode(Query::SELECT)->between('id',1,16)->get());
-
- $this->assertNotEmpty($this->query->mode(Query::SELECT)->only('id')->between('id',1,16)->get());
-
- $this->assertNotEmpty($this->query->mode(Query::SELECT)->only('id')->between('date',$b,$e)->get());
-
-
- $this->assertStringNotContainsString("ORDER BY ",$this->query->mode(Query::DELETE)->where('id','=',16)->sql());
-
-
- }
-
- /**
- * @throws Exception
- */
- public function test_union()
- {
-
-
- $limit = 10;
-
- $columns = 'id, name';
-
- $this->assertNotEmpty($this->query->mode(Query::UNION)->union($this->table,$this->second_table,'','')->get());
-
- $this->assertNotEmpty($this->query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,'','')->get());
-
- $this->assertNotEmpty($this->query->mode(Query::UNION)->union($this->table,$this->second_table,$columns, $columns)->limit($limit,0)->get());
-
- $this->assertNotEmpty($this->query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,$columns,$columns)->limit($limit,0)->get());
-
-
-
- $this->assertNotEmpty($this->query->mode(Query::UNION)->union($this->table,$this->second_table,'','')->get());
-
- $this->assertNotEmpty($this->query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,'','')->get());
-
- $this->assertNotEmpty($this->query->mode(Query::UNION)->union($this->table,$this->second_table,'','')->limit($limit,0)->get());
-
- $this->assertNotEmpty($this->query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,'','')->limit($limit,0)->get());
-
-
- $this->assertCount($limit,$this->query->mode(Query::UNION)->union($this->table,$this->second_table,'','')->limit($limit,0)->get());
-
- $this->assertCount($limit,$this->query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,'','')->limit($limit,0)->get());
-
-
- }
-
- public function test_join()
- {
- $this->assertNotEmpty($this->query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->query->mode(CROSS_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->query->mode(CROSS_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(CROSS_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->query->mode(LEFT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(LEFT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->query->mode(LEFT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(LEFT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
-
- $this->assertNotEmpty($this->query->mode(RIGHT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(RIGHT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id','id')->get());
-
-
- $this->assertNotEmpty($this->query->mode(RIGHT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(RIGHT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
-
- }
-
-
- }
-}
diff --git a/tests/mysql/table/TableTest.php b/tests/mysql/table/TableTest.php
deleted file mode 100644
index d029281..0000000
--- a/tests/mysql/table/TableTest.php
+++ /dev/null
@@ -1,333 +0,0 @@
-<?php
-
-
-namespace Testing\mysql\table {
-
- use Exception;
- use Imperium\App;
- use Imperium\Tables\Column;
- use Imperium\Tables\Table;
- use Testing\DatabaseTest;
-
- class TableTest extends DatabaseTest
- {
-
- /**
- * @var string
- */
- private $table;
-
- /**
- * @throws Exception
- */
- public function setUp():void
- {
- $this->table = 'base';
- }
-
- /**
- * @throws Exception
- */
- public function test_columns_info()
- {
- $this->assertNotEmpty($this->mysql()->table()->column()->for($this->table)->info());
- }
-
-
- /**
- * @throws Exception
- */
- public function test_types()
- {
- $this->assertNotEmpty($this->column()->types());
- }
- /**
- * @throws Exception
- */
- public function test_seed()
- {
- $this->assertTrue($this->table()->seed(50));
- }
-
- /**
- * @throws Exception
- */
- public function test_insert_multiples()
- {
- $number = 100;
- $data = collection();
- for ($i = 0; $i != $number ; $i++)
- {
-
- $data->add(
- [
- 'id' => 'id',
- 'name' => faker()->name,
- 'age' => faker()->numberBetween(1,100),
- 'phone' => faker()->randomNumber(8),
- 'sex' => faker()->firstNameMale,
- 'status' => faker()->text(20),
- 'days' => faker()->date(),
- ]);
-
- }
-
-
- $this->assertTrue($this->table()->insert_multiples($data->collection()));
- }
- /**
- * @throws Exception
- */
- public function test_select()
- {
-
- $this->assertNotEmpty($this->table()->select(6));
-
- }
-
-
- /**
- * @throws Exception
- */
- public function test_change()
- {
- $this->assertTrue($this->table()->set_charset('utf8')->change_charset());
- $this->assertTrue($this->table()->set_collation('utf8_general_ci')->change_collation());
-
-
- $this->assertTrue($this->table()->convert('utf8','utf8_general_ci'));
- }
-
- /**
- * @throws Exception
- */
- public function test_primary_key()
- {
- $this->assertEquals('id', $this->column()->primary_key());
- }
-
- /**
- * @throws Exception
- */
- public function test_show()
- {
- $this->assertContains('base',$this->table()->show());
- }
-
- /**
- * @throws Exception
- */
- public function test_has_columns_type()
- {
-
- $this->assertTrue($this->column()->has_types('datetime','int'));
-
- $this->assertFalse($this->column()->has_types('integer'));
- }
- /**
- * @throws Exception
- */
- public function test_get_tpm_name()
- {
- $this->assertNotEmpty($this->table()->get_current_tmp_table());
- }
-
-
- /**
- * @throws Exception
- */
- public function test_type()
- {
- foreach ($this->table()->column()->for($this->table)->show() as $column)
- $this->assertNotEmpty($this->column()->column_type($column));
- }
-
- /**
- * @throws Exception
- */
- public function test_has()
- {
- $this->assertTrue($this->table()->has());
- $this->assertTrue($this->column()->exist('id'));
- }
-
-
- /**
- * @throws Exception
- */
-
- public function test_remove_by_id()
- {
- $this->assertTrue($this->table()->remove(20));
- }
-
- /**
- * @throws Exception
- */
- public function test_not_exist()
- {
- $this->assertTrue($this->table()->not_exist('alexandra'));
- }
-
- /**
- * @throws Exception
- */
- public function test_import()
- {
- $this->assertTrue($this->mysql()->model()->dump(current_table()));
- $this->assertTrue($this->mysql()->table()->import($this->base));
- }
-
- /**
- * @throws Exception
- */
- public function test_the_last_field()
- {
-
- $columns = $this->column()->show();
- $end = collection($columns)->last();
-
- $this->assertFalse(equal($this->column()->last(),'id'));
- $this->assertFalse(equal($this->column()->last(),'name'));
-
- $this->assertTrue(equal($this->column()->last(),$end));
- }
-
- /**
- * @throws Exception
- */
- public function test_truncate()
- {
- $this->assertTrue($this->table()->truncate(current_table()));
-
- }
-
- /**
- * @throws Exception
- */
- public function test_append_column()
- {
- $column = 'moria';
-
- $instance = $this->column();
-
- $this->assertTrue($instance->add($column,App::VARCHAR,255,false));
- $this->assertTrue($instance->exist($column));
- $this->assertTrue($instance->drop($column));
-
- $this->assertTrue($instance->add($column,App::VARCHAR,255,true));
- $this->assertTrue($instance->exist($column));
- $this->assertTrue($instance->drop($column));
-
- }
-
- /**
- * @throws Exception
- */
- public function test_ignore()
- {
-
- $this->assertContains(current_table(),$this->table()->show());
- }
-
-
- /**
- * @throws Exception
- */
- public function test_columns_to_string()
- {
-
- $this->assertEquals('id, name, age, phone, sex, status, days',$this->column()->columns_to_string());
- }
-
-
- /**
- * @throws Exception
- */
- public function test_count()
- {
- $this->assertEquals(554 ,$this->table()->count());
- }
-
-
- /**
- * @throws Exception
- */
- public function test_found()
- {
- $this->assertEquals(12,$this->table()->found());
-
- }
-
-
- /**
- * @throws Exception
- */
- public function test_current()
- {
- $this->assertEquals('base',$this->table()->current());
- }
-
-
- /**
- * @throws Exception
- */
- public function test_columns_not_exist()
- {
- $this->assertTrue($this->column()->not_exist('excalibur'));
-
- $this->assertFalse($this->column()->not_exist('id'));
- }
- /**
- * @throws Exception
- */
- public function test_dump()
- {
-
- $this->assertTrue($this->table()->dump());
- $this->assertTrue($this->table()->dump(current_table()));
-
- }
-
- /**
- * @throws Exception
- */
- public function test_rename()
- {
-
-
- $old = 'name';
- $new = 'username';
-
- $this->assertTrue($this->column()->rename($old, $new));
- $this->assertTrue($this->column()->rename($new, $old));
-
-
- $this->assertTrue($this->table()->rename($new));
-
- $this->assertTrue($this->table()->drop(current_table()));
-
-
-
- }
-
- /**
- * @return Table
- * @throws Exception
- */
- private function table(): Table
- {
- return $this->mysql()->table()->from($this->table);
- }
-
- /**
- * @return Column
- * @throws Exception
- */
- private function column(): Column
- {
- return $this->table()->column()->for($this->table);
- }
-
- }
-}
diff --git a/tests/mysql/users/UsersTest.php b/tests/mysql/users/UsersTest.php
deleted file mode 100644
index 098db1b..0000000
--- a/tests/mysql/users/UsersTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-
-namespace Testing\mysql\users {
-
-
- use Testing\DatabaseTest;
-
- class UsersTest extends DatabaseTest
- {
- /**
- * @throws \Exception
- */
- public function test_show()
- {
-
- $this->assertNotEmpty($this->mysql()->users()->show());
-
- $this->assertContains(self::MYSQL_USER,$this->mysql()->users()->show());
-
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_create_and_drop()
- {
-
- $name = 'voku';
-
- $this->assertTrue($this->mysql()->users()->set_name($name)->set_password($name)->create());
- $this->assertTrue($this->mysql()->users()->drop($name));
- }
-
- }
-} \ No newline at end of file
diff --git a/tests/pgsql/app/AppTest.php b/tests/pgsql/app/AppTest.php
deleted file mode 100644
index 194dad9..0000000
--- a/tests/pgsql/app/AppTest.php
+++ /dev/null
@@ -1,818 +0,0 @@
-<?php
-
-namespace Testing\pgsql\app {
-
- use Exception;
- use Imperium\Bases\Base;
- use Imperium\Collection\Collection;
- use Imperium\Connexion\Connect;
- use Imperium\App;
- use Imperium\Json\Json;
- use Imperium\Model\Model;
- use Imperium\Query\Query;
- use Imperium\Tables\Table;
- use Imperium\Users\Users;
- use Intervention\Image\ImageManager;
- use Sinergi\BrowserDetector\Os;
- use Sinergi\BrowserDetector\Device;
- use Sinergi\BrowserDetector\Browser;
- use Testing\DatabaseTest;
- use Whoops\Run;
-
- /**
- *
- */
- class AppTest extends DatabaseTest
- {
-
-
-
- /**
- * @throws Exception
- */
- public function test_app()
- {
-
- $this->assertInstanceOf(App::class,app());
- }
-
- /**
- *
- */
- public function test_env()
- {
-
- $this->assertEquals('mysql',env('driver'));
-
- }
-
- /**
- *
- */
- public function test_not_exist()
- {
- $this->assertTrue(not_exist(faker()->name));
- $this->assertFalse(not_exist('def'));
- }
-
- /**
- *
- */
- public function test_ago()
- {
- $this->assertNotEmpty(ago('fr',now()));
- $this->assertNotEmpty(ago('en',now()));
- $this->assertNotEmpty(ago('de',now()));
- }
-
- /**
- *
- */
- public function test_image()
- {
- $this->assertInstanceOf(ImageManager::class,image());
- $this->assertInstanceOf(ImageManager::class,image("imagick"));
- }
-
- /**
- *
- */
- public function test_loaded()
- {
- $this->assertTrue(mysql_loaded());
- $this->assertTrue(pgsql_loaded());
- $this->assertTrue(sqlite_loaded());
- }
-
- /**
- * @throws Exception
- */
- public function test_quote()
- {
- $word = "l'agent à été l'as du voyage d'affaire`";
-
- $this->assertNotEquals($word,quote($word));
- }
-
-
-
- /**
- * @throws Exception
- */
- public function test_execute()
- {
- $this->assertTrue(execute("SELECT * FROM model","SELECT * FROM base","SELECT * FROM helpers"));
-
- }
-
- /**
- * @throws Exception
- */
- public function test_req()
- {
- $this->assertNotEmpty(req("SELECT * FROM model","SELECT * FROM base","SELECT * FROM helpers"));
- }
-
- /**
- *
- */
- public function test_assign()
- {
- $var = 'i am a';
-
- assign(false,$var," man");
-
- $this->assertEquals($var,$var);
-
- assign(true,$var," man");
-
- $this->assertEquals(" man",$var);
- }
-
- /**
- * @throws Exception
- */
- public function test_query()
- {
- $this->assertInstanceOf(Query::class,\query($this->postgresql()->table(),$this->postgresql()->connect()));
-
- $this->assertInstanceOf(Model::class,\model($this->postgresql()->connect(),$this->postgresql()->table()));
-
- $this->assertInstanceOf(Table::class,table($this->postgresql()->connect()));
-
- }
-
- public function test_awesome()
- {
- $this->assertNotEmpty(awesome());
- $this->assertNotEmpty(foundation());
- $this->assertNotEmpty(bootswatch('lumen'));
- $this->assertNotEmpty(bootswatch('bootstrap'));
- }
-
- /**
- *
- */
- public function test_today_and_future()
- {
- $this->assertNotEmpty(today());
- $this->assertNotEmpty(future('second',1));
- $this->assertNotEmpty(future('seconds',1));
- $this->assertNotEmpty(future('minute',1));
- $this->assertNotEmpty(future('minutes',1));
- $this->assertNotEmpty(future('hour',1));
- $this->assertNotEmpty(future('hours',1));
- $this->assertNotEmpty(future('day',1));
- $this->assertNotEmpty(future('days',1));
- $this->assertNotEmpty(future('week',1));
- $this->assertNotEmpty(future('weeks',1));
- $this->assertNotEmpty(future('month',1));
- $this->assertNotEmpty(future('months',1));
- $this->assertNotEmpty(future('year',1));
- $this->assertNotEmpty(future('years',1));
- $this->assertNotEmpty(future('centuries',1));
- $this->assertNotEmpty(future('century',1));
- $this->assertNotEmpty(future('a',1));
- }
-
- /**
- *
- */
- public function test_lines()
- {
- $this->assertNotEmpty(lines('README.md'));
- }
-
- /**
- *
- */
- public function test_slug()
- {
- $this->assertEquals('linux-is-better',\slug('LINUX IS BETTER'));
- $this->assertEquals('the-planet-is-dead',\slug('The planet IS DEAD'));
- $this->assertEquals('the-planet-is-dead',\slug('The*planet*IS*DEAD','*'));
- $this->assertEquals('the-planet-is-dead',\slug('The--planet--IS--DEAD','--'));
- }
-
- /**
- *
- */
- public function test_pair()
- {
- $this->assertTrue(is_pair(0));
- $this->assertFalse(is_pair(1));
- $this->assertTrue(is_pair(2));
- $this->assertFalse(is_pair(3));
- $this->assertTrue(is_pair(4));
- $this->assertFalse(is_pair(5));
- $this->assertTrue(is_pair(6));
- $this->assertFalse(is_pair(7));
- $this->assertTrue(is_pair(8));
- $this->assertFalse(is_pair(9));
- $this->assertTrue(is_pair(10));
- }
-
- /**
- * @throws Exception
- */
- public function test_equal()
- {
- $this->assertTrue(equal('a','a'));
- $this->assertTrue(equal(10,10)) ;
- $this->assertFalse(equal(5,3));
- $this->assertFalse(equal('om','psg'));
- }
-
- /**
- * @throws Exception
- */
- public function test_equal_exe()
- {
- $msg = "matrix";
-
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
-
- equal('a','a',true,$msg);
- equal(true,true,true,$msg);
- equal(false,false,true,$msg);
- equal(1,1,true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_is_not_false()
- {
- $this->assertTrue(is_not_false(true));
- $this->assertTrue(is_not_false('a'));
- $this->assertTrue(is_not_false(5));
- $this->assertFalse(is_not_false(false));
- }
-
- /**
- * @throws Exception
- */
- public function test_is_not_false_exe()
- {
- $msg = "matrix";
-
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
-
- is_not_false('a',true,$msg);
- is_not_false(5,true,$msg);
- is_not_false(true,true,$msg);
-
- }
-
-
- /**
- * @throws Exception
- */
- public function test_is_not_true()
- {
- $this->assertTrue(is_not_true(false));
- $this->assertTrue(is_not_true('a'));
- $this->assertTrue(is_not_true(5));
- $this->assertFalse(is_not_true(true));
- }
-
-
- /**
- * @throws Exception
- */
- public function test_is_not_true_exe()
- {
- $msg = "matrix";
-
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
-
- is_not_true(false,true,$msg);
- is_not_true(5,true,$msg);
- is_not_true('adza',true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_is_false()
- {
- $this->assertTrue(is_false(false));
- $this->assertFalse(is_false(true));
- }
-
- /**
- * @throws Exception
- */
- public function test_is_false_exe()
- {
- $msg = "matrix";
-
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
-
- is_false(false,true,$msg);
-
- }
-
-
- /**
- * @throws Exception
- */
- public function test_is_true()
- {
- $this->assertTrue(is_true(true));
- $this->assertFalse(is_true(false));
- }
-
- /**
- * @throws Exception
- */
- public function test_is_true_exe()
- {
- $msg = "matrix";
-
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
-
- is_true(true,true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_different()
- {
- $this->assertTrue(different(true,false));
- $this->assertTrue(different(5,false));
- $this->assertTrue(different(5,52));
- $this->assertFalse(different(false,false));
- }
-
- /**
- * @throws Exception
- */
- public function test_different_exe()
- {
- $msg = "matrix";
-
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
-
- different(false,true,true,$msg);
- different(5,true,true,$msg);
- different(5,8,true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_base_to_json()
- {
- $this->assertTrue(bases_to_json('app.json'));
- }
-
- /**
- * @throws Exception
- */
- public function test_user_to_json()
- {
- $this->assertTrue(users_to_json('app.json'));
- }
-
- /**
- * @throws Exception
- */
- public function test_table_to_json()
- {
- $this->assertTrue(tables_to_json('app.json'));
- }
-
- /**
- * @throws Exception
- */
- public function test_sql_to_json()
- {
- $this->assertTrue(sql_to_json('app.json',["SELECT * FROM model","SELECT * FROM users"],['bases','tables']));
- }
-
- /**
- * @throws Exception
- */
- public function test_length()
- {
- $this->assertEquals(5,length('trois'));
- $this->assertEquals(4,length([1,2,3,4]));
- }
-
- /**
- * @throws Exception
- */
- public function test_connect_instance()
- {
- $this->assertInstanceOf(Connect::class,\connect(Connect::MYSQL,'zen','root','root',Connect::LOCALHOST,'dump'));
- $this->assertInstanceOf(Connect::class,\connect(Connect::POSTGRESQL,'zen','postgres','postgres',Connect::LOCALHOST,'dump'));
- $this->assertInstanceOf(Connect::class,\connect(Connect::SQLITE,'zen','','',Connect::LOCALHOST,'dump'));
- }
-
- /**
- *
- */
- public function test_json_instance()
- {
- $this->assertInstanceOf(Json::class,json('app.json'));
- }
-
- /**
- *
- */
- public function test_collection_instance()
- {
- $this->assertInstanceOf(Collection::class,collection());
- }
-
- /**
- *
- */
- public function test_def()
- {
- $a ='';
- $this->assertFalse(def($a));
- $this->assertTrue(not_def($a));
- $a = 'aaz';
- $this->assertTrue(def($a));
- $this->assertFalse(not_def($a));
- }
-
- /**
- *
- */
- public function test_zones()
- {
- $this->assertContains('Europe/Paris',zones(''));
- $this->assertContains('a',zones('a'));
- }
-
- /**
- * @throws Exception
- */
- public function test_table_select()
- {
- $select = tables_select('base','?=','/');
- $this->assertStringContainsString('base',$select);
- $this->assertStringContainsString('?=',$select);
- $this->assertStringContainsString('/',$select);
- }
-
- /**
- *
- */
- public function test_true_or_false()
- {
- $this->assertNotEmpty(true_or_false(Connect::POSTGRESQL));
-
- }
-
- /**
- * @throws Exception
- */
- public function test_users_select()
- {
- $select = users_select('?=','','choose',false);
-
- $this->assertStringContainsString('?=',$select);
- $this->assertStringContainsString('/',$select);
- $this->assertStringContainsString('postgres',$select);
-
- $select = users_select('?=','postgres','choose',true);
- $this->assertStringContainsString('location',$select);
-
- }
-
- /**
- * @throws Exception
- */
- public function test_base_select()
- {
- $select = bases_select('?=','','choose',false);
-
- $this->assertStringContainsString('?=',$select);
- $this->assertStringContainsString('/',$select);
- $this->assertStringContainsString('zen',$select);
-
- $select = bases_select('?=','','choose',true);
- $this->assertStringContainsString('location',$select);
-
-
- }
-
- /**
- * @throws Exception
- */
- public function test_html()
- {
- $html = ['title','article','aside','footer','header','h1','h2','h3','h4','h5','h6','nav','section','div','p','li','ol','ul','pre'];
- foreach($html as $elem)
- {
- $this->assertEquals("<$elem>a</$elem>",html($elem,'a'));
- $this->assertEquals("<$elem class=\"a\">a</$elem>",html($elem,'a','a'));
- $this->assertEquals("<$elem class=\"a\" id=\"a\">a</$elem>",html($elem,'a','a','a'));
-
- }
-
- $this->assertEquals('<link href="a" rel="stylesheet">',html('link','a'));
- $this->assertEquals('<pre><code>a</code></pre>',html('code','a'));
- $this->assertEquals('<meta csrf="fr-latin9">',html('meta','csrf="fr-latin9"'));
- $this->assertEquals('<img src="a">',html('img','a'));
- $this->assertEquals('<img src="a" class="a">',html('img','a','a'));
-
- }
-
- /**
- *
- */
- public function test_id()
- {
- $this->assertNotEmpty(id());
- $this->assertNotEmpty(id('a'));
- }
-
-
- /**
- *
- */
- public function test_submit()
- {
-
- $this->assertFalse(submit('a'));
- $_POST['a'] = 'legend';
- $this->assertTrue(submit('a'));
-
- $this->assertFalse(submit('a',false));
- $_GET['a'] = 'legend';
- $this->assertTrue(submit('a',false));
- }
-
- /**
- *
- */
- public function test_push()
- {
- $a = [];
- push($a,1,2,3);
- $this->assertEquals([1,2,3],$a);
- }
-
- /**
- *
- */
- public function test_stack()
- {
- $a = [];
- stack($a,1,2,3);
- $this->assertEquals([3,2,1],$a);
- }
-
- /**
- *
- */
- public function test_has()
- {
- $this->assertTrue(has(1,[2,1,3]));
- $this->assertTrue(has(50,[2,1,3,50]));
- $this->assertFalse(has(4,[2,1,3]));
- $this->assertFalse(has(5,[2,1,3,50]));
- }
-
- /**
- *
- */
- public function test_values()
- {
- $this->assertEquals(['i','am','a','god'],values([0=> 'i',1 => 'am',3 => 'a' , 4=> 'god']));
- }
-
- /**
- *
- */
- public function test_keys()
- {
- $this->assertEquals([0,1,3,4],keys([0=> 'i',1 => 'am',3 => 'a' , 4=> 'god']));
- }
-
- /**
- *
- */
- public function test_merge()
- {
- $a = [1,2,3];
- merge($a,[4,5],[6,7,8],[9,10]);
- $this->assertEquals([1,2,3,4,5,6,7,8,9,10],$a);
- }
-
- /**
- * @throws Exception
- */
- public function test_collation()
- {
- $this->assertNotEmpty(collation($this->postgresql()->connect()));
- }
-
- /**
- * @throws Exception
- */
- public function test_charset()
- {
- $this->assertNotEmpty(charset($this->postgresql()->connect()));
- }
-
- /**
- * @throws Exception
- */
- public function test_base()
- {
- $this->assertInstanceOf(Base::class,base($this->postgresql()->connect(),$this->postgresql()->table()));
- $this->assertInstanceOf(Base::class,base($this->postgresql()->connect(),$this->postgresql()->table()));
-
- }
-
- /**
- * @throws Exception
- */
- public function test_user()
- {
- $this->assertInstanceOf(Users::class,user($this->postgresql()->connect()));
- $this->assertInstanceOf(Users::class,user($this->postgresql()->connect()));
- }
-
- /**
- * @throws Exception
- */
- public function test_pass()
- {
- $this->assertTrue(pass('postgres','postgres'));
- }
-
- /**
- *
- */
- public function test_os()
- {
- $this->assertInstanceOf(Os::class,os());
- $this->assertEquals(Os::UNKNOWN,os(true));
- }
-
- /**
- *
- */
- public function test_device()
- {
- $this->assertInstanceOf(Device::class,\device());
- $this->assertEquals(Device::UNKNOWN,device(true));
- }
-
- /**
- *
- */
- public function test_browser()
- {
- $this->assertInstanceOf(Browser::class,browser());
- $this->assertEquals(Browser::UNKNOWN,browser(true));
- }
-
- /**
- *
- */
- public function test_is_browser()
- {
- $this->assertFalse(is_browser('Firefox'));
- }
-
- /**
- *
- */
- public function test_is_mobile()
- {
- $this->assertFalse(is_mobile());
- }
-
- /**
- * @throws Exception
- */
- public function test_superior()
- {
- $this->assertTrue(\superior(1,0));
- $this->assertFalse(\superior(0,5));
- }
-
- /**
- * @throws Exception
- */
- public function test_superior_exe()
- {
- $msg = 'matrix';
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
- superior(5,2,true,$msg);
- superior(8,4,true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_superior_or_equal()
- {
- $this->assertTrue(superior_or_equal(1,0));
- $this->assertTrue(superior_or_equal(1,1));
- $this->assertFalse(superior_or_equal(0,5));
- $this->assertFalse(superior_or_equal(4,5));
- }
-
- /**
- * @throws Exception
- */
- public function test_superior_or_equal_exe()
- {
- $msg = 'matrix';
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
- superior_or_equal(5,2,true,$msg);
- superior_or_equal(5,5,true,$msg);
- superior_or_equal(8,4,true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_inferior()
- {
- $this->assertTrue(inferior(0,4));
- $this->assertTrue(inferior(1,5));
- $this->assertFalse(inferior(60,5));
- $this->assertFalse(inferior(50,5));
- }
-
- /**
- * @throws Exception
- */
- public function test_inferior_exe()
- {
- $msg = 'matrix';
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
- inferior(22,50,true,$msg);
- inferior(2,50,true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_inferior_or_equal()
- {
- $this->assertTrue(inferior_or_equal(1,1));
- $this->assertTrue(inferior_or_equal(1,5));
- $this->assertFalse(inferior_or_equal(5,0));
- $this->assertFalse(inferior_or_equal(10,5));
- }
-
- /**
- * @throws Exception
- */
- public function test_inferior_or_equal_exe()
- {
- $msg = 'matrix';
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
- inferior_or_equal(5,5,true,$msg);
- inferior_or_equal(5,50,true,$msg);
- }
-
- /**
- *
- */
- public function test_whoops()
- {
- $this->assertInstanceOf(Run::class,whoops());
- }
-
- /**
- * @throws Exception
- */
- public function test_value_before_a_key()
- {
- $a = [0 => "a",2 => 'b',3 => 'c',508 =>'d',4 => 'e' ];
- $this->assertEquals('a',before_key($a,2));
- $this->assertEquals('c',before_key($a,508));
- $this->assertEquals('d',before_key($a,4));
- }
- }
-}
diff --git a/tests/pgsql/base/BaseTest.php b/tests/pgsql/base/BaseTest.php
deleted file mode 100644
index 13c1dee..0000000
--- a/tests/pgsql/base/BaseTest.php
+++ /dev/null
@@ -1,109 +0,0 @@
-<?php
-namespace Testing\pgsql\base {
-
-
- use Exception;
- use Testing\DatabaseTest;
-
- class BaseTest extends DatabaseTest
- {
-
- public function setUp(): void
- {
-
- $this->table = 'base';
- }
-
- public function test_show()
- {
- $this->assertContains($this->base,$this->postgresql()->show_databases());
- $this->assertContains($this->base,$this->postgresql()->bases()->show());
- $this->assertTrue($this->postgresql()->base_exist($this->base));
-
- }
-
-
- /**
- * @throws Exception
- */
- public function test_multiples()
- {
- $this->assertTrue($this->postgresql()->bases()->create_multiples('a','b','c'));
- $this->assertTrue($this->postgresql()->bases()->drop_multiples('a','b','c'));
-
- }
- /**
- * @throws \Exception
- */
- public function test_has()
- {
- $this->assertTrue($this->postgresql()->bases()->has());
- $this->assertTrue($this->postgresql()->has_bases());
- }
-
- /**
- * @throws \Exception
- */
- public function test_create()
- {
- $base = 'application';
-
- $this->assertTrue($this->postgresql()->bases()->remove('alex','marion','sandra'));
- $this->assertTrue($this->postgresql()->bases()->set_charset('UTF8')->set_collation('C')->create('alex','marion','sandra'));
- $this->assertTrue($this->postgresql()->bases()->remove('alex','marion','sandra'));
-
- $this->assertTrue($this->postgresql()->bases()->create($base));
- $this->assertTrue($this->postgresql()->bases()->drop($base));
-
- }
-
- /**
- * @throws Exception
- */
- public function test_hidden()
- {
- $this->assertEquals([],$this->postgresql()->bases()->hidden_bases());
-
- $this->assertNotEmpty($this->postgresql()->bases()->hidden_tables());
- $this->assertEmpty($this->postgresql()->bases()->hidden_bases());
- }
- /**
- * @throws \Exception
- */
- public function test_charset()
- {
- $this->assertNotEmpty($this->postgresql()->collations());
- $this->assertNotEmpty($this->postgresql()->charsets());
-
- $this->assertNotEmpty($this->postgresql()->bases()->collations());
- $this->assertNotEmpty($this->postgresql()->bases()->charsets());
- }
-
-
- public function test_exec()
- {
- $this->expectException(Exception::class);
-
- $this->postgresql()->bases()->change_collation();
- $this->postgresql()->bases()->change_charset();
- $bidon = faker()->text(5);
-
-
- $this->postgresql()->bases()->set_collation($bidon)->change_collation();
- $this->postgresql()->bases()->set_charset($bidon)->change_charset();
- }
- /**
- * @throws \Exception
- */
- public function test_change()
- {
- $this->assertTrue($this->postgresql()->bases()->set_charset('UTF8')->change_charset());
- $this->assertTrue($this->postgresql()->bases()->set_collation('C')->change_collation());
-
- $this->assertTrue($this->postgresql()->change_base_charset('UTF8'));
- $this->assertTrue($this->postgresql()->change_base_collation('C'));
- }
-
-
- }
-}
diff --git a/tests/pgsql/connect/ConnectTest.php b/tests/pgsql/connect/ConnectTest.php
deleted file mode 100644
index 2051433..0000000
--- a/tests/pgsql/connect/ConnectTest.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-
-namespace Testing\pgsql\connect {
-
-
- use Imperium\Connexion\Connect;
- use Testing\DatabaseTest;
-
- class ConnectTest extends DatabaseTest
- {
-
-
-
- /**
- * @throws \Exception
- */
- public function test_transaction()
- {
- $m_queries = app()->connect();
-
- $table = 'base';
-
- $data = ['id',faker()->name,faker()->numberBetween(1,100),faker()->randomNumber(8),faker()->firstNameFemale,faker()->text(10),faker()->date(),faker()->date()];
-
- $all_mysql = $this->postgresql()->model()->count($table);
-
- $m_queries->queries(insert_into($table,$data));
-
-
-
- $m = $this->postgresql()->connect()->transaction();
-
- $this->assertTrue($m->commit());
- $this->assertTrue(different($this->postgresql()->model()->count($table),$all_mysql));
- }
-
- public function test_not()
- {
-
- $this->assertTrue($this->postgresql()->connect()->not(SQLITE));
- $this->assertTrue($this->postgresql()->connect()->not(MYSQL));
- $this->assertFalse($this->postgresql()->connect()->not(POSTGRESQL));
- $this->assertTrue($this->postgresql()->connect()->postgresql());
-
- }
-
-
-
-
-
- }
-} \ No newline at end of file
diff --git a/tests/pgsql/dumper/DumperTest.php b/tests/pgsql/dumper/DumperTest.php
deleted file mode 100644
index d98b18f..0000000
--- a/tests/pgsql/dumper/DumperTest.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-namespace Testing\pgsql\dumper {
-
- use Testing\DatabaseTest;
-
- class DumperTest extends DatabaseTest
- {
- public function test_dump()
- {
- $this->assertTrue($this->mysql()->dump(true));
- $this->assertTrue($this->mysql()->dump(false,'base','helper'));
- }
- }
-}
diff --git a/tests/pgsql/imperium/ImperiumTest.php b/tests/pgsql/imperium/ImperiumTest.php
deleted file mode 100644
index 88a8481..0000000
--- a/tests/pgsql/imperium/ImperiumTest.php
+++ /dev/null
@@ -1,273 +0,0 @@
-<?php
-
-namespace Testing\pgsql\imperium {
-
-
- use Exception;
- use Imperium\Collection\Collection;
- use Imperium\App;
- use Imperium\Tables\Table;
-
- use Imperium\Users\Users;
- use Testing\DatabaseTest;
-
-
- class ImperiumTest extends DatabaseTest
- {
- /**
- * @var string
- */
- private $table;
-
- /**
- * @throws Exception
- */
- public function setUp():void
- {
- $this->table = 'base';
- }
-
- /**
- * @throws Exception
- */
- public function test_find()
- {
-
- $this->assertNotEmpty($this->postgresql()->find($this->table,50));
- $this->assertNotEmpty($this->postgresql()->find_or_fail($this->table,50));
-
- }
- /**
- * @throws Exception
- */
- public function test_all()
- {
- $this->assertNotEmpty($this->postgresql()->all($this->table,'id'));
- }
-
- /**
- * @throws Exception
- */
- public function test_show_columns_type()
- {
- $this->assertNotEmpty($this->postgresql()->show_columns_types($this->table));
- }
-
- /**
- * @throws Exception
- */
- public function test_append_column()
- {
- $this->assertTrue($this->postgresql()->append_column($this->table,'salary',App::INT,0,false,true));
- $this->assertTrue($this->postgresql()->remove_column($this->table,'salary'));
- }
-
- public function test_save()
- {
- $number = 5;
- for ($i = 0; $i != $number; ++$i)
- {
-
- $data= [
- 'id' => 'id',
- 'name' => faker()->name,
- 'age' => faker()->numberBetween(1,100),
- 'phone' => faker()->randomNumber(8),
- 'sex' => faker()->firstNameMale,
- 'status' => faker()->text(20),
- 'days' => faker()->date(),
- 'date' => faker()->date()
- ];
- $this->assertTrue($this->postgresql()->update_record(5,$data,$this->table));
- $this->assertTrue($this->postgresql()->save($this->table,$data));
- }
- }
-
- public function test_remove_by_id()
- {
- $this->assertTrue($this->postgresql()->remove_record($this->table,50));
- }
- /**
- * @throws \Exception
- */
- public function test_json()
- {
- $filename = 'app.json';
- $this->assertTrue($this->postgresql()->json()->set_name($filename)->add($this->postgresql()->show_databases(),'database')->generate());
-
- $this->assertTrue($this->postgresql()->bases_users_tables_to_json($filename));
- $this->assertTrue($this->postgresql()->bases_users_tables_to_json($filename));
-
- $query = "SELECT * FROM $this->table";
- $this->assertTrue($this->postgresql()->json()->sql($this->postgresql()->connect(), $query,'records')->generate());
-
-
- $this->assertTrue($this->postgresql()->sql_to_json($filename,$query));
-
- $this->assertTrue($this->postgresql()->create_json($filename,$this->postgresql()->show_databases()));
-
- $this->assertTrue($this->postgresql()->json()->set_name($filename)->add($this->postgresql()->show_databases())->generate());
- $this->assertNotEmpty($this->postgresql()->json()->decode($filename));
- $this->assertNotEmpty($this->postgresql()->json_decode($filename));
-
-
-
- }
-
- public function test_change_base()
- {
- $this->assertTrue($this->postgresql()->change_base_charset('UTF8'));
- }
-
- public function test_get_host()
- {
- $this->assertEquals('localhost',$this->postgresql()->connect()->host());
- }
-
- /**
- * @throws \Exception
- */
- public function test_remove_column()
- {
- $this->assertFalse($this->postgresql()->table()->column()->for($this->table)->drop('id'));
-
- $this->assertTrue($this->postgresql()->table()->column()->for($this->table)->drop('date'));
-
- $this->assertFalse($this->postgresql()->table()->column()->for($this->table)->exist('date'));
- }
-
-
-
- /**
- * @throws \Exception
- */
- public function test_show_users()
- {
- $this->assertNotEmpty($this->postgresql()->show_users());
-
- $this->assertContains('postgres',$this->postgresql()->show_users());
- $this->assertTrue($this->postgresql()->user_exist('postgres'));
-
- }
-
-
-
- /**
- * @throws \Exception
- */
- public function test_add_databases()
- {
- $name = 'alexandra';
- $this->assertTrue($this->postgresql()->add_database($name,'UTF8','C'));
- $this->assertTrue($this->postgresql()->remove_database($name));
-
-
- $this->assertTrue($this->postgresql()->add_database($name));
- $this->assertTrue($this->postgresql()->remove_database($name));
-
-
- }
- /**
- * @throws \Exception
- */
- public function test_exist()
- {
- $this->assertTrue($this->postgresql()->table_exist($this->table));
-
-
- }
-
-
-
- /**
- * @throws \Exception
- */
- public function test_remove_user()
- {
- $first = 'dupond';
- $second = 'dupont';
- $this->assertTrue(add_user($first,$first));
- $this->assertTrue(add_user($second,$second));
- $this->assertTrue(remove_users($first,$second));
- }
-
- /**
- * @throws \Exception
- */
-
- public function test_pass()
- {
- $this->assertTrue($this->postgresql()->change_user_password('postgres','postgres'));
- }
- /**
- * @throws \Exception
- */
- public function test_show_columns()
- {
- $this->assertNotEmpty($this->postgresql()->table()->column()->for($this->table)->types());
-
- $this->assertNotEmpty($this->postgresql()->show_columns($this->table));
- }
-
- /**
- * @throws \Exception
- */
- public function test_has()
- {
- $this->assertTrue($this->postgresql()->has_column($this->table,'id'));
-
- $this->assertFalse($this->postgresql()->has_column($this->table,'utf8_general_ci'));
-
- $this->assertTrue($this->postgresql()->users()->has());
-
- $this->assertTrue($this->postgresql()->has_users());
-
- $this->assertTrue($this->postgresql()->has_tables());
-
- $this->assertTrue($this->postgresql()->has_bases());
-
- }
-
- /**
- * @throws Exception
- */
- public function test_seed()
- {
- $this->assertTrue($this->postgresql()->seed_database());
- }
-
- /**
- * @throws Exception
- */
- public function test_add_user()
- {
- $this->assertTrue($this->postgresql()->add_user('linux','linux'));
-
- $this->assertTrue($this->postgresql()->remove_user('linux'));
- }
-
-
- /**
- * @throws Exception
- */
- public function test_change()
- {
- $this->assertTrue($this->postgresql()->change_base_collation('C'));
-
- $this->assertTrue($this->postgresql()->change_table_charset($this->table,"UTF8"));
-
- $this->assertTrue($this->postgresql()->change_table_collation($this->table,"C"));
- }
-
- public function test_collection()
- {
- $this->assertInstanceOf(Collection::class,$this->postgresql()->collection());
-
- $this->assertEquals([],$this->postgresql()->collection()->collection());
-
- $this->assertEquals(['3'],$this->postgresql()->collection(['3'])->collection());
- }
-
-
- }
-}
diff --git a/tests/pgsql/import/ImportTest.php b/tests/pgsql/import/ImportTest.php
deleted file mode 100644
index 25d7e81..0000000
--- a/tests/pgsql/import/ImportTest.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-namespace Testing\pgsql\import {
-
- use Testing\DatabaseTest;
-
- /**
- *
- */
- class ImportTest extends DatabaseTest
- {
-
- public function test_import()
- {
- $base = "marion";
- $this->assertTrue($this->mysql()->bases()->copy($base));
- }
- }
-}
diff --git a/tests/pgsql/json/JsonTest.php b/tests/pgsql/json/JsonTest.php
deleted file mode 100644
index a05c2d1..0000000
--- a/tests/pgsql/json/JsonTest.php
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-
-namespace Testing\pgsql\json {
-
-
- use Exception;
- use Testing\DatabaseTest;
-
- class JsonTest extends DatabaseTest
- {
-
- public function setUp():void
- {
- $this->table = 'model';
- }
-
- /**
- * @throws \Exception
- */
- public function test_create()
- {
- $json = json('app.json');
- $json->add($this->mysql()->show_databases(),'bases')->add($this->mysql()->show_users(),'users');
-
- $this->assertTrue($json->generate());
- }
-
- public function test_json_encode_exception()
- {
- $this->expectException(Exception::class);
- $this->mysql()->json()->set_name('app.json')->encode(78995);
- }
-
- public function test_json()
- {
- $this->assertNotEmpty($this->mysql()->json()->set_name('app.json')->add(['a' => 1],'fantasy')->encode());
-
- }
- /**
- * @throws \Exception
- */
- public function test_bases_to_json()
- {
-
- $this->assertTrue(bases_to_json('base.json'));
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_sql()
- {
- $json = json('sql.json');
- $this->assertTrue($json->sql($this->mysql()->connect(),"SELECT * FROM $this->table")->generate());
- }
- /**
- * @throws \Exception
- */
- public function test_user_to_json()
- {
- $this->assertTrue(users_to_json('app.json'));
- }
-
- /**
- * @throws \Exception
- */
- public function test_tables_to_json()
- {
- $this->assertTrue(tables_to_json('tables.json'));
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_decode()
- {
- $x = '{"users":["mysql.session","mysql.sys","root"],"bases":["information_schema","mysql","performance_schema","sys","zen"]}';
- $json = json($x);
- $this->assertNotEmpty($json->decode());
-
- $json = json('d.json');
- $json->add($this->mysql()->show_users(),'users')->add($this->mysql()->show_databases(),'bases')->add($this->mysql()->show_tables(),'tables')->generate();
-
- $this->assertNotEmpty($json->decode());
-
- }
- }
-} \ No newline at end of file
diff --git a/tests/pgsql/model/ModelTest.php b/tests/pgsql/model/ModelTest.php
deleted file mode 100644
index ba7362e..0000000
--- a/tests/pgsql/model/ModelTest.php
+++ /dev/null
@@ -1,333 +0,0 @@
-<?php
-
-namespace Testing\pgsql\model {
-
- use Exception;
- use Imperium\Connexion\Connect;
- use Imperium\Model\Model;
- use PDO;
- use Imperium\Query\Query;
- use Testing\DatabaseTest;
-
- class ModelTest extends DatabaseTest
- {
-
- /**
- * @var Model
- */
- private $model;
-
- /**
- * @var string
- */
- private $table;
-
- /**
- * @throws Exception
- */
- public function setUp():void
- {
- $this->table = 'model';
- $this->model = $this->postgresql()->model()->from($this->table);
- }
-
- /**
- * @throws \Exception
- */
- public function test_find()
- {
- $this->assertTrue(def($this->model->find(2)));
- $this->assertTrue(def($this->model->find_or_fail(2)));
- }
- public function test_only()
- {
- $this->assertNotEmpty($this->model->where('id', EQUAL,55)->only('name')->get());
-
- }
- /**
- * @throws Exception
- */
- public function test_search()
- {
- $this->assertNotEmpty($this->model->search('a'));
- $this->assertNotEmpty($this->model->search(4));
- }
-
- /**
- * @throws Exception
- */
- public function test_news_and_last()
- {
- $this->assertNotEmpty($this->model->news('id',20));
- $this->assertNotEmpty($this->model->news('id',20,5));
-
- $this->assertNotEmpty($this->model->last('id',20));
- $this->assertNotEmpty($this->model->last('id',20,5));
-
- }
- public function test_cool()
- {
- $bool = $this->model
- ->set('id','id')
- ->set('phone',faker()->randomNumber(8))
- ->set('name', faker()->name)
- ->set('date', faker()->date())
- ->set('sex', 'F')
- ->set('days', faker()->date())
- ->set('age', faker()->numberBetween(1,100))
- ->set('status','dead')
- ->save();
- $this->assertTrue($bool);
- }
-
- public function test_get_query()
- {
- $this->assertInstanceOf(Query::class,$this->model->query());
- }
-
-
- public function test_all()
- {
- $this->assertNotEmpty($this->model->all());
-
- }
-
-
- public function test_edit()
- {
-
- $form = edit($this->table,5,'/',id(),'update','');
- $this->assertNotEmpty($form);
-
- }
-
- public function test_primary()
- {
- $this->assertEquals('id',$this->model->primary());
- }
-
- public function test_create()
- {
-
- $form = create($this->table,'/',id(),'create','');
- $this->assertNotEmpty($form);
- }
-
- /**
- * @throws Exception
- */
- public function test_truncate()
- {
- $empty = 'the table is empty';
- $success = 'records was found';
-
- $sql ='';
-
- $this->assertTrue($this->model->truncate($this->table));
-
- $result = query_result($this->table,SELECT,$this->model->all('id'),$success,$empty,$empty,$sql);
-
- $this->assertCount(0,$this->model->all());
- $this->assertStringContainsString($empty,$result);
- $this->assertTrue( $this->model->is_empty($this->table));
-
- }
-
- /**
- * @throws Exception
- */
- public function test_insert()
- {
-
-
- $number = 5;
- for ($i = 0; $i != $number; ++$i)
- {
- $data = [
- 'id' => 'id',
- 'name' => faker()->name,
- 'age' => faker()->numberBetween(1,100),
- 'phone' => faker()->randomNumber(8),
- 'sex' => faker()->firstNameMale,
- 'status' => faker()->text(20),
- 'days' => faker()->date(),
- 'date' => faker()->date()
- ];
-
- $this->assertTrue($this->model->insert_new_record($data));
- }
-
- $this->assertCount($number,$this->model->all());
- $this->assertEquals($number,$this->model->count($this->table));
-
- }
-
-
-
- /**
- * @throws \Exception
- */
- public function test_show_tables()
- {
- $this->assertContains($this->table,$this->model->show_tables());
-
- }
-
- /**
- * @throws Exception
- */
- public function test_is()
- {
- $this->assertTrue($this->model->is_postgresql());
- $this->assertFalse($this->model->is_mysql());
- $this->assertFalse($this->model->is_sqlite());
-
- }
-
- /**
- * @throws Exception
- *
- */
- public function test_request()
- {
-
- $req = "select * from $this->table";
- $this->assertNotEmpty($this->model->request($req));
- }
-
-
- /**
- * @throws Exception
- */
- public function test_seed()
- {
- $this->assertTrue($this->model->seed(100));
- }
- /**
- * @throws Exception
- */
- public function test_execute()
- {
- $req = "select * from $this->table";
- $this->assertTrue($this->model->execute($req));
- }
-
- /**
- * @throws Exception
- */
- public function test_pdo()
- {
- $this->assertInstanceOf(PDO::class,$this->postgresql()->connect()->instance());
- $this->assertInstanceOf(PDO::class,$this->postgresql()->model()->pdo());
- }
-
- /**
- * @throws \Exception
- */
- public function test_find_or_fail()
- {
- $this->expectException(Exception::class);
- $this->model->find_or_fail(800);
-
- }
-
- /**
- * @throws Exception
- */
- public function test_remove()
- {
- $this->assertTrue($this->model->remove(4));
- }
-
-
- /**
- * @throws Exception
- */
-
- public function test_update()
- {
-
- $data = [
- 'id' => 'id',
- 'name' => faker()->name,
- 'age' => faker()->numberBetween(1,100),
- 'phone' => faker()->randomNumber(8),
- 'sex' => faker()->firstNameMale,
- 'status' => faker()->text(20),
- 'days' => faker()->date(),
- 'date' => faker()->date()
- ];
-
- $this->assertTrue($this->model->update_record(4,$data));
- }
-
-
-
- /**
- * @throws Exception
- */
- public function test_save()
- {
- $number = 5;
- for ($i = 0; $i != $number; ++$i)
- {
-
- $data = [
- 'id' => 'id',
- 'name' => faker()->name,
- 'age' => faker()->numberBetween(1,100),
- 'phone' => faker()->randomNumber(8),
- 'sex' => faker()->firstNameMale,
- 'status' => faker()->text(20),
- 'days' => faker()->date(),
- 'date' => faker()->date()
- ];
- $this->assertTrue($this->model->insert_new_record($data));
-
- }
- $this->assertCount(109,$this->model->all('id'));
- }
-
- /**
- * @throws Exception
- */
- public function test_found()
- {
- $this->assertEquals(12,$this->model->found());
- }
-
-
-
-
- /**
- * @throws Exception
- */
- public function test_get_instance()
- {
- $expected = PDO::class;
- $x = new Connect(Connect::POSTGRESQL,'',self::POSTGRESQL_USER,self::POSTGRESQL_PASS,Connect::LOCALHOST,'dump');
- $this->assertInstanceOf($expected,$x->instance());
-
- $x = new Connect(Connect::POSTGRESQL,$this->base,self::POSTGRESQL_USER,self::POSTGRESQL_PASS,Connect::LOCALHOST,'dump');
- $this->assertInstanceOf($expected,$x->instance());
-
- $this->expectException(Exception::class);
-
- $x = new Connect(Connect::MYSQL,'',self::POSTGRESQL_USER,self::POSTGRESQL_PASS,Connect::LOCALHOST,'dump');
- $x->instance();
- $x = new Connect(Connect::MYSQL,$this->base,self::POSTGRESQL_USER,self::POSTGRESQL_PASS,Connect::LOCALHOST,'dump');
- $x->instance();
- }
-
- public function test_dump()
- {
- $this->assertTrue($this->postgresql()->model()->dump($this->table));
- $this->assertTrue($this->postgresql()->model()->dump_base());
- }
- public function test_import()
- {
- $this->assertTrue($this->postgresql()->model()->dump($this->table));
-
- }
- }
-}
diff --git a/tests/pgsql/query/QueryTest.php b/tests/pgsql/query/QueryTest.php
deleted file mode 100644
index c39aade..0000000
--- a/tests/pgsql/query/QueryTest.php
+++ /dev/null
@@ -1,137 +0,0 @@
-<?php
-
-namespace Testing\pgsql\query {
-
-
- use Exception;
- use Imperium\Query\Query;
- use Symfony\Component\DependencyInjection\Tests\Compiler\E;
- use Testing\DatabaseTest;
-
-
- class QueryTest extends DatabaseTest
- {
-
-
- /**
- * @var Query
- */
- private $query;
- /**
- * @var string
- */
- private $second_table;
-
-
- public function setUp():void
- {
- $this->table = 'query';
- $this->second_table = 'helpers';
- $this->query = $this->postgresql()->query()->from($this->table);
-
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_where()
- {
-
- $this->assertNotEmpty($this->query->mode(SELECT)->where('id','=',5)->only('date')->sql());
-
-
- $b = '1988-07-15 00:00:00';
- $e = '2010-07-30 00:00:00';
-
- $this->assertNotEmpty($this->query->mode(Query::SELECT)->where('id','!=',1)->get());
-
- $this->assertNotEmpty($this->query->mode(Query::SELECT)->where('name','!=','will')->get());
-
- $this->assertNotEmpty($this->query->mode(Query::SELECT)->like('a')->get());
-
-
- $this->assertNotEmpty($this->query->mode(Query::SELECT)->between('id',1,16)->get());
-
- $this->assertNotEmpty($this->query->mode(Query::SELECT)->only('id')->between('id',1,16)->get());
-
- $this->assertNotEmpty($this->query->mode(Query::SELECT)->only('id')->between('date',$b,$e)->get());
-
-
- $this->assertStringNotContainsString("ORDER BY ",$this->query->mode(Query::DELETE)->where('id','=',16)->sql());
-
-
- }
-
- /**
- * @throws Exception
- */
- public function test_union()
- {
-
-
- $limit = 10;
-
- $columns = 'id, name';
-
- $this->assertNotEmpty($this->query->mode(Query::UNION)->union($this->table,$this->second_table,'','')->get());
-
- $this->assertNotEmpty($this->query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,'','')->get());
-
- $this->assertNotEmpty($this->query->mode(Query::UNION)->union($this->table,$this->second_table,$columns, $columns)->limit($limit,0)->get());
-
- $this->assertNotEmpty($this->query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,$columns,$columns)->limit($limit,0)->get());
-
-
-
- $this->assertNotEmpty($this->query->mode(Query::UNION)->union($this->table,$this->second_table,'','')->get());
-
- $this->assertNotEmpty($this->query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,'','')->get());
-
- $this->assertNotEmpty($this->query->mode(Query::UNION)->union($this->table,$this->second_table,'','')->limit($limit,0)->get());
-
- $this->assertNotEmpty($this->query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,'','')->limit($limit,0)->get());
-
-
- $this->assertCount($limit,$this->query->mode(Query::UNION)->union($this->table,$this->second_table,'','')->limit($limit,0)->get());
-
- $this->assertCount($limit,$this->query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,'','')->limit($limit,0)->get());
-
-
- }
-
-
-
- public function test_join()
- {
- $this->assertNotEmpty($this->query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->query->mode(CROSS_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->query->mode(CROSS_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(CROSS_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->query->mode(LEFT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(LEFT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->query->mode(LEFT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(LEFT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
-
- $this->assertNotEmpty($this->query->mode(RIGHT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(RIGHT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id','id')->get());
-
-
- $this->assertNotEmpty($this->query->mode(RIGHT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(RIGHT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
-
- }
-
-
- }
-}
diff --git a/tests/pgsql/table/TableTest.php b/tests/pgsql/table/TableTest.php
deleted file mode 100644
index 3903519..0000000
--- a/tests/pgsql/table/TableTest.php
+++ /dev/null
@@ -1,331 +0,0 @@
-<?php
-
-
-namespace Testing\pgsql\table {
-
- use Imperium\App;
- use Imperium\Tables\Table;
- use Testing\DatabaseTest;
-
- class TableTest extends DatabaseTest
- {
-
- /**
- * @var string
- */
- private $table;
-
- /**
- * @throws \Exception
- */
- public function setUp():void
- {
- $this->table = 'base';
- }
-
- /**
- * @throws \Exception
- */
- public function test_columns_info()
- {
- $this->assertNotEmpty($this->postgresql()->table()->column()->for($this->table)->info());
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_types()
- {
- $this->assertNotEmpty($this->column()->types());
- }
- /**
- * @throws \Exception
- */
- public function test_seed()
- {
- $this->assertTrue($this->table()->seed(50));
- }
-
- /**
- * @throws \Exception
- */
- public function test_insert_multiples()
- {
- $number = 100;
- $data = collection();
- for ($i = 0; $i != $number ; $i++)
- {
-
- $data->add(
- [
- 'id' => 'id',
- 'name' => faker()->name,
- 'age' => faker()->numberBetween(1,100),
- 'phone' => faker()->randomNumber(8),
- 'sex' => faker()->firstNameMale,
- 'status' => faker()->text(20),
- 'days' => faker()->date(),
- ]);
-
- }
-
-
- $this->assertTrue($this->table()->insert_multiples($data->collection()));
- }
- /**
- * @throws \Exception
- */
- public function test_select()
- {
-
- $this->assertNotEmpty($this->table()->select(6));
-
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_change()
- {
- $this->assertTrue($this->table()->set_charset('UTF8')->change_charset());
- $this->assertTrue($this->table()->set_collation('C')->change_collation());
-
-
- $this->assertTrue($this->table()->convert('UTF8','C'));
- }
-
- /**
- * @throws \Exception
- */
- public function test_primary_key()
- {
- $this->assertEquals('id', $this->column()->primary_key());
- }
-
- /**
- * @throws \Exception
- */
- public function test_show()
- {
- $this->assertContains('base',$this->table()->show());
- }
-
- /**
- * @throws \Exception
- */
- public function test_has_columns_type()
- {
-
- $this->assertTrue($this->column()->has_types('integer'));
-
- $this->assertFalse($this->column()->has_types('int'));
- }
- /**
- * @throws \Exception
- */
- public function test_get_tpm_name()
- {
- $this->assertNotEmpty($this->table()->get_current_tmp_table());
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_type()
- {
- foreach ($this->table()->column()->for($this->table)->show() as $column)
- $this->assertNotEmpty($this->column()->column_type($column));
- }
-
- /**
- * @throws \Exception
- */
- public function test_has()
- {
- $this->assertTrue($this->table()->has());
- $this->assertTrue($this->column()->exist('id'));
- }
-
-
- /**
- * @throws \Exception
- */
-
- public function test_remove_by_id()
- {
- $this->assertTrue($this->table()->remove(20));
- }
-
- /**
- * @throws \Exception
- */
- public function test_not_exist()
- {
- $this->assertTrue($this->table()->not_exist('alexandra'));
- }
-
- /**
- * @throws \Exception
- */
- public function test_import()
- {
- $this->assertTrue($this->postgresql()->model()->dump(current_table()));
- $this->assertTrue($this->postgresql()->table()->import($this->base));
- }
-
- /**
- * @throws \Exception
- */
- public function test_the_last_field()
- {
-
- $columns = $this->column()->show();
- $end = collection($columns)->last();
-
- $this->assertFalse(equal($this->column()->last(),'id'));
- $this->assertFalse(equal($this->column()->last(),'name'));
-
- $this->assertTrue(equal($this->column()->last(),$end));
- }
-
- /**
- * @throws \Exception
- */
- public function test_truncate()
- {
- $this->assertTrue($this->table()->truncate(current_table()));
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_append_column()
- {
- $column = 'moria';
-
- $instance = $this->column();
-
- $this->assertTrue($instance->add($column,App::VARCHAR,255,false));
- $this->assertTrue($instance->exist($column));
- $this->assertTrue($instance->drop($column));
-
- $this->assertTrue($instance->add($column,App::VARCHAR,255,true));
- $this->assertTrue($instance->exist($column));
- $this->assertTrue($instance->drop($column));
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_ignore()
- {
-
- $this->assertContains(current_table(),$this->table()->show());
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_columns_to_string()
- {
-
- $this->assertEquals('id, name, age, phone, sex, status, days',$this->column()->columns_to_string());
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_count()
- {
- $this->assertEquals(554,$this->table()->count());
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_found()
- {
- $this->assertEquals(12,$this->table()->found());
-
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_current()
- {
- $this->assertEquals('base',$this->table()->current());
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_columns_not_exist()
- {
- $this->assertTrue($this->column()->not_exist('excalibur'));
-
- $this->assertFalse($this->column()->not_exist('id'));
- }
- /**
- * @throws \Exception
- */
- public function test_dump()
- {
-
- $this->assertTrue($this->table()->dump());
- $this->assertTrue($this->table()->dump(current_table()));
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_rename()
- {
-
-
- $old = 'name';
- $new = 'username';
-
- $this->assertTrue($this->column()->rename($old, $new));
- $this->assertTrue($this->column()->rename($new, $old));
-
-
- $this->assertTrue($this->table()->rename($new));
-
- $this->assertTrue($this->table()->drop(current_table()));
-
-
-
- }
-
- /**
- * @return Table
- * @throws \Exception
- */
- private function table(): Table
- {
- return $this->postgresql()->table()->from($this->table);
- }
-
- /**
- * @return \Imperium\Tables\Column
- * @throws \Exception
- */
- private function column(): \Imperium\Tables\Column
- {
- return $this->table()->column()->for($this->table);
- }
-
- }
-}
diff --git a/tests/pgsql/users/UsersTest.php b/tests/pgsql/users/UsersTest.php
deleted file mode 100644
index fe8a78a..0000000
--- a/tests/pgsql/users/UsersTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-
-namespace Testing\pgsql\users {
-
-
- use Testing\DatabaseTest;
-
- class UsersTest extends DatabaseTest
- {
- /**
- * @throws \Exception
- */
- public function test_show()
- {
-
- $this->assertNotEmpty($this->mysql()->users()->show());
-
- $this->assertContains('postgres',$this->mysql()->users()->show());
-
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_create_and_drop()
- {
-
- $name = 'voku';
-
- $this->assertTrue($this->mysql()->users()->set_name($name)->set_password($name)->create());
- $this->assertTrue($this->mysql()->users()->drop($name));
- }
-
- }
-} \ No newline at end of file
diff --git a/tests/query/QueryTest.php b/tests/query/QueryTest.php
deleted file mode 100644
index 99ac6e1..0000000
--- a/tests/query/QueryTest.php
+++ /dev/null
@@ -1,265 +0,0 @@
-<?php
-
-namespace Testing\query {
-
-
- use Exception;
- use Imperium\Query\Query;
- use Symfony\Component\DependencyInjection\Tests\Compiler\E;
- use Testing\DatabaseTest;
-
-
- class QueryTest extends DatabaseTest
- {
-
- /**
- * @var Query
- */
- private $mysql_query;
-
- /**
- * @var Query
- */
- private $pgsql_query;
-
- /**
- * @var Query
- */
- private $sqlite_query;
- private $second_table;
-
-
- public function setUp()
- {
- $this->table = 'query';
- $this->second_table = 'helpers';
- $this->mysql_query = $this->mysql()->query()->from($this->table);
- $this->pgsql_query = $this->postgresql()->query()->from($this->table);
- $this->sqlite_query = $this->sqlite()->query()->from($this->table);
-
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_where()
- {
-
- $this->assertNotEmpty($this->mysql()->model()->change_table($this->table)->where('id','=',5)->only('date')->get());
- $this->assertNotEmpty($this->mysql()->model()->change_table($this->table)->where('id','=',50)->only('date')->get());
-
- $this->assertNotEmpty($this->postgresql()->model()->change_table($this->table)->where('id','=',5)->only('date')->get());
- $this->assertNotEmpty($this->postgresql()->model()->change_table($this->table)->where('id','=',50)->only('date')->get());
-
- $this->assertNotEmpty($this->sqlite()->model()->change_table($this->table)->where('id','=',5)->only('date')->get());
- $this->assertNotEmpty($this->sqlite()->model()->change_table($this->table)->where('id','=',50)->only('date')->get());
-
-
- $b = '1988-07-15 00:00:00';
- $e = '2010-07-30 00:00:00';
-
- $this->assertNotEmpty($this->mysql_query->mode(Query::SELECT)->where('id','!=',1)->get());
- $this->assertNotEmpty($this->pgsql_query->mode(Query::SELECT)->where('id','!=',1)->get());
- $this->assertNotEmpty($this->sqlite_query->mode(Query::SELECT)->where('id','!=',1)->get());
-
- $this->assertNotEmpty($this->mysql_query->mode(Query::SELECT)->where('name','!=','will')->get());
- $this->assertNotEmpty($this->pgsql_query->mode(Query::SELECT)->where('name','!=','will')->get());
- $this->assertNotEmpty($this->sqlite_query->mode(Query::SELECT)->where('name','!=','will')->get());
-
- $this->assertNotEmpty($this->mysql_query->mode(Query::SELECT)->like('a')->get());
- $this->assertNotEmpty($this->pgsql_query->mode(Query::SELECT)->like('a')->get());
- $this->assertNotEmpty($this->sqlite_query->mode(Query::SELECT)->like('a')->get());
-
-
- $this->assertNotEmpty($this->mysql_query->mode(Query::SELECT)->between('id',1,16)->get());
- $this->assertNotEmpty($this->pgsql_query->mode(Query::SELECT)->between('id',1,16)->get());
- $this->assertNotEmpty($this->sqlite_query->mode(Query::SELECT)->between('id',1,16)->get());
-
- $this->assertNotEmpty($this->mysql_query->mode(Query::SELECT)->columns(['id'])->between('id',1,16)->get());
- $this->assertNotEmpty($this->pgsql_query->mode(Query::SELECT)->columns(['id'])->between('id',1,16)->get());
- $this->assertNotEmpty($this->sqlite_query->mode(Query::SELECT)->columns(['id'])->between('id',1,16)->get());
-
-
- $this->assertNotEmpty($this->mysql_query->mode(Query::SELECT)->columns(['id'])->between('date',$b,$e)->get());
- $this->assertNotEmpty($this->pgsql_query->mode(Query::SELECT)->columns(['id'])->between('date',$b,$e)->get());
- $this->assertNotEmpty($this->sqlite_query->mode(Query::SELECT)->columns(['id'])->between('date',$b,$e)->get());
-
-
-
-
- $this->assertNotContains("ORDER BY ",$this->mysql_query->mode(Query::DELETE)->where('id','=',16)->sql());
- $this->assertNotContains("ORDER BY ",$this->pgsql_query->mode(Query::DELETE)->where('id','=',16)->sql());
- $this->assertNotContains("ORDER BY ",$this->sqlite_query->mode(Query::DELETE)->where('id','=',16)->sql());
-
- $this->expectException(\Exception::class);
-
- $this->mysql()->where('id','azd','5');
- $this->postgresql()->where('id','azd','5');
- $this->sqlite()->where('id','azd','5');
-
- $this->mysql_query->where('id','azd','5')->get();
- $this->pgsql_query->where('id','azd','5')->get();
- $this->sqlite_query->where('id','azd','5')->get();
-
- }
-
- /**
- * @throws Exception
- */
- public function test_union()
- {
-
-
- $limit = 10;
-
- $columns = ['id','name'];
-
- $this->assertNotEmpty($this->mysql_query->mode(Query::UNION)->union($this->table,$this->second_table,[], [])->get());
- $this->assertNotEmpty($this->pgsql_query->mode(Query::UNION)->union($this->table,$this->second_table,[], [])->get());
- $this->assertNotEmpty($this->sqlite_query->mode(Query::UNION)->union($this->table,$this->second_table,[],[])->get());
-
- $this->assertNotEmpty($this->mysql_query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,[],[])->get());
- $this->assertNotEmpty($this->pgsql_query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,[],[])->get());
- $this->assertNotEmpty($this->sqlite_query->mode(Query::UNION_ALL)->union( $this->table,$this->second_table,[],[])->get());
-
- $this->assertNotEmpty($this->mysql_query->mode(Query::UNION)->union($this->table,$this->second_table,$columns, $columns)->limit($limit,0)->get());
- $this->assertNotEmpty($this->pgsql_query->mode(Query::UNION)->union($this->table,$this->second_table,$columns, $columns)->limit($limit,0)->get());
- $this->assertNotEmpty($this->sqlite_query->mode(Query::UNION)->union($this->table,$this->second_table,$columns,$columns)->limit($limit,0)->get());
-
- $this->assertNotEmpty($this->mysql_query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,$columns,$columns)->limit($limit,0)->get());
- $this->assertNotEmpty($this->pgsql_query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,$columns,$columns)->limit($limit,0)->get());
- $this->assertNotEmpty($this->sqlite_query->mode(Query::UNION_ALL)->union( $this->table,$this->second_table,$columns,$columns)->limit($limit,0)->get());
-
-
-
- $this->assertNotEmpty($this->mysql_query->mode(Query::UNION)->union($this->table,$this->second_table,[], [])->get());
- $this->assertNotEmpty($this->pgsql_query->mode(Query::UNION)->union($this->table,$this->second_table,[], [])->get());
- $this->assertNotEmpty($this->sqlite_query->mode(Query::UNION)->union($this->table,$this->second_table,[],[])->get());
-
- $this->assertNotEmpty($this->mysql_query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,[],[])->get());
- $this->assertNotEmpty($this->pgsql_query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,[],[])->get());
- $this->assertNotEmpty($this->sqlite_query->mode(Query::UNION_ALL)->union( $this->table,$this->second_table,[],[])->get());
-
- $this->assertNotEmpty($this->mysql_query->mode(Query::UNION)->union($this->table,$this->second_table,[], [])->limit($limit,0)->get());
- $this->assertNotEmpty($this->pgsql_query->mode(Query::UNION)->union($this->table,$this->second_table,[], [])->limit($limit,0)->get());
- $this->assertNotEmpty($this->sqlite_query->mode(Query::UNION)->union($this->table,$this->second_table,[],[])->limit($limit,0)->get());
-
- $this->assertNotEmpty($this->mysql_query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,[],[])->limit($limit,0)->get());
- $this->assertNotEmpty($this->pgsql_query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,[],[])->limit($limit,0)->get());
- $this->assertNotEmpty($this->sqlite_query->mode(Query::UNION_ALL)->union( $this->table,$this->second_table,[],[])->limit($limit,0)->get());
-
-
- $this->assertCount($limit,$this->mysql_query->mode(Query::UNION)->union($this->table,$this->second_table,[], [])->limit($limit,0)->get());
- $this->assertCount($limit,$this->pgsql_query->mode(Query::UNION)->union($this->table,$this->second_table,[], [])->limit($limit,0)->get());
- $this->assertCount($limit,$this->sqlite_query->mode(Query::UNION)->union($this->table,$this->second_table,[], [])->limit($limit,0)->get());
-
-
- $this->assertCount($limit,$this->mysql_query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,[], [])->limit($limit,0)->get());
- $this->assertCount($limit,$this->pgsql_query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,[], [])->limit($limit,0)->get());
- $this->assertCount($limit,$this->sqlite_query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,[], [])->limit($limit,0)->get());
-
-
- }
-
- public function test_join_execp()
- {
-
-
- $this->expectException(Exception::class);
-
- $this->sqlite_query->mode(Query::RIGHT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get();
- $this->sqlite_query->mode(Query::RIGHT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','=',['id','name'])->get();
- $this->mysql_query->mode(Query::FULL_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get();
- $this->mysql_query->mode(Query::FULL_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get();
- $this->sqlite_query->mode(Query::FULL_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get();
- $this->sqlite_query->mode(Query::FULL_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','=',['id','name'])->get();
-
- }
-
- public function test_join()
- {
- $this->assertNotEmpty($this->mysql_query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->mysql_query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->pgsql_query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->pgsql_query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id','name')->get());
-
- $this->assertNotEmpty($this->sqlite_query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->sqlite_query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id','name')->get());
-
-
- $this->assertNotEmpty($this->mysql_query->mode(CROSS_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->mysql_query->mode(CROSS_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->pgsql_query->mode(CROSS_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->pgsql_query->mode(CROSS_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id','id','name')->get());
-
- $this->assertNotEmpty($this->sqlite_query->mode(CROSS_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->sqlite_query->mode(CROSS_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id','id','name')->get());
-
-
- $this->assertNotEmpty($this->mysql_query->mode(CROSS_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->mysql_query->mode(CROSS_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->pgsql_query->mode(CROSS_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->pgsql_query->mode(CROSS_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id','name')->get());
-
- $this->assertNotEmpty($this->sqlite_query->mode(CROSS_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->sqlite_query->mode(CROSS_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id','name')->get());
-
-
-
- $this->assertNotEmpty($this->mysql_query->mode(LEFT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->mysql_query->mode(LEFT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->pgsql_query->mode(LEFT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->pgsql_query->mode(LEFT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id','id','name')->get());
-
- $this->assertNotEmpty($this->sqlite_query->mode(LEFT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->sqlite_query->mode(LEFT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id','id','name')->get());
-
-
- $this->assertNotEmpty($this->mysql_query->mode(LEFT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->mysql_query->mode(LEFT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->pgsql_query->mode(LEFT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->pgsql_query->mode(LEFT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id','name')->get());
-
- $this->assertNotEmpty($this->sqlite_query->mode(LEFT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->sqlite_query->mode(LEFT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id','name')->get());
-
-
-
- $this->assertNotEmpty($this->mysql_query->mode(RIGHT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->mysql_query->mode(RIGHT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->pgsql_query->mode(RIGHT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->pgsql_query->mode(RIGHT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id','id','name')->get());
-
- $this->assertNotEmpty($this->mysql_query->mode(RIGHT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->mysql_query->mode(RIGHT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->pgsql_query->mode(RIGHT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->pgsql_query->mode(RIGHT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id','name')->get());
-
-
-
- $this->assertNotEmpty($this->pgsql_query->mode(FULL_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->pgsql_query->mode(FULL_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id','name')->get());
-
-
- $this->assertNotEmpty($this->mysql_query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->mysql_query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->pgsql_query->mode(INNER_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->pgsql_query->mode(INNER_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id','id','name')->get());
-
- $this->assertNotEmpty($this->sqlite_query->mode(INNER_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->sqlite_query->mode(INNER_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id','id','name')->get());
-
- }
-
-
- }
-}
diff --git a/tests/router/RouterTest.php b/tests/router/RouterTest.php
deleted file mode 100644
index 910e55e..0000000
--- a/tests/router/RouterTest.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-
-namespace Testing\router;
-
-use Exception;
-use Imperium\Routing\Router;
-use Testing\DatabaseTest;
-
-class RouterTest extends DatabaseTest
-{
-
- /**
- * @throws Exception
- */
- public function test_callback()
- {
- $this->assertEquals('AdminController@login',Router::callback('login'));
- }
-
- /**
- * @throws Exception
- */
- public function test_admin()
- {
- $this->assertEquals('/',Router::admin('home'));
- $this->assertEquals('/query',Router::admin('query',POST));
- }
-
- /**
- * @throws Exception
- */
- public function test_name_not_found()
- {
- $this->expectException(Exception::class);
- name('alexandra');
- name('a',POST);
- name('b',GET);
- }
-
- /**
- * @throws Exception
- */
- public function test_name()
- {
- $this->assertEquals('/remove/:table/:id',name('remove'));
- $this->assertEquals('/',name('home'));
- $this->assertEquals('/login',name('login'));
- $this->assertEquals('/login',name('login',POST));
-
- }
-
-} \ No newline at end of file
diff --git a/tests/session/SessionTest.php b/tests/session/SessionTest.php
deleted file mode 100644
index d6c1f88..0000000
--- a/tests/session/SessionTest.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-
-
-namespace Testing\session {
-
-
- use Imperium\Session\ArraySession;
- use Imperium\Session\Session;
- use PHPUnit\Framework\TestCase;
-
- class SessionTest extends TestCase
- {
- /**
- * @var Session
- */
- private $session;
-
- public function setUp(): void
- {
- $this->session = new ArraySession();
- }
-
- public function test_get()
- {
- $this->session->set('a','a');
- $this->assertEquals('a',$this->session->get('a'));
- }
-
- public function test_not_exist()
- {
- $this->session->set('alexandra','a');
- $this->assertEquals('',$this->session->get('alex'));
- }
-
- public function test_remove()
- {
- $this->session->set('a','alex');
-
- $this->assertContains('alex',$this->session->all());
- $this->session->remove('a');
- $this->assertEquals([],$this->session->all());
- }
- }
-} \ No newline at end of file
diff --git a/tests/sqlite/app/AppTest.php b/tests/sqlite/app/AppTest.php
deleted file mode 100644
index ce04031..0000000
--- a/tests/sqlite/app/AppTest.php
+++ /dev/null
@@ -1,811 +0,0 @@
-<?php
-
-namespace Testing\sqlite\app {
-
- use Exception;
- use Imperium\Bases\Base;
- use Imperium\Collection\Collection;
- use Imperium\Connexion\Connect;
- use Imperium\App;
- use Imperium\Json\Json;
- use Imperium\Model\Model;
- use Imperium\Query\Query;
- use Imperium\Tables\Table;
- use Imperium\Users\Users;
- use Intervention\Image\ImageManager;
- use Sinergi\BrowserDetector\Os;
- use Sinergi\BrowserDetector\Device;
- use Sinergi\BrowserDetector\Browser;
- use Testing\DatabaseTest;
- use Whoops\Run;
-
- /**
- *
- */
- class AppTest extends DatabaseTest
- {
-
-
-
- /**
- * @throws Exception
- */
- public function test_app()
- {
-
- $this->assertInstanceOf(App::class,app());
- }
-
- /**
- *
- */
- public function test_env()
- {
-
- $this->assertEquals('mysql',env('driver'));
-
- }
-
- /**
- *
- */
- public function test_not_exist()
- {
- $this->assertTrue(not_exist(faker()->name));
- $this->assertFalse(not_exist('def'));
- }
-
- /**
- *
- */
- public function test_ago()
- {
- $this->assertNotEmpty(ago('fr',now()));
- $this->assertNotEmpty(ago('en',now()));
- $this->assertNotEmpty(ago('de',now()));
- }
-
- /**
- *
- */
- public function test_image()
- {
- $this->assertInstanceOf(ImageManager::class,image());
- $this->assertInstanceOf(ImageManager::class,image("imagick"));
- }
-
- /**
- *
- */
- public function test_loaded()
- {
- $this->assertTrue(mysql_loaded());
- $this->assertTrue(pgsql_loaded());
- $this->assertTrue(sqlite_loaded());
- }
-
- /**
- * @throws Exception
- */
- public function test_quote()
- {
- $word = "l'agent à été l'as du voyage d'affaire`";
-
- $this->assertNotEquals($word,quote($word));
- }
-
-
-
- /**
- * @throws Exception
- */
- public function test_execute()
- {
- $this->assertTrue(execute("SELECT * FROM model","SELECT * FROM base","SELECT * FROM helpers"));
-
- }
-
- /**
- * @throws Exception
- */
- public function test_req()
- {
- $this->assertNotEmpty(req("SELECT * FROM model","SELECT * FROM base","SELECT * FROM helpers"));
- }
-
- /**
- *
- */
- public function test_assign()
- {
- $var = 'i am a';
-
- assign(false,$var," man");
-
- $this->assertEquals($var,$var);
-
- assign(true,$var," man");
-
- $this->assertEquals(" man",$var);
- }
-
- /**
- * @throws Exception
- */
- public function test_query()
- {
- $this->assertInstanceOf(Query::class,\query($this->sqlite()->table(),$this->sqlite()->connect()));
-
- $this->assertInstanceOf(Model::class,\model($this->sqlite()->connect(),$this->sqlite()->table()));
-
- $this->assertInstanceOf(Table::class,table($this->sqlite()->connect()));
-
- }
-
- public function test_awesome()
- {
- $this->assertNotEmpty(awesome());
- $this->assertNotEmpty(foundation());
- $this->assertNotEmpty(bootswatch('lumen'));
- $this->assertNotEmpty(bootswatch('bootstrap'));
- }
-
- /**
- *
- */
- public function test_today_and_future()
- {
- $this->assertNotEmpty(today());
- $this->assertNotEmpty(future('second',1));
- $this->assertNotEmpty(future('seconds',1));
- $this->assertNotEmpty(future('minute',1));
- $this->assertNotEmpty(future('minutes',1));
- $this->assertNotEmpty(future('hour',1));
- $this->assertNotEmpty(future('hours',1));
- $this->assertNotEmpty(future('day',1));
- $this->assertNotEmpty(future('days',1));
- $this->assertNotEmpty(future('week',1));
- $this->assertNotEmpty(future('weeks',1));
- $this->assertNotEmpty(future('month',1));
- $this->assertNotEmpty(future('months',1));
- $this->assertNotEmpty(future('year',1));
- $this->assertNotEmpty(future('years',1));
- $this->assertNotEmpty(future('centuries',1));
- $this->assertNotEmpty(future('century',1));
- $this->assertNotEmpty(future('a',1));
- }
-
- /**
- *
- */
- public function test_lines()
- {
- $this->assertNotEmpty(lines('README.md'));
- }
-
- /**
- *
- */
- public function test_slug()
- {
- $this->assertEquals('linux-is-better',\slug('LINUX IS BETTER'));
- $this->assertEquals('the-planet-is-dead',\slug('The planet IS DEAD'));
- $this->assertEquals('the-planet-is-dead',\slug('The*planet*IS*DEAD','*'));
- $this->assertEquals('the-planet-is-dead',\slug('The--planet--IS--DEAD','--'));
- }
-
- /**
- *
- */
- public function test_pair()
- {
- $this->assertTrue(is_pair(0));
- $this->assertFalse(is_pair(1));
- $this->assertTrue(is_pair(2));
- $this->assertFalse(is_pair(3));
- $this->assertTrue(is_pair(4));
- $this->assertFalse(is_pair(5));
- $this->assertTrue(is_pair(6));
- $this->assertFalse(is_pair(7));
- $this->assertTrue(is_pair(8));
- $this->assertFalse(is_pair(9));
- $this->assertTrue(is_pair(10));
- }
-
- /**
- * @throws Exception
- */
- public function test_equal()
- {
- $this->assertTrue(equal('a','a'));
- $this->assertTrue(equal(10,10)) ;
- $this->assertFalse(equal(5,3));
- $this->assertFalse(equal('om','psg'));
- }
-
- /**
- * @throws Exception
- */
- public function test_equal_exe()
- {
- $msg = "matrix";
-
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
-
- equal('a','a',true,$msg);
- equal(true,true,true,$msg);
- equal(false,false,true,$msg);
- equal(1,1,true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_is_not_false()
- {
- $this->assertTrue(is_not_false(true));
- $this->assertTrue(is_not_false('a'));
- $this->assertTrue(is_not_false(5));
- $this->assertFalse(is_not_false(false));
- }
-
- /**
- * @throws Exception
- */
- public function test_is_not_false_exe()
- {
- $msg = "matrix";
-
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
-
- is_not_false('a',true,$msg);
- is_not_false(5,true,$msg);
- is_not_false(true,true,$msg);
-
- }
-
-
- /**
- * @throws Exception
- */
- public function test_is_not_true()
- {
- $this->assertTrue(is_not_true(false));
- $this->assertTrue(is_not_true('a'));
- $this->assertTrue(is_not_true(5));
- $this->assertFalse(is_not_true(true));
- }
-
-
- /**
- * @throws Exception
- */
- public function test_is_not_true_exe()
- {
- $msg = "matrix";
-
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
-
- is_not_true(false,true,$msg);
- is_not_true(5,true,$msg);
- is_not_true('adza',true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_is_false()
- {
- $this->assertTrue(is_false(false));
- $this->assertFalse(is_false(true));
- }
-
- /**
- * @throws Exception
- */
- public function test_is_false_exe()
- {
- $msg = "matrix";
-
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
-
- is_false(false,true,$msg);
-
- }
-
-
- /**
- * @throws Exception
- */
- public function test_is_true()
- {
- $this->assertTrue(is_true(true));
- $this->assertFalse(is_true(false));
- }
-
- /**
- * @throws Exception
- */
- public function test_is_true_exe()
- {
- $msg = "matrix";
-
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
-
- is_true(true,true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_different()
- {
- $this->assertTrue(different(true,false));
- $this->assertTrue(different(5,false));
- $this->assertTrue(different(5,52));
- $this->assertFalse(different(false,false));
- }
-
- /**
- * @throws Exception
- */
- public function test_different_exe()
- {
- $msg = "matrix";
-
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
-
- different(false,true,true,$msg);
- different(5,true,true,$msg);
- different(5,8,true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_base_to_json()
- {
- $this->expectException(Exception::class);
- bases_to_json('app.json');
- }
-
- /**
- * @throws Exception
- */
- public function test_user_to_json()
- {
- $this->expectException(Exception::class);
- users_to_json('app.json');
- }
-
- /**
- * @throws Exception
- */
- public function test_table_to_json()
- {
- $this->assertTrue(tables_to_json('app.json'));
- }
-
- /**
- * @throws Exception
- */
- public function test_sql_to_json()
- {
- $this->assertTrue(sql_to_json('app.json',["SELECT * FROM model","SELECT * FROM users"],['bases','tables']));
- }
-
- /**
- * @throws Exception
- */
- public function test_length()
- {
- $this->assertEquals(5,length('trois'));
- $this->assertEquals(4,length([1,2,3,4]));
- }
-
- /**
- * @throws Exception
- */
- public function test_connect_instance()
- {
- $this->assertInstanceOf(Connect::class,\connect(Connect::MYSQL,'zen','root','root',Connect::LOCALHOST,'dump'));
- $this->assertInstanceOf(Connect::class,\connect(Connect::POSTGRESQL,'zen','postgres','postgres',Connect::LOCALHOST,'dump'));
- $this->assertInstanceOf(Connect::class,\connect(Connect::SQLITE,'zen','','',Connect::LOCALHOST,'dump'));
- }
-
- /**
- *
- */
- public function test_json_instance()
- {
- $this->assertInstanceOf(Json::class,json('app.json'));
- }
-
- /**
- *
- */
- public function test_collection_instance()
- {
- $this->assertInstanceOf(Collection::class,collection());
- }
-
- /**
- *
- */
- public function test_def()
- {
- $a ='';
- $this->assertFalse(def($a));
- $this->assertTrue(not_def($a));
- $a = 'aaz';
- $this->assertTrue(def($a));
- $this->assertFalse(not_def($a));
- }
-
- /**
- *
- */
- public function test_zones()
- {
- $this->assertContains('Europe/Paris',zones(''));
- $this->assertContains('a',zones('a'));
- }
-
- /**
- * @throws Exception
- */
- public function test_table_select()
- {
- $select = tables_select('base','?=','/');
- $this->assertStringContainsString('base',$select);
- $this->assertStringContainsString('?=',$select);
- $this->assertStringContainsString('/',$select);
- }
-
- /**
- *
- */
- public function test_true_or_false()
- {
- $this->assertNotEmpty(true_or_false(Connect::POSTGRESQL));
-
- }
-
- /**
- * @throws Exception
- */
- public function test_users_select()
- {
- $this->expectException(Exception::class);
- users_select('?=','postgres','choose',true);
-
- }
-
- /**
- * @throws Exception
- */
- public function test_base_select()
- {
- $this->expectException(Exception::class);
- bases_select('?=','','choose',false);
-
-
-
-
- }
-
- /**
- * @throws Exception
- */
- public function test_html()
- {
- $html = ['title','article','aside','footer','header','h1','h2','h3','h4','h5','h6','nav','section','div','p','li','ol','ul','pre'];
- foreach($html as $elem)
- {
- $this->assertEquals("<$elem>a</$elem>",html($elem,'a'));
- $this->assertEquals("<$elem class=\"a\">a</$elem>",html($elem,'a','a'));
- $this->assertEquals("<$elem class=\"a\" id=\"a\">a</$elem>",html($elem,'a','a','a'));
-
- }
-
- $this->assertEquals('<link href="a" rel="stylesheet">',html('link','a'));
- $this->assertEquals('<pre><code>a</code></pre>',html('code','a'));
- $this->assertEquals('<meta csrf="fr-latin9">',html('meta','csrf="fr-latin9"'));
- $this->assertEquals('<img src="a">',html('img','a'));
- $this->assertEquals('<img src="a" class="a">',html('img','a','a'));
-
- }
-
- /**
- *
- */
- public function test_id()
- {
- $this->assertNotEmpty(id());
- $this->assertNotEmpty(id('a'));
- }
-
-
- /**
- *
- */
- public function test_submit()
- {
-
- $this->assertFalse(submit('a'));
- $_POST['a'] = 'legend';
- $this->assertTrue(submit('a'));
-
- $this->assertFalse(submit('a',false));
- $_GET['a'] = 'legend';
- $this->assertTrue(submit('a',false));
- }
-
- /**
- *
- */
- public function test_push()
- {
- $a = [];
- push($a,1,2,3);
- $this->assertEquals([1,2,3],$a);
- }
-
- /**
- *
- */
- public function test_stack()
- {
- $a = [];
- stack($a,1,2,3);
- $this->assertEquals([3,2,1],$a);
- }
-
- /**
- *
- */
- public function test_has()
- {
- $this->assertTrue(has(1,[2,1,3]));
- $this->assertTrue(has(50,[2,1,3,50]));
- $this->assertFalse(has(4,[2,1,3]));
- $this->assertFalse(has(5,[2,1,3,50]));
- }
-
- /**
- *
- */
- public function test_values()
- {
- $this->assertEquals(['i','am','a','god'],values([0=> 'i',1 => 'am',3 => 'a' , 4=> 'god']));
- }
-
- /**
- *
- */
- public function test_keys()
- {
- $this->assertEquals([0,1,3,4],keys([0=> 'i',1 => 'am',3 => 'a' , 4=> 'god']));
- }
-
- /**
- *
- */
- public function test_merge()
- {
- $a = [1,2,3];
- merge($a,[4,5],[6,7,8],[9,10]);
- $this->assertEquals([1,2,3,4,5,6,7,8,9,10],$a);
- }
-
- /**
- * @throws Exception
- */
- public function test_collation()
- {
- $this->assertEmpty(collation($this->sqlite()->connect()));
- }
-
- /**
- * @throws Exception
- */
- public function test_charset()
- {
- $this->assertEmpty(charset($this->sqlite()->connect()));
- }
-
- /**
- * @throws Exception
- */
- public function test_base()
- {
- $this->assertInstanceOf(Base::class,base($this->sqlite()->connect(),$this->sqlite()->table()));
- $this->assertInstanceOf(Base::class,base($this->sqlite()->connect(),$this->sqlite()->table()));
-
- }
-
- /**
- * @throws Exception
- */
- public function test_user()
- {
- $this->assertInstanceOf(Users::class,user($this->sqlite()->connect()));
- $this->assertInstanceOf(Users::class,user($this->sqlite()->connect()));
- }
-
- /**
- * @throws Exception
- */
- public function test_pass()
- {
- $this->expectException(Exception::class);
- pass('postgres','postgres');
- }
-
- /**
- *
- */
- public function test_os()
- {
- $this->assertInstanceOf(Os::class,os());
- $this->assertEquals(Os::UNKNOWN,os(true));
- }
-
- /**
- *
- */
- public function test_device()
- {
- $this->assertInstanceOf(Device::class,\device());
- $this->assertEquals(Device::UNKNOWN,device(true));
- }
-
- /**
- *
- */
- public function test_browser()
- {
- $this->assertInstanceOf(Browser::class,browser());
- $this->assertEquals(Browser::UNKNOWN,browser(true));
- }
-
- /**
- *
- */
- public function test_is_browser()
- {
- $this->assertFalse(is_browser('Firefox'));
- }
-
- /**
- *
- */
- public function test_is_mobile()
- {
- $this->assertFalse(is_mobile());
- }
-
- /**
- * @throws Exception
- */
- public function test_superior()
- {
- $this->assertTrue(\superior(1,0));
- $this->assertFalse(\superior(0,5));
- }
-
- /**
- * @throws Exception
- */
- public function test_superior_exe()
- {
- $msg = 'matrix';
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
- superior(5,2,true,$msg);
- superior(8,4,true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_superior_or_equal()
- {
- $this->assertTrue(superior_or_equal(1,0));
- $this->assertTrue(superior_or_equal(1,1));
- $this->assertFalse(superior_or_equal(0,5));
- $this->assertFalse(superior_or_equal(4,5));
- }
-
- /**
- * @throws Exception
- */
- public function test_superior_or_equal_exe()
- {
- $msg = 'matrix';
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
- superior_or_equal(5,2,true,$msg);
- superior_or_equal(5,5,true,$msg);
- superior_or_equal(8,4,true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_inferior()
- {
- $this->assertTrue(inferior(0,4));
- $this->assertTrue(inferior(1,5));
- $this->assertFalse(inferior(60,5));
- $this->assertFalse(inferior(50,5));
- }
-
- /**
- * @throws Exception
- */
- public function test_inferior_exe()
- {
- $msg = 'matrix';
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
- inferior(22,50,true,$msg);
- inferior(2,50,true,$msg);
- }
-
-
- /**
- * @throws Exception
- */
- public function test_inferior_or_equal()
- {
- $this->assertTrue(inferior_or_equal(1,1));
- $this->assertTrue(inferior_or_equal(1,5));
- $this->assertFalse(inferior_or_equal(5,0));
- $this->assertFalse(inferior_or_equal(10,5));
- }
-
- /**
- * @throws Exception
- */
- public function test_inferior_or_equal_exe()
- {
- $msg = 'matrix';
- $this->expectException(Exception::class);
- $this->expectExceptionMessage($msg);
- inferior_or_equal(5,5,true,$msg);
- inferior_or_equal(5,50,true,$msg);
- }
-
- /**
- *
- */
- public function test_whoops()
- {
- $this->assertInstanceOf(Run::class,whoops());
- }
-
- /**
- * @throws Exception
- */
- public function test_value_before_a_key()
- {
- $a = [0 => "a",2 => 'b',3 => 'c',508 =>'d',4 => 'e' ];
- $this->assertEquals('a',before_key($a,2));
- $this->assertEquals('c',before_key($a,508));
- $this->assertEquals('d',before_key($a,4));
- }
- }
-}
diff --git a/tests/sqlite/base/BaseTest.php b/tests/sqlite/base/BaseTest.php
deleted file mode 100644
index 9a3a256..0000000
--- a/tests/sqlite/base/BaseTest.php
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-namespace Testing\sqlite\base {
-
-
- use Exception;
- use Testing\DatabaseTest;
-
- class BaseTest extends DatabaseTest
- {
-
- public function setUp(): void
- {
-
- $this->table = 'base';
- }
-
- public function test_show()
- {
- $this->expectException(Exception::class);
- $this->sqlite()->show_databases();
- $this->sqlite()->bases()->show();
-
- }
-
-
- /**
- * @throws Exception
- */
- public function test_multiples()
- {
- $this->assertTrue($this->sqlite()->bases()->create_multiples('a','b','c'));
- $this->assertTrue($this->sqlite()->bases()->drop_multiples('a','b','c'));
-
- }
- /**
- * @throws \Exception
- */
- public function test_has()
- {
- $this->expectException(Exception::class);
- $this->sqlite()->bases()->has();
- $this->sqlite()->has_bases();
- }
-
- /**
- * @throws \Exception
- */
- public function test_create()
- {
- $base = 'application';
-
- $this->assertTrue($this->sqlite()->bases()->remove('alex','marion','sandra'));
- $this->assertTrue($this->sqlite()->bases()->create('alex','marion','sandra'));
- $this->assertTrue($this->sqlite()->bases()->remove('alex','marion','sandra'));
-
- $this->assertTrue($this->sqlite()->bases()->create($base));
- $this->assertTrue($this->sqlite()->bases()->drop($base));
-
- }
-
- /**
- * @throws Exception
- */
- public function test_hidden()
- {
- $this->assertEquals([],$this->sqlite()->bases()->hidden_bases());
-
- $this->assertNotEmpty($this->sqlite()->bases()->hidden_tables());
- $this->assertEmpty($this->sqlite()->bases()->hidden_bases());
- }
- /**
- * @throws \Exception
- */
- public function test_charset()
- {
- $this->expectException(Exception::class);
- $this->sqlite()->collations();
- $this->sqlite()->charsets();
- }
-
-
- public function test_exec()
- {
- $this->expectException(Exception::class);
-
- $this->sqlite()->bases()->change_collation();
- $this->sqlite()->bases()->change_charset();
- $bidon = faker()->text(5);
-
-
- $this->sqlite()->bases()->set_collation($bidon)->change_collation();
- $this->sqlite()->bases()->set_charset($bidon)->change_charset();
- }
- /**
- * @throws \Exception
- */
- public function test_change()
- {
- $this->expectException(Exception::class);
- $this->sqlite()->bases()->set_charset('UTF8')->change_charset();
- $this->sqlite()->bases()->set_collation('C')->change_collation();
-
- }
-
-
- }
-}
diff --git a/tests/sqlite/connect/ConnectTest.php b/tests/sqlite/connect/ConnectTest.php
deleted file mode 100644
index 55951be..0000000
--- a/tests/sqlite/connect/ConnectTest.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-
-namespace Testing\sqlite\connect {
-
-
- use Imperium\Connexion\Connect;
- use Testing\DatabaseTest;
-
- class ConnectTest extends DatabaseTest
- {
-
-
-
- /**
- * @throws \Exception
- */
- public function test_transaction()
- {
- $m_queries = app()->connect();
-
- $table = 'base';
-
- $data = ['id',faker()->name,faker()->numberBetween(1,100),faker()->randomNumber(8),faker()->firstNameFemale,faker()->text(10),faker()->date(),faker()->date()];
-
- $all_mysql = $this->postgresql()->model()->count($table);
-
- $m_queries->queries(insert_into($table,$data));
-
-
-
- $m = $this->postgresql()->connect()->transaction();
-
- $this->assertTrue($m->commit());
- $this->assertTrue(different($this->postgresql()->model()->count($table),$all_mysql));
- }
-
- public function test_not()
- {
-
- $this->assertTrue($this->postgresql()->connect()->not(POSTGRESQL));
- $this->assertTrue($this->postgresql()->connect()->not(MYSQL));
- $this->assertFalse($this->postgresql()->connect()->not(SQLITE));
- $this->assertTrue($this->postgresql()->connect()->sqlite());
-
- }
-
-
-
-
-
- }
-} \ No newline at end of file
diff --git a/tests/sqlite/dumper/DumperTest.php b/tests/sqlite/dumper/DumperTest.php
deleted file mode 100644
index c65ea06..0000000
--- a/tests/sqlite/dumper/DumperTest.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-namespace Testing\sqlite\dumper {
-
- use Testing\DatabaseTest;
-
- class DumperTest extends DatabaseTest
- {
- public function test_dump()
- {
- $this->assertTrue($this->mysql()->dump(true));
- $this->assertFalse($this->mysql()->dump(false,'base','helper'));
- }
- }
-}
diff --git a/tests/sqlite/imperium/ImperiumTest.php b/tests/sqlite/imperium/ImperiumTest.php
deleted file mode 100644
index cefe2b3..0000000
--- a/tests/sqlite/imperium/ImperiumTest.php
+++ /dev/null
@@ -1,245 +0,0 @@
-<?php
-
-namespace Testing\sqlite\imperium {
-
-
- use Exception;
- use Imperium\Collection\Collection;
- use Imperium\App;
- use Testing\DatabaseTest;
-
-
- class ImperiumTest extends DatabaseTest
- {
- /**
- * @var string
- */
- private $table;
-
- /**
- * @throws Exception
- */
- public function setUp():void
- {
- $this->table = 'base';
- }
-
- /**
- * @throws Exception
- */
- public function test_find()
- {
-
- $this->assertNotEmpty($this->sqlite()->find($this->table,50));
- $this->assertNotEmpty($this->sqlite()->find_or_fail($this->table,50));
-
- }
- /**
- * @throws Exception
- */
- public function test_all()
- {
- $this->assertNotEmpty($this->sqlite()->all($this->table,'id'));
- }
-
- /**
- * @throws Exception
- */
- public function test_show_columns_type()
- {
- $this->assertNotEmpty($this->sqlite()->show_columns_types($this->table));
- }
-
- /**
- * @throws Exception
- */
- public function test_append_column()
- {
- $this->assertTrue($this->sqlite()->append_column($this->table,'salary',App::INTEGER,0,true));
- }
-
- public function test_save()
- {
- $number = 5;
- for ($i = 0; $i != $number; ++$i)
- {
-
- $data= [
- 'id' => 'id',
- 'name' => faker()->name,
- 'age' => faker()->numberBetween(1,100),
- 'phone' => faker()->randomNumber(8),
- 'sex' => faker()->firstNameMale,
- 'status' => faker()->text(20),
- 'days' => faker()->date(),
- 'date' => faker()->date(),
- 'salary' => faker()->numberBetween(0,200)
- ];
- $this->assertTrue($this->sqlite()->update_record(5,$data,$this->table));
- $this->assertTrue($this->sqlite()->save($this->table,$data));
- }
- }
-
- public function test_remove_by_id()
- {
- $this->assertTrue($this->sqlite()->remove_record($this->table,50));
- }
-
-
-
-
-
- public function test_change_base()
- {
- $this->expectException(Exception::class);
- $this->assertTrue($this->sqlite()->change_base_charset('UTF8'));
- }
-
- public function test_get_host()
- {
- $this->assertEquals('localhost',$this->sqlite()->connect()->host());
- }
-
- /**
- * @throws \Exception
- */
- public function test_remove_column()
- {
- $this->assertFalse($this->sqlite()->table()->column()->for($this->table)->drop('id'));
-
- $this->assertFalse($this->sqlite()->table()->column()->for($this->table)->drop('date'));
-
- }
-
-
-
- /**
- * @throws \Exception
- */
- public function test_show_users()
- {
- $this->expectException(Exception::class);
- $this->sqlite()->show_users();
-
-
-
- }
-
-
-
- /**
- * @throws \Exception
- */
- public function test_add_databases()
- {
-
- $this->expectException(Exception::class);
- $name = 'alexandra';
- $this->sqlite()->add_database($name,'UTF8','C');
- $this->sqlite()->remove_database($name);
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_exist()
- {
- $this->assertTrue($this->sqlite()->table_exist($this->table));
- }
-
-
-
- /**
- * @throws \Exception
- */
- public function test_remove_user()
- {
- $this->expectException(Exception::class);
- $first = 'dupond';
- $second = 'dupont';
- $this->assertTrue(add_user($first,$first));
- $this->assertTrue(add_user($second,$second));
- $this->assertTrue(remove_users($first,$second));
- }
-
- /**
- * @throws \Exception
- */
-
- public function test_pass()
- {
- $this->expectException(Exception::class);
- $this->sqlite()->change_user_password('postgres','postgres');
- }
- /**
- * @throws \Exception
- */
- public function test_show_columns()
- {
- $this->assertNotEmpty($this->sqlite()->table()->column()->for($this->table)->types());
-
- $this->assertNotEmpty($this->sqlite()->show_columns($this->table));
- }
-
- /**
- * @throws \Exception
- */
- public function test_has()
- {
- $this->assertTrue($this->sqlite()->has_column($this->table,'id'));
-
- $this->assertFalse($this->sqlite()->has_column($this->table,'utf8_general_ci'));
-
- $this->assertTrue($this->sqlite()->has_tables());
-
-
- }
-
- /**
- * @throws Exception
- */
- public function test_seed()
- {
- $this->assertTrue($this->sqlite()->seed_database());
- }
-
- /**
- * @throws Exception
- */
- public function test_add_user()
- {
- $this->expectException(Exception::class);
- $this->sqlite()->add_user('linux','linux');
-
- $this->sqlite()->remove_user('linux');
- }
-
-
- /**
- * @throws Exception
- */
- public function test_change()
- {
- $this->expectException(Exception::class);
-
- $this->sqlite()->change_base_collation('C');
-
- $this->sqlite()->change_table_charset($this->table,"UTF8");
-
- $this->sqlite()->change_table_collation($this->table,"C");
- }
-
- public function test_collection()
- {
-
- $this->assertInstanceOf(Collection::class,$this->sqlite()->collection());
-
- $this->assertEquals([],$this->sqlite()->collection()->collection());
-
- $this->assertEquals(['3'],$this->sqlite()->collection(['3'])->collection());
- }
-
-
- }
-}
diff --git a/tests/sqlite/import/ImportTest.php b/tests/sqlite/import/ImportTest.php
deleted file mode 100644
index f230804..0000000
--- a/tests/sqlite/import/ImportTest.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-namespace Testing\sqlite\import {
-
- use Testing\DatabaseTest;
-
- /**
- *
- */
- class ImportTest extends DatabaseTest
- {
-
- public function test_import()
- {
- $base = "marion";
- $this->assertTrue($this->sqlite()->bases()->copy($base));
- }
- }
-}
diff --git a/tests/sqlite/json/JsonTest.php b/tests/sqlite/json/JsonTest.php
deleted file mode 100644
index fac679f..0000000
--- a/tests/sqlite/json/JsonTest.php
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-
-namespace Testing\sqlite\json {
-
-
- use Exception;
- use Testing\DatabaseTest;
-
- class JsonTest extends DatabaseTest
- {
-
- public function setUp():void
- {
- $this->table = 'model';
- }
-
- /**
- * @throws \Exception
- */
- public function test_create()
- {
- $json = json('app.json');
- $json->add($this->sqlite()->model()->from($this->table)->all(),'bases');
-
- $this->assertTrue($json->generate());
- }
-
- public function test_json_encode_exception()
- {
- $this->expectException(Exception::class);
- $this->mysql()->json()->set_name('app.json')->encode(78995);
- }
-
- public function test_json()
- {
- $this->assertNotEmpty($this->mysql()->json()->set_name('app.json')->add(['a' => 1],'fantasy')->encode());
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_bases_to_json()
- {
- $this->expectException(Exception::class);
-
- bases_to_json('base.json');
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_sql()
- {
- $json = json('sql.json');
- $this->assertTrue($json->sql($this->mysql()->connect(),"SELECT * FROM $this->table")->generate());
- }
- /**
- * @throws \Exception
- */
- public function test_user_to_json()
- {
- $this->expectException(Exception::class);
- users_to_json('app.json');
- }
-
- /**
- * @throws \Exception
- */
- public function test_tables_to_json()
- {
- $this->assertTrue(tables_to_json('tables.json'));
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_decode()
- {
- $x = '{"users":["mysql.session","mysql.sys","root"],"bases":["information_schema","mysql","performance_schema","sys","zen"]}';
- $json = json($x);
- $this->assertNotEmpty($json->decode());
-
-
-
- }
- }
-} \ No newline at end of file
diff --git a/tests/sqlite/model/ModelTest.php b/tests/sqlite/model/ModelTest.php
deleted file mode 100644
index e97e6d7..0000000
--- a/tests/sqlite/model/ModelTest.php
+++ /dev/null
@@ -1,358 +0,0 @@
-<?php
-
-namespace Testing\sqlite\model {
-
- use Exception;
- use Imperium\Connexion\Connect;
- use Imperium\Model\Model;
- use PDO;
- use Imperium\Query\Query;
- use Testing\DatabaseTest;
-
- class ModelTest extends DatabaseTest
- {
-
- /**
- * @var Model
- */
- private $model;
-
- /**
- * @var string
- */
- private $table;
-
- /**
- * @throws Exception
- */
- public function setUp():void
- {
- $this->table = 'model';
- $this->model = $this->sqlite()->model()->from($this->table);
- }
-
- /**
- * @throws \Exception
- */
- public function test_find()
- {
- $this->assertCount(1,$this->model->find(2));
- $this->assertCount(1,$this->model->find_or_fail(2));
-
- $records = $this->model->all();
-
- foreach ($records as $record)
- {
- foreach ($this->model->columns() as $k => $v)
- {
- $this->assertNotEmpty($this->model->by($v,$record->$v));
-
- }
- }
- }
- public function test_only()
- {
- $this->assertNotEmpty($this->model->where('id', EQUAL,55)->only('name')->get());
-
- }
- /**
- * @throws Exception
- */
- public function test_search()
- {
- $this->assertNotEmpty($this->model->search('a'));
- $this->assertNotEmpty($this->model->search(4));
- }
-
- /**
- * @throws Exception
- */
- public function test_news_and_last()
- {
- $this->assertNotEmpty($this->model->news('id',20));
- $this->assertNotEmpty($this->model->news('id',20,5));
-
- $this->assertNotEmpty($this->model->last('id',20));
- $this->assertNotEmpty($this->model->last('id',20,5));
-
- }
- public function test_cool()
- {
- $bool = $this->model
- ->set('id','id')
- ->set('phone',faker()->randomNumber(8))
- ->set('name', faker()->name)
- ->set('date', faker()->date())
- ->set('sex', 'F')
- ->set('days', faker()->date())
- ->set('age', faker()->numberBetween(1,100))
- ->set('status','dead')
- ->save();
- $this->assertTrue($bool);
- }
-
- public function test_get_query()
- {
- $this->assertInstanceOf(Query::class,$this->model->query());
- }
-
-
- public function test_all()
- {
- $this->assertNotEmpty($this->model->all());
-
- }
- public function test_show()
- {
- $record = $this->model->show(
- 'table-responsive','table-dark','?table=',1,'table','remove','sure',
- '','','remove','edit','edit','previous','next','id','desc','search','','',
- '','',''
-
- );
-
- $this->assertStringContainsString('?table=', $record);
- $this->assertStringContainsString('remove', $record);
- $this->assertStringContainsString('/', $record);
- $this->assertStringContainsString('sure', $record);
- $this->assertStringContainsString('next', $record);
- $this->assertStringContainsString('previous', $record);
- $this->assertStringContainsString('remove', $record);
- $this->assertStringContainsString('class="btn btn-danger"', $record);
- $this->assertStringContainsString('class="btn btn-primary"', $record);
- }
-
- public function test_edit()
- {
-
- $form = edit($this->table,5,'/',id(),'update','');
- $this->assertNotEmpty($form);
-
- }
-
- public function test_primary()
- {
- $this->assertEquals('id',$this->model->primary());
- }
-
- public function test_create()
- {
-
- $form = create($this->table,'/',id(),'create','');
- $this->assertNotEmpty($form);
- }
-
- /**
- * @throws Exception
- */
- public function test_truncate()
- {
- $empty = 'the table is empty';
- $success = 'records was found';
-
- $sql ='';
-
- $this->assertTrue($this->model->truncate($this->table));
-
- $result = query_result($this->table,SELECT,$this->model->all('id'),$success,$empty,$empty,$sql);
-
- $this->assertCount(0,$this->model->all());
- $this->assertStringContainsString($empty,$result);
- $this->assertTrue( $this->model->is_empty($this->table));
-
- }
-
- /**
- * @throws Exception
- */
- public function test_insert()
- {
-
-
- $number = 5;
- for ($i = 0; $i != $number; ++$i)
- {
- $data = [
- 'id' => 'id',
- 'name' => faker()->name,
- 'age' => faker()->numberBetween(1,100),
- 'phone' => faker()->randomNumber(8),
- 'sex' => faker()->firstNameMale,
- 'status' => faker()->text(20),
- 'days' => faker()->date(),
- 'date' => faker()->date()
- ];
-
- $this->assertTrue($this->model->insert_new_record($data));
- }
-
- $this->assertCount($number,$this->model->all());
- $this->assertEquals($number,$this->model->count($this->table));
-
- }
-
-
-
- /**
- * @throws \Exception
- */
- public function test_show_tables()
- {
- $this->assertContains($this->table,$this->model->show_tables());
-
- }
-
- /**
- * @throws Exception
- */
- public function test_is()
- {
- $this->assertTrue($this->model->is_sqlite());
- $this->assertFalse($this->model->is_mysql());
- $this->assertFalse($this->model->is_postgresql());
-
- }
-
- /**
- * @throws Exception
- *
- */
- public function test_request()
- {
-
- $req = "select * from $this->table";
- $this->assertNotEmpty($this->model->request($req));
- }
-
-
- /**
- * @throws Exception
- */
- public function test_seed()
- {
- $this->assertTrue($this->model->seed(100));
- }
- /**
- * @throws Exception
- */
- public function test_execute()
- {
- $req = "select * from $this->table";
- $this->assertTrue($this->model->execute($req));
- }
-
- /**
- * @throws Exception
- */
- public function test_pdo()
- {
- $this->assertInstanceOf(PDO::class,$this->sqlite()->connect()->instance());
- $this->assertInstanceOf(PDO::class,$this->sqlite()->model()->pdo());
- }
-
- /**
- * @throws \Exception
- */
- public function test_find_or_fail()
- {
- $this->expectException(Exception::class);
- $this->model->find_or_fail(800);
-
- }
-
- /**
- * @throws Exception
- */
- public function test_remove()
- {
- $this->assertTrue($this->model->remove(4));
- }
-
-
- /**
- * @throws Exception
- */
-
- public function test_update()
- {
-
- $data = [
- 'id' => 'id',
- 'name' => faker()->name,
- 'age' => faker()->numberBetween(1,100),
- 'phone' => faker()->randomNumber(8),
- 'sex' => faker()->firstNameMale,
- 'status' => faker()->text(20),
- 'days' => faker()->date(),
- 'date' => faker()->date()
- ];
-
- $this->assertTrue($this->model->update_record(4,$data));
- }
-
-
-
- /**
- * @throws Exception
- */
- public function test_save()
- {
- $number = 5;
- for ($i = 0; $i != $number; ++$i)
- {
-
- $data = [
- 'id' => 'id',
- 'name' => faker()->name,
- 'age' => faker()->numberBetween(1,100),
- 'phone' => faker()->randomNumber(8),
- 'sex' => faker()->firstNameMale,
- 'status' => faker()->text(20),
- 'days' => faker()->date(),
- 'date' => faker()->date()
- ];
- $this->assertTrue($this->model->insert_new_record($data));
-
- }
- $this->assertCount(110,$this->model->all('id'));
- }
-
- /**
- * @throws Exception
- */
- public function test_found()
- {
- $this->assertEquals(11,$this->model->found());
- }
-
-
-
-
- /**
- * @throws Exception
- */
- public function test_get_instance()
- {
- $expected = PDO::class;
- $x = new Connect(Connect::POSTGRESQL,'',self::POSTGRESQL_USER,self::POSTGRESQL_PASS,Connect::LOCALHOST,'dump');
- $this->assertInstanceOf($expected,$x->instance());
-
- $x = new Connect(Connect::POSTGRESQL,$this->base,self::POSTGRESQL_USER,self::POSTGRESQL_PASS,Connect::LOCALHOST,'dump');
- $this->assertInstanceOf($expected,$x->instance());
-
- $this->expectException(Exception::class);
-
- $x = new Connect(Connect::MYSQL,'',self::POSTGRESQL_USER,self::POSTGRESQL_PASS,Connect::LOCALHOST,'dump');
- $x->instance();
- $x = new Connect(Connect::MYSQL,$this->base,self::POSTGRESQL_USER,self::POSTGRESQL_PASS,Connect::LOCALHOST,'dump');
- $x->instance();
- }
-
- public function test_dump()
- {
- $this->assertFalse($this->sqlite()->model()->dump($this->table));
- $this->assertTrue($this->sqlite()->model()->dump_base());
- }
-
- }
-}
diff --git a/tests/sqlite/query/QueryTest.php b/tests/sqlite/query/QueryTest.php
deleted file mode 100644
index 1984a6e..0000000
--- a/tests/sqlite/query/QueryTest.php
+++ /dev/null
@@ -1,131 +0,0 @@
-<?php
-
-namespace Testing\sqlite\query {
-
-
- use Exception;
- use Imperium\Query\Query;
- use Symfony\Component\DependencyInjection\Tests\Compiler\E;
- use Testing\DatabaseTest;
-
-
- class QueryTest extends DatabaseTest
- {
-
-
- /**
- * @var Query
- */
- private $query;
- /**
- * @var string
- */
- private $second_table;
-
-
- public function setUp():void
- {
- $this->table = 'query';
- $this->second_table = 'helpers';
- $this->query = $this->sqlite()->query()->from($this->table);
-
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_where()
- {
-
- $this->assertNotEmpty($this->query->mode(SELECT)->where('id','=',5)->only('date')->sql());
-
-
- $b = '1988-07-15 00:00:00';
- $e = '2010-07-30 00:00:00';
-
- $this->assertNotEmpty($this->query->mode(Query::SELECT)->where('id','!=',1)->get());
-
- $this->assertNotEmpty($this->query->mode(Query::SELECT)->where('name','!=','will')->get());
-
- $this->assertNotEmpty($this->query->mode(Query::SELECT)->like('a')->get());
-
-
- $this->assertNotEmpty($this->query->mode(Query::SELECT)->between('id',1,16)->get());
-
- $this->assertNotEmpty($this->query->mode(Query::SELECT)->only('id')->between('id',1,16)->get());
-
- $this->assertNotEmpty($this->query->mode(Query::SELECT)->only('id')->between('date',$b,$e)->get());
-
-
- $this->assertStringNotContainsString("ORDER BY ",$this->query->mode(Query::DELETE)->where('id','=',16)->sql());
-
-
- }
-
- /**
- * @throws Exception
- */
- public function test_union()
- {
-
-
- $limit = 10;
-
- $columns = 'id, name';
-
- $this->assertNotEmpty($this->query->mode(Query::UNION)->union($this->table,$this->second_table,'','')->get());
-
- $this->assertNotEmpty($this->query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,'','')->get());
-
- $this->assertNotEmpty($this->query->mode(Query::UNION)->union($this->table,$this->second_table,$columns, $columns)->limit($limit,0)->get());
-
- $this->assertNotEmpty($this->query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,$columns,$columns)->limit($limit,0)->get());
-
-
-
- $this->assertNotEmpty($this->query->mode(Query::UNION)->union($this->table,$this->second_table,'','')->get());
-
- $this->assertNotEmpty($this->query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,'','')->get());
-
- $this->assertNotEmpty($this->query->mode(Query::UNION)->union($this->table,$this->second_table,'','')->limit($limit,0)->get());
-
- $this->assertNotEmpty($this->query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,'','')->limit($limit,0)->get());
-
-
- $this->assertCount($limit,$this->query->mode(Query::UNION)->union($this->table,$this->second_table,'','')->limit($limit,0)->get());
-
- $this->assertCount($limit,$this->query->mode(Query::UNION_ALL)->union($this->table,$this->second_table,'','')->limit($limit,0)->get());
-
-
- }
-
-
-
- public function test_join()
- {
- $this->assertNotEmpty($this->query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->query->mode(CROSS_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->query->mode(CROSS_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(CROSS_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->query->mode(LEFT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(LEFT_JOIN)->join(DIFFERENT,$this->table,$this->second_table,'id','id','id')->get());
-
- $this->assertNotEmpty($this->query->mode(LEFT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(LEFT_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
-
-
- $this->assertNotEmpty($this->query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id')->get());
- $this->assertNotEmpty($this->query->mode(INNER_JOIN)->join(EQUAL,$this->table,$this->second_table,'id','id','id')->get());
-
-
- }
-
-
- }
-}
diff --git a/tests/sqlite/table/TableTest.php b/tests/sqlite/table/TableTest.php
deleted file mode 100644
index 5ba7bf9..0000000
--- a/tests/sqlite/table/TableTest.php
+++ /dev/null
@@ -1,291 +0,0 @@
-<?php
-
-
-namespace Testing\sqlite\table {
-
- use Imperium\App;
- use Imperium\Tables\Table;
- use Testing\DatabaseTest;
-
- class TableTest extends DatabaseTest
- {
-
- /**
- * @var string
- */
- private $table;
-
- /**
- * @throws \Exception
- */
- public function setUp():void
- {
- $this->table = 'model';
- }
-
- /**
- * @throws \Exception
- */
- public function test_columns_info()
- {
- $this->assertNotEmpty($this->postgresql()->table()->column()->for($this->table)->info());
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_types()
- {
- $this->assertNotEmpty($this->column()->types());
- }
- /**
- * @throws \Exception
- */
- public function test_seed()
- {
- $this->assertTrue($this->table()->seed(50));
- }
-
- /**
- * @throws \Exception
- */
- public function test_select()
- {
-
- $this->assertNotEmpty($this->table()->select(202));
-
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_change()
- {
- $this->expectException(\Exception::class);
- $this->table()->set_charset('UTF8')->change_charset();
- $this->table()->set_collation('C')->change_collation();
- $this->table()->convert('UTF8','C');
- }
-
- /**
- * @throws \Exception
- */
- public function test_primary_key()
- {
- $this->assertEquals('id', $this->column()->primary_key());
- }
-
- /**
- * @throws \Exception
- */
- public function test_show()
- {
- $this->assertContains('base',$this->table()->show());
- }
-
- /**
- * @throws \Exception
- */
- public function test_has_columns_type()
- {
-
- $this->assertTrue($this->column()->has_types('INTEGER','DATETIME'));
-
- $this->assertFalse($this->column()->has_types('int'));
- }
- /**
- * @throws \Exception
- */
- public function test_get_tpm_name()
- {
- $this->assertNotEmpty($this->table()->get_current_tmp_table());
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_type()
- {
- foreach ($this->table()->column()->for($this->table)->show() as $column)
- $this->assertNotEmpty($this->column()->column_type($column));
- }
-
- /**
- * @throws \Exception
- */
- public function test_has()
- {
- $this->assertTrue($this->table()->has());
- $this->assertTrue($this->column()->exist('id'));
- }
-
-
- /**
- * @throws \Exception
- */
-
- public function test_remove_by_id()
- {
- $this->assertTrue($this->table()->remove(20));
- }
-
- /**
- * @throws \Exception
- */
- public function test_not_exist()
- {
- $this->assertTrue($this->table()->not_exist('alexandra'));
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_the_last_field()
- {
-
- $columns = $this->column()->show();
- $end = collection($columns)->last();
-
- $this->assertFalse(equal($this->column()->last(),'id'));
- $this->assertFalse(equal($this->column()->last(),'name'));
-
- $this->assertTrue(equal($this->column()->last(),$end));
- }
-
- /**
- * @throws \Exception
- */
- public function test_truncate()
- {
- $this->assertTrue($this->table()->truncate(current_table()));
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_append_column()
- {
- $column = 'moria';
-
- $instance = $this->column();
-
- $this->assertTrue($instance->add($column,App::TEXT,255,true));
- $this->assertTrue($instance->exist($column));
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_ignore()
- {
-
- $this->assertContains(current_table(),$this->table()->show());
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_columns_to_string()
- {
-
- $this->assertEquals('id, name, age, phone, sex, status, days, date, moria',$this->column()->columns_to_string());
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_count()
- {
- $this->assertEquals(160,$this->table()->count());
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_found()
- {
- $this->assertEquals(11,$this->table()->found());
-
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_current()
- {
- $this->assertEquals('model',$this->table()->current());
- }
-
-
- /**
- * @throws \Exception
- */
- public function test_columns_not_exist()
- {
- $this->assertTrue($this->column()->not_exist('excalibur'));
-
- $this->assertFalse($this->column()->not_exist('id'));
- }
- /**
- * @throws \Exception
- */
- public function test_dump()
- {
-
- $this->assertFalse($this->table()->dump());
- $this->assertFalse($this->table()->dump(current_table()));
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_rename()
- {
-
-
- $old = 'name';
- $new = 'username';
-
- $this->assertTrue($this->column()->rename($old, $new));
- $this->assertTrue($this->column()->rename($new, $old));
-
-
- $this->assertTrue($this->table()->rename($new));
-
- $this->assertTrue($this->table()->drop(current_table()));
-
-
-
- }
-
- /**
- * @return Table
- * @throws \Exception
- */
- private function table(): Table
- {
- return $this->postgresql()->table()->from($this->table);
- }
-
- /**
- * @return \Imperium\Tables\Column
- * @throws \Exception
- */
- private function column(): \Imperium\Tables\Column
- {
- return $this->table()->column()->for($this->table);
- }
-
- }
-}
diff --git a/tests/sqlite/users/UsersTest.php b/tests/sqlite/users/UsersTest.php
deleted file mode 100644
index a289bb6..0000000
--- a/tests/sqlite/users/UsersTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-
-namespace Testing\sqlite\users {
-
-
- use Testing\DatabaseTest;
-
- class UsersTest extends DatabaseTest
- {
- /**
- * @throws \Exception
- */
- public function test_show()
- {
-
- $this->expectException(\Exception::class);
-
- $this->sqlite()->users()->show();
-
- }
-
- /**
- * @throws \Exception
- */
- public function test_create_and_drop()
- {
-
- $this->expectException(\Exception::class);
- $name = 'voku';
-
- $this->sqlite()->users()->set_name($name)->set_password($name)->create();
- $this->sqlite()->users()->drop($name);
- }
-
- }
-} \ No newline at end of file
diff --git a/tests/trans/TransTest.php b/tests/trans/TransTest.php
deleted file mode 100644
index dcefda5..0000000
--- a/tests/trans/TransTest.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-
-namespace Testing\trans {
-
-
- use PHPUnit\Framework\TestCase;
-
- class TransTest extends TestCase
- {
-
- public function test()
- {
- $this->assertEquals('Bienvenue Willy',trans('Welcome %s','Willy'));
- $this->assertEquals('Rechercher',trans('Search'));
- $this->assertEquals('Allez à Ibiza le lundi à dix heures',trans('Go at Ibiza at the %s at the %s hour','lundi','dix'));
- }
- }
-} \ No newline at end of file