Improve coding standard

This commit is contained in:
Meritoo
2018-05-06 14:41:13 +02:00
parent 5be449a83d
commit 96bdb6eb60
2 changed files with 46 additions and 21 deletions

View File

@@ -14,6 +14,7 @@ use Meritoo\Common\Exception\Regex\InvalidColorHexValueException;
use Meritoo\Common\Test\Base\BaseTestCase;
use Meritoo\Common\Utilities\Locale;
use Meritoo\Common\Utilities\Miscellaneous;
use ReflectionException;
use stdClass;
/**
@@ -28,6 +29,9 @@ class MiscellaneousTest extends BaseTestCase
private $stringCommaSeparated;
private $stringDotSeparated;
/**
* @throws ReflectionException
*/
public function testConstructor()
{
static::assertHasNoConstructor(Miscellaneous::class);
@@ -363,35 +367,33 @@ class MiscellaneousTest extends BaseTestCase
self::assertEquals('Lorem ipsum dolor sit---amet, consectetur---adipiscing---elit', Miscellaneous::breakLongText($this->stringCommaSeparated, 20, '---'));
}
public function testRemoveDirectory()
public function testRemoveDirectoryUsingNotExistingDirectory()
{
/*
* Removing not existing directory
*/
self::assertTrue(Miscellaneous::removeDirectory('/abc/def/ghi'));
self::assertNull(Miscellaneous::removeDirectory('/abc/def/ghi'));
}
/*
* Removing not directory
*/
public function testRemoveDirectoryUsingNoDirectory()
{
$directoryPath = sys_get_temp_dir() . '/ipsum.txt';
touch($directoryPath);
self::assertTrue(Miscellaneous::removeDirectory($directoryPath));
}
/*
* Removing simple directory
*/
public function testRemoveDirectoryUsingSimpleDirectory()
{
$directoryPath = sys_get_temp_dir() . '/lorem/ipsum';
mkdir($directoryPath, 0777, true);
self::assertTrue(Miscellaneous::removeDirectory($directoryPath));
}
/*
* Removing more complex directory
*/
public function testRemoveDirectoryUsingComplexDirectory()
{
$directory1Path = sys_get_temp_dir() . '/lorem/ipsum';
$directory2Path = sys_get_temp_dir() . '/lorem/dolor/sit';
mkdir($directory1Path, 0777, true);
mkdir($directory2Path, 0777, true);
self::assertTrue(Miscellaneous::removeDirectory(sys_get_temp_dir() . '/lorem', false));
}
@@ -661,6 +663,10 @@ class MiscellaneousTest extends BaseTestCase
self::assertEquals(255, Miscellaneous::getValidColorComponent(255, false));
}
/**
* @throws IncorrectColorHexLengthException
* @throws InvalidColorHexValueException
*/
public function testGetInvertedColorWithIncorrectLength()
{
$this->setExpectedException(IncorrectColorHexLengthException::class);
@@ -675,6 +681,10 @@ class MiscellaneousTest extends BaseTestCase
Miscellaneous::getInvertedColor('1234567');
}
/**
* @throws IncorrectColorHexLengthException
* @throws InvalidColorHexValueException
*/
public function testGetInvertedColorWithInvalidValue()
{
$this->setExpectedException(InvalidColorHexValueException::class);
@@ -686,6 +696,10 @@ class MiscellaneousTest extends BaseTestCase
Miscellaneous::getInvertedColor('00ppqq');
}
/**
* @throws IncorrectColorHexLengthException
* @throws InvalidColorHexValueException
*/
public function testGetInvertedColor()
{
/*