Organized tests file structure
This commit is contained in:
parent
eebb862332
commit
2f54ee75b7
8 changed files with 38 additions and 26 deletions
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
class CommentAddTest extends AbstractTest
|
class AddCommentJobTest extends AbstractTest
|
||||||
{
|
{
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
class CommentDeleteTest extends AbstractTest
|
class DeleteCommentJobTest extends AbstractTest
|
||||||
{
|
{
|
||||||
public function testOwn()
|
public function testOwn()
|
||||||
{
|
{
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
class CommentEditTest extends AbstractTest
|
class EditCommentJobTest extends AbstractTest
|
||||||
{
|
{
|
||||||
public function testOwn()
|
public function testOwn()
|
||||||
{
|
{
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
class CommentListTest extends AbstractTest
|
class ListCommentJobTest extends AbstractTest
|
||||||
{
|
{
|
||||||
public function testNone()
|
public function testNone()
|
||||||
{
|
{
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
class CommentPreviewTest extends AbstractTest
|
class PreviewCommentJobTest extends AbstractTest
|
||||||
{
|
{
|
||||||
public function testPreview()
|
public function testPreview()
|
||||||
{
|
{
|
|
@ -1,22 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
class MiscTest extends AbstractTest
|
class LoggerTest extends AbstractTest
|
||||||
{
|
{
|
||||||
public function testEncryption()
|
|
||||||
{
|
|
||||||
$lengths = [0];
|
|
||||||
for ($i = 0; $i < 20; $i ++)
|
|
||||||
$lengths []= mt_rand(0, 10000);
|
|
||||||
|
|
||||||
foreach ($lengths as $length)
|
|
||||||
{
|
|
||||||
$text = '';
|
|
||||||
foreach (range(0, $length) as $j)
|
|
||||||
$text .= chr(mt_rand(1, 255));
|
|
||||||
|
|
||||||
$this->assert->areEqual($text, TextHelper::decrypt(TextHelper::encrypt($text)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testLogging()
|
public function testLogging()
|
||||||
{
|
{
|
||||||
$logPath = __DIR__ . '/logs/{yyyy}-{mm}-{dd}.log';
|
$logPath = __DIR__ . '/logs/{yyyy}-{mm}-{dd}.log';
|
19
tests/MiscTests/TextHelperTest.php
Normal file
19
tests/MiscTests/TextHelperTest.php
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
class TextHelperTest extends AbstractTest
|
||||||
|
{
|
||||||
|
public function testEncryption()
|
||||||
|
{
|
||||||
|
$lengths = [0];
|
||||||
|
for ($i = 0; $i < 20; $i ++)
|
||||||
|
$lengths []= mt_rand(0, 10000);
|
||||||
|
|
||||||
|
foreach ($lengths as $length)
|
||||||
|
{
|
||||||
|
$text = '';
|
||||||
|
foreach (range(0, $length) as $j)
|
||||||
|
$text .= chr(mt_rand(1, 255));
|
||||||
|
|
||||||
|
$this->assert->areEqual($text, TextHelper::decrypt(TextHelper::encrypt($text)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../src/core.php';
|
||||||
|
require_once __DIR__ . '/../src/upgrade.php';
|
||||||
|
\Chibi\Autoloader::registerFileSystem(__DIR__);
|
||||||
|
|
||||||
$configPath = __DIR__ . '/test.ini';
|
$configPath = __DIR__ . '/test.ini';
|
||||||
|
|
||||||
$options = getopt('cf:', ['clean', 'filter:']);
|
$options = getopt('cf:', ['clean', 'filter:']);
|
||||||
|
@ -35,9 +39,6 @@ try
|
||||||
|
|
||||||
file_put_contents($configPath, implode(PHP_EOL, $configIni));
|
file_put_contents($configPath, implode(PHP_EOL, $configIni));
|
||||||
|
|
||||||
require_once __DIR__ . '/../src/core.php';
|
|
||||||
require_once __DIR__ . '/../src/upgrade.php';
|
|
||||||
|
|
||||||
upgradeDatabase();
|
upgradeDatabase();
|
||||||
|
|
||||||
runAll($filter);
|
runAll($filter);
|
||||||
|
@ -49,7 +50,15 @@ finally
|
||||||
|
|
||||||
function getTestMethods($filter)
|
function getTestMethods($filter)
|
||||||
{
|
{
|
||||||
$testClasses = \Chibi\Util\Reflection::loadClasses(glob(__DIR__ . '/*Test.php'));
|
$testFiles = [];
|
||||||
|
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__)) as $fileName)
|
||||||
|
{
|
||||||
|
$path = $fileName->getPathname();
|
||||||
|
if (preg_match('/.*Test.php$/', $path))
|
||||||
|
$testFiles []= $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
$testClasses = \Chibi\Util\Reflection::loadClasses($testFiles);
|
||||||
|
|
||||||
if ($filter !== null)
|
if ($filter !== null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue