-
Notifications
You must be signed in to change notification settings - Fork 7
/
test-new
executable file
·79 lines (65 loc) · 1.47 KB
/
test-new
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
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env php
<?php
$content = '';
if ($argc < 2) {
throw new Exception('You need to enter test name');
}
$test_name = $argv[1];
$test_cnt = isset($argv[2]) ? $argv[2] : 2;
$file_name = "$test_name.php";
$file_path = __DIR__ . "/Tests/$file_name";
$user_name = trim(exec('git config user.name'));
$user_mail = 'alex at itvault dot info';
$license = 'The BSD 3-Clause License.';
$lic_link = 'https://tldrlegal.com/license/bsd-3-clause-license-(revised)';
$curr_date = date('D M d H:i:s Y');
$curr_year = date('Y');
$content .= <<<EOT
<?php
/**
* @todo <Test description here>
* @file $file_name
*
* PHP version 5.6+
*
* @author $user_name <$user_mail>
* @copyright © 2013-$curr_year $user_name
* @date $curr_date
* @license $license
* <$lic_link>
*/
namespace Tests;
use Veles\Tools\CliProgressBar;
use Veles\Tools\Timer;
use Application\TestApplication;
/**
* Class $test_name
*
* @author $user_name <$user_mail>
*/
class $test_name extends TestApplication
{
protected \$repeats = 10000;
public function run()
{
\$repeats = \$this->getRepeats();
EOT;
$i = 0;
while (++$i <= $test_cnt) {
$content .= <<<EOT
Timer::reset();
\$bar = new CliProgressBar(\$repeats);
for (\$i = 1; \$i <= \$repeats; ++\$i) {
Timer::start();
//TODO Place here your code
Timer::stop();
\$bar->update(\$i);
}
\$this->addResult('ResultName$i', Timer::get());
EOT;
}
$content .= <<<EOT
}
}
EOT;
file_put_contents($file_path, $content);