-
Notifications
You must be signed in to change notification settings - Fork 7
/
test-example
executable file
·66 lines (57 loc) · 1.63 KB
/
test-example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env php
<?php
/**
* Test loader
*
* 1. Make copy of this file:
* cp test-example test
*
* 2. Edit your Db or cache parameters in copy file.
*
* 3. Run tests using new created file:
* ./test <TestName>
*
* @file test
*
* PHP version 5.4+
*
* @author Yancharuk Alexander <alex at itvault dot info>
* @date Сбт Фев 16 17:01:16 2013
* @license The BSD 3-Clause License.
* <https://tldrlegal.com/license/bsd-3-clause-license-(revised)>
*/
use Veles\AutoLoader;
use Veles\DataBase\ConnectionPools\ConnectionPool;
use Veles\DataBase\Connections\PdoConnection;
use Veles\DataBase\Adapters\PdoAdapter;
use Veles\DataBase\Db;
define('BASE_PATH', realpath(__DIR__));
setlocale(LC_ALL, 'ru_RU.utf8');
date_default_timezone_set('Europe/Moscow');
/** @noinspection PhpIncludeInspection */
require 'lib/Veles/AutoLoader.php';
set_include_path(
implode(PATH_SEPARATOR, [BASE_PATH . '/lib', get_include_path()])
);
AutoLoader::init();
// Db class initialization
$pool = new ConnectionPool();
$conn = new PdoConnection('master');
$conn->setDsn('mysql:host=localhost;dbname=dbname;charset=utf8')
->setUserName('user')
->setPassword('password')
->setOptions([
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_EMULATE_PREPARES => false
]);
$pool->addConnection($conn, true);
Db::setAdapter((new PdoAdapter)->setPool($pool));
if ($argc < 2) {
throw new Exception('Enter class name as parameter!');
}
$app_class = "Tests\\$argv[1]";
$application = new $app_class;
$application->testDependencies();
$application->run();
$application->showResults();