Tests > use "Meritoo\Test\Common" namespace (instead of "Meritoo\Common\Test")

This commit is contained in:
Meritoo
2019-03-04 19:35:42 +01:00
parent fe40d9caee
commit 5ebde80646
54 changed files with 134 additions and 125 deletions

View File

@@ -6,6 +6,7 @@ Common and useful classes, methods, exceptions etc.
1. Arrays > refactoring & more tests
2. ValueObject > Human > represents a human
3. Tests > use `Meritoo\Test\Common` namespace (instead of `Meritoo\Common\Test`)
# 0.1.5

View File

@@ -36,7 +36,7 @@
},
"autoload-dev": {
"psr-4": {
"Meritoo\\Common\\Test\\": "tests/"
"Meritoo\\Test\\Common\\": "tests/"
}
},
"config": {

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Collection;
namespace Meritoo\Test\Common\Collection;
use ArrayIterator;
use Generator;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Exception\Base;
namespace Meritoo\Test\Common\Exception\Base;
use Meritoo\Common\Exception\Base\UnknownTypeException;
use Meritoo\Common\Test\Base\BaseTestCase;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Exception\Bundle;
namespace Meritoo\Test\Common\Exception\Bundle;
use Meritoo\Common\Exception\Bundle\IncorrectBundleNameException;
use Meritoo\Common\Test\Base\BaseTestCase;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Exception\Date;
namespace Meritoo\Test\Common\Exception\Date;
use Generator;
use Meritoo\Common\Exception\Type\UnknownDatePartTypeException;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Exception\File;
namespace Meritoo\Test\Common\Exception\File;
use Generator;
use Meritoo\Common\Exception\File\EmptyFileException;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Exception\File;
namespace Meritoo\Test\Common\Exception\File;
use Meritoo\Common\Exception\File\EmptyFilePathException;
use Meritoo\Common\Test\Base\BaseTestCase;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Exception\File;
namespace Meritoo\Test\Common\Exception\File;
use Generator;
use Meritoo\Common\Exception\File\NotExistingFileException;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Exception\Method;
namespace Meritoo\Test\Common\Exception\Method;
use Generator;
use Meritoo\Common\Exception\Method\DisabledMethodException;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Exception\Reflection;
namespace Meritoo\Test\Common\Exception\Reflection;
use Generator;
use Meritoo\Common\Exception\Reflection\CannotResolveClassNameException;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Exception\Reflection;
namespace Meritoo\Test\Common\Exception\Reflection;
use Generator;
use Meritoo\Common\Exception\Reflection\MissingChildClassesException;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Exception\Reflection;
namespace Meritoo\Test\Common\Exception\Reflection;
use Meritoo\Common\Exception\Reflection\NotExistingPropertyException;
use Meritoo\Common\Test\Base\BaseTestCase;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Exception\Reflection;
namespace Meritoo\Test\Common\Exception\Reflection;
use Generator;
use Meritoo\Common\Exception\Reflection\TooManyChildClassesException;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Exception\Regex;
namespace Meritoo\Test\Common\Exception\Regex;
use Generator;
use Meritoo\Common\Exception\Regex\IncorrectColorHexLengthException;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Exception\Regex;
namespace Meritoo\Test\Common\Exception\Regex;
use Generator;
use Meritoo\Common\Exception\Regex\InvalidColorHexValueException;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Exception\Regex;
namespace Meritoo\Test\Common\Exception\Regex;
use Generator;
use Meritoo\Common\Exception\Regex\InvalidHtmlAttributesException;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Exception\Regex;
namespace Meritoo\Test\Common\Exception\Regex;
use Generator;
use Meritoo\Common\Exception\Regex\InvalidUrlException;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Exception\Type;
namespace Meritoo\Test\Common\Exception\Type;
use Generator;
use Meritoo\Common\Exception\Type\UnknownOopVisibilityTypeException;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Test\Base;
namespace Meritoo\Test\Common\Test\Base;
use DateTime;
use Generator;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Type\Base;
namespace Meritoo\Test\Common\Type\Base;
use Generator;
use Meritoo\Common\Test\Base\BaseTestCase;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Type;
namespace Meritoo\Test\Common\Type;
use Meritoo\Common\Test\Base\BaseTypeTestCase;
use Meritoo\Common\Type\DatePartType;
@@ -19,29 +19,6 @@ use Meritoo\Common\Type\DatePartType;
*/
class DatePartTypeTest extends BaseTypeTestCase
{
/**
* {@inheritdoc}
*/
protected function getAllExpectedTypes()
{
return [
'DAY' => DatePartType::DAY,
'HOUR' => DatePartType::HOUR,
'MINUTE' => DatePartType::MINUTE,
'MONTH' => DatePartType::MONTH,
'SECOND' => DatePartType::SECOND,
'YEAR' => DatePartType::YEAR,
];
}
/**
* {@inheritdoc}
*/
protected function getTestedTypeInstance()
{
return new DatePartType();
}
/**
* {@inheritdoc}
*/
@@ -97,4 +74,27 @@ class DatePartTypeTest extends BaseTypeTestCase
true,
];
}
/**
* {@inheritdoc}
*/
protected function getAllExpectedTypes()
{
return [
'DAY' => DatePartType::DAY,
'HOUR' => DatePartType::HOUR,
'MINUTE' => DatePartType::MINUTE,
'MONTH' => DatePartType::MONTH,
'SECOND' => DatePartType::SECOND,
'YEAR' => DatePartType::YEAR,
];
}
/**
* {@inheritdoc}
*/
protected function getTestedTypeInstance()
{
return new DatePartType();
}
}

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Type;
namespace Meritoo\Test\Common\Type;
use DateTime;
use Generator;
@@ -214,34 +214,6 @@ class DatePeriodTest extends BaseTypeTestCase
];
}
/**
* Returns all expected types of the tested type
*
* @return array
*/
protected function getAllExpectedTypes()
{
return [
'LAST_MONTH' => DatePeriod::LAST_MONTH,
'LAST_WEEK' => DatePeriod::LAST_WEEK,
'LAST_YEAR' => DatePeriod::LAST_YEAR,
'NEXT_MONTH' => DatePeriod::NEXT_MONTH,
'NEXT_WEEK' => DatePeriod::NEXT_WEEK,
'NEXT_YEAR' => DatePeriod::NEXT_YEAR,
'THIS_MONTH' => DatePeriod::THIS_MONTH,
'THIS_WEEK' => DatePeriod::THIS_WEEK,
'THIS_YEAR' => DatePeriod::THIS_YEAR,
];
}
/**
* {@inheritdoc}
*/
protected function getTestedTypeInstance()
{
return new DatePeriod();
}
/**
* {@inheritdoc}
*/
@@ -277,4 +249,32 @@ class DatePeriodTest extends BaseTypeTestCase
true,
];
}
/**
* Returns all expected types of the tested type
*
* @return array
*/
protected function getAllExpectedTypes()
{
return [
'LAST_MONTH' => DatePeriod::LAST_MONTH,
'LAST_WEEK' => DatePeriod::LAST_WEEK,
'LAST_YEAR' => DatePeriod::LAST_YEAR,
'NEXT_MONTH' => DatePeriod::NEXT_MONTH,
'NEXT_WEEK' => DatePeriod::NEXT_WEEK,
'NEXT_YEAR' => DatePeriod::NEXT_YEAR,
'THIS_MONTH' => DatePeriod::THIS_MONTH,
'THIS_WEEK' => DatePeriod::THIS_WEEK,
'THIS_YEAR' => DatePeriod::THIS_YEAR,
];
}
/**
* {@inheritdoc}
*/
protected function getTestedTypeInstance()
{
return new DatePeriod();
}
}

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities\Arrays;
namespace Meritoo\Test\Common\Utilities\Arrays;
/**
* Simple class convertible to string.

View File

@@ -6,11 +6,11 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities;
namespace Meritoo\Test\Common\Utilities;
use Meritoo\Common\Test\Base\BaseTestCase;
use Meritoo\Common\Test\Utilities\Arrays\SimpleToString;
use Meritoo\Common\Utilities\Arrays;
use Meritoo\Test\Common\Utilities\Arrays\SimpleToString;
/**
* Test case of the useful arrays methods

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities;
namespace Meritoo\Test\Common\Utilities;
use Meritoo\Common\Test\Base\BaseTestCase;
use Meritoo\Common\Utilities\Bootstrap4CssSelector;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities;
namespace Meritoo\Test\Common\Utilities;
use Generator;
use Meritoo\Common\Exception\Bundle\IncorrectBundleNameException;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities;
namespace Meritoo\Test\Common\Utilities;
use Generator;
use Meritoo\Common\Test\Base\BaseTestCase;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities;
namespace Meritoo\Test\Common\Utilities;
use Meritoo\Common\Test\Base\BaseTestCase;
use Meritoo\Common\Utilities\CssSelector;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities;
namespace Meritoo\Test\Common\Utilities;
use DateInterval;
use DateTime;
@@ -680,7 +680,8 @@ class DateTest extends BaseTestCase
}
/**
* @param int $period The period, type of period. One of DatePeriod class constants, e.g. DatePeriod::LAST_WEEK.
* @param int $period The period, type of period. One of DatePeriod class constants, e.g.
* DatePeriod::LAST_WEEK.
* @param DatePeriod $expected Expected start and end date for given period
*
* @dataProvider provideCorrectPeriod
@@ -982,7 +983,9 @@ class DateTest extends BaseTestCase
DatePeriod::NEXT_WEEK,
new DatePeriod(
(new DateTime('this week'))->add(new DateInterval('P7D'))->setTime(0, 0, 0),
(new DateTime('this week'))->add(new DateInterval('P7D'))->add(new DateInterval('P6D'))->setTime(23, 59, 59)
(new DateTime('this week'))->add(new DateInterval('P7D'))
->add(new DateInterval('P6D'))
->setTime(23, 59, 59)
),
];

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities;
namespace Meritoo\Test\Common\Utilities;
use Meritoo\Common\Test\Base\BaseTestCase;
use Meritoo\Common\Utilities\GeneratorUtility;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities;
namespace Meritoo\Test\Common\Utilities;
use Generator;
use Meritoo\Common\Test\Base\BaseTestCase;
@@ -80,8 +80,8 @@ class LocaleTest extends BaseTestCase
}
/**
* @param int $category Named constant specifying the category of the functions affected by the locale setting.
* It's the same constant as required by setlocale() function.
* @param int $category Named constant specifying the category of the functions affected by the locale
* setting. It's the same constant as required by setlocale() function.
* @param string $languageCode Language code, in ISO 639-1 format. Short form of the locale, e.g. "fr".
* @param string $countryCode Country code, in ISO 3166-1 alpha-2 format, e.g. "FR"
* @param string $expectedLocale Expected locale

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities;
namespace Meritoo\Test\Common\Utilities;
use Generator;
use Meritoo\Common\Test\Base\BaseTestCase;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities;
namespace Meritoo\Test\Common\Utilities;
use Generator;
use Meritoo\Common\Exception\Regex\IncorrectColorHexLengthException;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities;
namespace Meritoo\Test\Common\Utilities;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManager;
@@ -260,7 +260,8 @@ class QueryBuilderUtilityTest extends BaseTestCase
$entityManager
->expects(static::any())
->method('getExpressionBuilder')
->willReturn(new Expr());
->willReturn(new Expr())
;
yield[
(new QueryBuilder($entityManager))->from('lorem_ipsum', 'lm'),

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities\Reflection;
namespace Meritoo\Test\Common\Utilities\Reflection;
/**
* The A class.

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities\Reflection;
namespace Meritoo\Test\Common\Utilities\Reflection;
/**
* The B class.

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities\Reflection;
namespace Meritoo\Test\Common\Utilities\Reflection;
/**
* The C class.

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities\Reflection;
namespace Meritoo\Test\Common\Utilities\Reflection;
/**
* The D class.

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities\Reflection;
namespace Meritoo\Test\Common\Utilities\Reflection;
/**
* The E trait.

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities\Reflection;
namespace Meritoo\Test\Common\Utilities\Reflection;
/**
* The F class.

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities\Reflection;
namespace Meritoo\Test\Common\Utilities\Reflection;
/**
* The G class.

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities\Reflection;
namespace Meritoo\Test\Common\Utilities\Reflection;
/**
* The H class.

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities\Reflection;
namespace Meritoo\Test\Common\Utilities\Reflection;
/**
* The H interface.

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities;
namespace Meritoo\Test\Common\Utilities;
use DateTime;
use Generator;
@@ -16,16 +16,16 @@ use Meritoo\Common\Exception\Reflection\MissingChildClassesException;
use Meritoo\Common\Exception\Reflection\NotExistingPropertyException;
use Meritoo\Common\Exception\Reflection\TooManyChildClassesException;
use Meritoo\Common\Test\Base\BaseTestCase;
use Meritoo\Common\Test\Utilities\Reflection\A;
use Meritoo\Common\Test\Utilities\Reflection\B;
use Meritoo\Common\Test\Utilities\Reflection\C;
use Meritoo\Common\Test\Utilities\Reflection\D;
use Meritoo\Common\Test\Utilities\Reflection\E;
use Meritoo\Common\Test\Utilities\Reflection\F;
use Meritoo\Common\Test\Utilities\Reflection\G;
use Meritoo\Common\Test\Utilities\Reflection\H;
use Meritoo\Common\Test\Utilities\Reflection\I;
use Meritoo\Common\Utilities\Reflection;
use Meritoo\Test\Common\Utilities\Reflection\A;
use Meritoo\Test\Common\Utilities\Reflection\B;
use Meritoo\Test\Common\Utilities\Reflection\C;
use Meritoo\Test\Common\Utilities\Reflection\D;
use Meritoo\Test\Common\Utilities\Reflection\E;
use Meritoo\Test\Common\Utilities\Reflection\F;
use Meritoo\Test\Common\Utilities\Reflection\G;
use Meritoo\Test\Common\Utilities\Reflection\H;
use Meritoo\Test\Common\Utilities\Reflection\I;
use ReflectionProperty;
/**
@@ -107,7 +107,7 @@ class ReflectionTest extends BaseTestCase
/*
* Existing class
*/
self::assertEquals('Meritoo\Common\Test\Utilities', Reflection::getClassNamespace(self::class));
self::assertEquals('Meritoo\Test\Common\Utilities', Reflection::getClassNamespace(self::class));
self::assertEquals(DateTime::class, Reflection::getClassNamespace(new DateTime()));
self::assertEquals(DateTime::class, Reflection::getClassNamespace([

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities\Repository;
namespace Meritoo\Test\Common\Utilities\Repository;
/**
* Sortable object/entity.

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities;
namespace Meritoo\Test\Common\Utilities;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
@@ -14,8 +14,8 @@ use Doctrine\ORM\Query\Expr\OrderBy;
use Doctrine\ORM\QueryBuilder;
use Generator;
use Meritoo\Common\Test\Base\BaseTestCase;
use Meritoo\Common\Test\Utilities\Repository\Sortable;
use Meritoo\Common\Utilities\Repository;
use Meritoo\Test\Common\Utilities\Repository\Sortable;
use stdClass;
/**
@@ -220,7 +220,8 @@ class RepositoryTest extends BaseTestCase
->setMethods([
'createQueryBuilder',
])
->getMock();
->getMock()
;
$expectedQueryBuilder = new QueryBuilder($entityManager);
$expectedQueryBuilder->from('any_table_name', 'qb');
@@ -228,7 +229,8 @@ class RepositoryTest extends BaseTestCase
$entityRepository
->expects(static::once())
->method('createQueryBuilder')
->willReturn($expectedQueryBuilder);
->willReturn($expectedQueryBuilder)
;
$queryBuilder = Repository::getEntityOrderedQueryBuilder($entityRepository);
$selectDQLPart = $queryBuilder->getDQLPart('select');
@@ -262,7 +264,8 @@ class RepositoryTest extends BaseTestCase
->setMethods([
'createQueryBuilder',
])
->getMock();
->getMock()
;
$expectedQueryBuilder = new QueryBuilder($entityManager);
$expectedQueryBuilder->from('any_table_name', 'qb');
@@ -270,7 +273,8 @@ class RepositoryTest extends BaseTestCase
$entityRepository
->expects(static::once())
->method('createQueryBuilder')
->willReturn($expectedQueryBuilder);
->willReturn($expectedQueryBuilder)
;
$queryBuilder = Repository::getEntityOrderedQueryBuilder($entityRepository, $property, $direction);
$selectDQLPart = $queryBuilder->getDQLPart('select');

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities;
namespace Meritoo\Test\Common\Utilities;
use Generator;
use Meritoo\Common\Test\Base\BaseTestCase;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Utilities;
namespace Meritoo\Test\Common\Utilities;
use Meritoo\Common\Test\Base\BaseTestCase;
use Meritoo\Common\Utilities\Xml;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\ValueObject;
namespace Meritoo\Test\Common\ValueObject;
use Meritoo\Common\Test\Base\BaseTestCase;
use Meritoo\Common\Type\OopVisibilityType;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\ValueObject;
namespace Meritoo\Test\Common\ValueObject;
use Meritoo\Common\Test\Base\BaseTestCase;
use Meritoo\Common\Type\OopVisibilityType;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\ValueObject;
namespace Meritoo\Test\Common\ValueObject;
use Meritoo\Common\Test\Base\BaseTestCase;
use Meritoo\Common\Type\OopVisibilityType;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\ValueObject;
namespace Meritoo\Test\Common\ValueObject;
use Meritoo\Common\Test\Base\BaseTestCase;
use Meritoo\Common\Type\OopVisibilityType;

View File

@@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\ValueObject;
namespace Meritoo\Test\Common\ValueObject;
use Generator;
use Meritoo\Common\Test\Base\BaseTestCase;