25 Commits

Author SHA1 Message Date
Michał Frankiewicz
00aada4c06 test composer req 2017-11-08 13:56:36 +01:00
Krzysztof Niziol
1641c50d1d composer.json - update name of this package 2017-11-07 16:34:49 +01:00
Krzysztof Niziol
afbbdfe437 composer.json - update name of this package 2017-11-07 15:24:51 +01:00
Meritoo
6d4e422165 BaseTestCase & BaseTypeTestCase - add traits to use in other test cases (e.g. in Symfony's kernel-related test case) 2017-11-02 22:00:38 +01:00
Meritoo
6f441bb9ea Tests - BaseTestCaseTest - fix bug while there is a difference (split second) 2017-11-02 13:58:24 +01:00
Meritoo
73030d703b composer.json - bump version 2017-11-02 12:25:39 +01:00
Meritoo
36ddb326b9 Tests - increase code coverage 2017-10-31 21:27:42 +01:00
Meritoo
452a4ec458 Tests - BaseTestCase - rename method getFilePathToTests() -> getFilePathForTesting() 2017-10-31 21:26:39 +01:00
Meritoo
325fe6b141 Support PHP 5.5.9+ 2017-10-31 20:28:55 +01:00
Meritoo
a1c26b3812 Phing - tests - phpcodesniffer task - fix "This task requires the PHP_CodeSniffer package installed and available on the include path" bug
Details: https://github.com/phingofficial/phing/issues/716
2017-10-26 20:04:05 +02:00
Meritoo
67d93036cf Phing - update properties.dist file 2017-10-22 21:40:23 +02:00
Meritoo
9368616dfe composer.json - update versions of the "dev" packages 2017-10-22 20:09:02 +02:00
Meritoo
5ab68d3667 Tests - Docker - update Xdebug configuration
Required to fix problem "Connection with XDebug 2.5.1 was not established. Validate installation."
2017-10-22 17:55:49 +02:00
Meritoo
4613a63f02 Tests - Docker - install vim, add custom php.ini, add "vendor/bin" to the $PATH global variable 2017-10-20 00:03:38 +02:00
Meritoo
9dac5bd11c Tests - Docker - update name of image and container 2017-10-18 21:50:02 +02:00
Meritoo
12100db058 Tests - Docker - update port 2017-10-18 20:02:09 +02:00
Meritoo
f9ab0a6194 Tests - Docker - add required libraries, PHP extensions & optimize size of Docker's image 2017-10-18 17:01:13 +02:00
Meritoo
b824808cd4 Tests - use Docker (as environment guard) 2017-10-18 00:31:18 +02:00
Meritoo
71e1eeb81b Start names of special directories with dot
BaseTestCase - add setter for path of directory with data used by test cases
2017-10-17 20:49:13 +02:00
Meritoo
70c273750d .gitignore update 2017-10-10 20:09:40 +02:00
Meritoo
e5e39651f3 Tests - fix names of constructors' tests 2017-10-02 15:56:53 +02:00
Meritoo
4683970c87 composer.json - update versions of the "dev" packages & sort them 2017-10-02 14:06:57 +02:00
Meritoo
559466c0ce composer.json - move tests-related classes to "autoload-dev" section (used for development purposes only and avoid polluting the autoloader in production) 2017-09-29 09:19:03 +02:00
Meritoo
bfd69c1098 Minor fix of coding standard 2017-09-27 21:52:10 +02:00
Meritoo
45493b37b0 Remove composer.lock 2017-09-27 21:51:48 +02:00
90 changed files with 441 additions and 3567 deletions

View File

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

64
.docker/config/Dockerfile Normal file
View File

@@ -0,0 +1,64 @@
FROM php:5.5-cli
#
# Tools & libraries
#
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
vim \
git \
zip \
unzip \
zlib1g-dev \
libicu-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
#
# PHP extensions
#
RUN docker-php-ext-install \
zip \
intl \
mbstring
#
# PHP configuration:
# - default configuration
# - timezone
#
COPY php.ini /usr/local/etc/php/php.ini
ARG TIMEZONE
RUN echo "\n""date.timezone = $TIMEZONE""\n" >> /usr/local/etc/php/php.ini
#
# Xdebug
#
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug
COPY xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
#
# Phing
#
RUN pear channel-discover pear.phing.info \
&& pear install [--alldeps] phing/phing
#
# Composer + https://packagist.org/packages/hirak/prestissimo package
#
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php -r "if (hash_file('SHA384', 'composer-setup.php') === \
'544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo \
'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
&& php composer-setup.php --install-dir=/usr/local/bin --filename=composer \
&& php -r "unlink('composer-setup.php');" \
&& composer global require --no-plugins --no-scripts hirak/prestissimo \
&& rm -rf /root/.composer/cache/*
#
# Bash
#
RUN sed -i 's/^# export/export/g' /root/.bashrc \
&& sed -i 's/^# alias/alias/g' /root/.bashrc \
&& echo "\n"'export PATH=/project/vendor/bin:$PATH'"\n" >> /root/.bashrc

3
.docker/config/php.ini Normal file
View File

@@ -0,0 +1,3 @@
display_errors = On
display_startup_errors = On
error_reporting = E_ALL

View File

@@ -0,0 +1,6 @@
[xdebug]
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_port=9001
xdebug.remote_host=10.254.254.254

1
.env Normal file
View File

@@ -0,0 +1 @@
TIMEZONE=Europe/Warsaw

11
.gitignore vendored
View File

@@ -7,13 +7,14 @@
# ----------------------------------------------------------------------------------------------------------------------
### Composer
# ----------------------------------------------------------------------------------------------------------------------
/composer.lock
/composer.phar
# ----------------------------------------------------------------------------------------------------------------------
### Phing
# ----------------------------------------------------------------------------------------------------------------------
/phing/properties
/.phing/properties
# ----------------------------------------------------------------------------------------------------------------------
@@ -28,10 +29,16 @@
/.php_cs.cache
# ----------------------------------------------------------------------------------------------------------------------
### Build files
# ----------------------------------------------------------------------------------------------------------------------
/.build/
# ----------------------------------------------------------------------------------------------------------------------
### Generated databases
# ----------------------------------------------------------------------------------------------------------------------
/data/tmp
/.data/tmp
*.sql
*.sqlite

View File

@@ -2,12 +2,12 @@
<project name="Meritoo Package" basedir="." default="build:main" phingVersion="2.14.0">
<!-- Properties -->
<if>
<available file="phing/properties" property="custom.properties.available"/>
<available file=".phing/properties" property="custom.properties.available"/>
<then>
<property file="phing/properties" />
<property file=".phing/properties" />
</then>
<else>
<property file="phing/properties.dist" />
<property file=".phing/properties.dist" />
</else>
</if>

View File

@@ -28,7 +28,13 @@ assets.installWithSymlink = true
# Clear cache with the "warmup" option
#
cache.clearWithWarmup = true
# The cache:clear command should always be called with the --no-warmup option. Warmup should be done via the cache:warmup command.
# https://github.com/symfony/symfony/blob/master/UPGRADE-3.3.md#frameworkbundle
#
# Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
# 2017-06-06
#
cache.clearWithWarmup = false
# --------------------------------------------------------------------------------
# Composer
@@ -59,7 +65,7 @@ composer.validate = false
# System directories
#
dir.data = ${project.basedir}/data
dir.data = ${project.basedir}/.data
dir.src = ${project.basedir}/src
dir.tests = ${project.basedir}/tests
@@ -67,7 +73,7 @@ dir.tests = ${project.basedir}/tests
# Build directories
# --------------------------------------------------------------------------------
dir.build = ${project.basedir}/build
dir.build = ${project.basedir}/.build
dir.reports = ${dir.build}/logs
dir.reports.pdepend = ${dir.reports}/pdepend
dir.reports.coverage = ${dir.reports}/phpunit_coverage

View File

@@ -11,12 +11,12 @@
<!-- Properties -->
<if>
<available file="phing/properties" property="custom.properties.available"/>
<available file=".phing/properties" property="custom.properties.available"/>
<then>
<property file="phing/properties" />
<property file=".phing/properties" />
</then>
<else>
<property file="phing/properties.dist" />
<property file=".phing/properties.dist" />
</else>
</if>

View File

@@ -8,11 +8,20 @@ Common and useful classes, methods, exceptions etc.
Run [Composer](https://getcomposer.org) to install this package in your project:
```bash
$ composer require meritoo/common-library
$ composer require wiosna/common-library
```
> How to install Composer: https://getcomposer.org/download
## Rebuilding project and tests running
```bash
$ docker-compose up -d
$ docker-compose exec php-cli phing
```
> What is Docker? https://www.docker.com/what-docker
## Static methods
This package contains a lot of class with static methods, so usage is not so complicated. Just run the static method who would you like to use. Example:

View File

@@ -2,12 +2,12 @@
<project name="Meritoo Package" basedir="." default="build:main" phingVersion="2.14.0">
<!-- Properties -->
<if>
<available file="phing/properties" property="custom.properties.available"/>
<available file=".phing/properties" property="custom.properties.available"/>
<then>
<property file="phing/properties" />
<property file=".phing/properties" />
</then>
<else>
<property file="phing/properties.dist" />
<property file=".phing/properties.dist" />
</else>
</if>
@@ -18,12 +18,12 @@
<!-- Build app -->
<target name="build:app" description="Prepares app to build and tests">
<phing phingfile="phing/app.xml" haltonfailure="true" />
<phing phingfile=".phing/app.xml" haltonfailure="true" />
</target>
<!-- Build tests -->
<target name="build:tests" description="Runs all tests, checks and creates docs">
<phing phingfile="phing/tests.xml" haltonfailure="true" />
<phing phingfile=".phing/tests.xml" haltonfailure="true" />
<!--
Conditional running of tests.
@@ -35,7 +35,7 @@
<if>
<equals arg1="${env}" arg2="test" />
<then>
<phing phingfile="phing/tests.xml" haltonfailure="true" />
<phing phingfile=".phing/tests.xml" haltonfailure="true" />
</then>
<else>
<echo message="[Skipped] Running tests, checks and creating docs, because it's a not 'test' environment..." />

View File

@@ -1,8 +1,8 @@
{
"name": "meritoo/common-library",
"name": "wiosna-dev/common-library",
"description": "Useful classes, methods, extensions etc.",
"license": "MIT",
"version": "0.0.13",
"version": "0.0.17",
"authors": [
{
"name": "Meritoo.pl",
@@ -11,24 +11,31 @@
}
],
"require": {
"php": ">=5.6.0",
"php": ">=5.5.9",
"doctrine/orm": "^2.5",
"gedmo/doctrine-extensions": "^2.4",
"symfony/http-foundation": "^3.3"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"squizlabs/php_codesniffer": "^2.9",
"phpmd/phpmd": "^2.6",
"sebastian/phpcpd": "^3.0",
"friendsofphp/php-cs-fixer": "^2.2",
"pdepend/pdepend": "^2.5",
"phploc/phploc": "^4.0",
"friendsofphp/php-cs-fixer": "^2.6"
"phploc/phploc": "^2.1",
"phpmd/phpmd": "^2.6",
"phpunit/phpunit": "^4.8",
"sebastian/phpcpd": "^2.0",
"squizlabs/php_codesniffer": "^2.9"
},
"autoload": {
"psr-4": {
"Meritoo\\Common\\": "src/Meritoo/Common/",
"Meritoo\\Common\\Test\\": "tests/Meritoo/Common/Test/"
"Meritoo\\Common\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Meritoo\\Common\\Test\\": "tests/"
}
},
"config": {
"sort-packages": true
}
}

3494
composer.lock generated

File diff suppressed because it is too large Load Diff

15
docker-compose.yml Normal file
View File

@@ -0,0 +1,15 @@
version: '3'
services:
php-cli:
image: meritoo/common-library
container_name: meritoo-common-library
working_dir: /project
entrypoint: php
command: -S 0.0.0.0:9999
build:
context: ./.docker/config
args:
- TIMEZONE=$TIMEZONE
volumes:
- .:/project

View File

@@ -30,6 +30,6 @@
</groups>
<logging>
<log type="coverage-html" target="./build/logs/phpunit_coverage/html" />
<log type="coverage-html" target="./.build/logs/phpunit_coverage/html" />
</logging>
</phpunit>

View File

@@ -0,0 +1,23 @@
<?php
/**
* (c) Meritoo.pl, http://www.meritoo.pl
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Base;
use Meritoo\Common\Traits\Test\Base\BaseTestCaseTrait;
use PHPUnit\Framework\TestCase;
/**
* Base test case with common methods and data providers
*
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
* @copyright Meritoo.pl
*/
abstract class BaseTestCase extends TestCase
{
use BaseTestCaseTrait;
}

View File

@@ -0,0 +1,22 @@
<?php
/**
* (c) Meritoo.pl, http://www.meritoo.pl
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Base;
use Meritoo\Common\Traits\Test\Base\BaseTypeTestCaseTrait;
/**
* Base test case for the type of something
*
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
* @copyright Meritoo.pl
*/
abstract class BaseTypeTestCase extends BaseTestCase
{
use BaseTypeTestCaseTrait;
}

View File

@@ -6,25 +6,32 @@
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Base;
namespace Meritoo\Common\Traits\Test\Base;
use DateTime;
use Generator;
use Meritoo\Common\Exception\Type\UnknownOopVisibilityTypeException;
use Meritoo\Common\Type\OopVisibilityType;
use Meritoo\Common\Utilities\Miscellaneous;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use ReflectionMethod;
/**
* Base test case with common methods and data providers
* BaseTestCaseTrait
* Created on 2017-11-02
*
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
* @copyright Meritoo.pl
*/
abstract class BaseTestCase extends TestCase
trait BaseTestCaseTrait
{
/**
* Path of directory with data used by test cases
*
* @var string
*/
private static $testsDataDirPath = '.data/tests';
/**
* Provides an empty value
*
@@ -98,19 +105,19 @@ abstract class BaseTestCase extends TestCase
/**
* Returns path of file used by tests.
* It should be placed in /data/tests directory of this project.
* It should be placed in /.data/tests directory of this project.
*
* @param string $fileName Name of file
* @param string $directoryPath (optional) Path of directory containing the file
* @return string
*/
public function getFilePathToTests($fileName, $directoryPath = '')
public function getFilePathForTesting($fileName, $directoryPath = '')
{
$rootPath = Miscellaneous::getProjectRootPath();
$paths = [
$rootPath,
'data/tests',
self::$testsDataDirPath,
$directoryPath,
$fileName,
];
@@ -200,7 +207,7 @@ abstract class BaseTestCase extends TestCase
$reflection = new ReflectionClass($classNamespace);
$method = $reflection->getConstructor();
return static::assertMethodVisibilityAndArguments($classNamespace, $method, $visibilityType, $argumentsCount, $requiredArgumentsCount);
static::assertMethodVisibilityAndArguments($classNamespace, $method, $visibilityType, $argumentsCount, $requiredArgumentsCount);
}
/**
@@ -218,4 +225,14 @@ abstract class BaseTestCase extends TestCase
static::assertNull($constructor);
}
/**
* Sets path of directory with data used by test cases
*
* @param string $testsDataDirPath Path of directory with data used by test cases
*/
protected static function setTestsDataDirPath($testsDataDirPath)
{
static::$testsDataDirPath = $testsDataDirPath;
}
}

View File

@@ -1,17 +1,23 @@
<?php
namespace Meritoo\Common\Test\Base;
/**
* (c) Meritoo.pl, http://www.meritoo.pl
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Traits\Test\Base;
use Generator;
use Meritoo\Common\Type\Base\BaseType;
/**
* Base test case for the type of something
* Trait for the base test case for the type of something
*
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
* @copyright Meritoo.pl
*/
abstract class BaseTypeTestCase extends BaseTestCase
trait BaseTypeTestCaseTrait
{
/**
* Verifies availability of all types

View File

@@ -33,7 +33,7 @@ class UnknownTypeExceptionTest extends BaseTestCase
public function testTheException()
{
$this->expectException(UnknownTestTypeException::class);
$this->setExpectedException(UnknownTestTypeException::class);
self::assertEmpty((new TestService())->getTranslatedType('test_3'));
}
}

View File

@@ -0,0 +1,176 @@
<?php
/**
* (c) Meritoo.pl, http://www.meritoo.pl
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Test\Test\Base;
use DateTime;
use Generator;
use Meritoo\Common\Test\Base\BaseTestCase;
use Meritoo\Common\Type\OopVisibilityType;
use Meritoo\Common\Utilities\GeneratorUtility;
/**
* Test case of the base test case with common methods and data providers
*
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
* @copyright Meritoo.pl
*/
class BaseTestCaseTest extends BaseTestCase
{
public function testConstructor()
{
static::assertConstructorVisibilityAndArguments(BaseTestCase::class, OopVisibilityType::IS_PUBLIC, 3);
}
public function testProvideEmptyValue()
{
$elements = [
[''],
[' '],
[null],
[0],
[false],
[[]],
];
$generator = (new SimpleTestCase())->provideEmptyValue();
self::assertEquals($elements, GeneratorUtility::getGeneratorElements($generator));
}
public function testProvideBooleanValue()
{
$elements = [
[false],
[true],
];
$generator = (new SimpleTestCase())->provideBooleanValue();
self::assertEquals($elements, GeneratorUtility::getGeneratorElements($generator));
}
public function testProvideDateTimeInstance()
{
$dateFormat = 'Y-m-d H:i';
$expectedElements = [
[new DateTime()],
[new DateTime('yesterday')],
[new DateTime('now')],
[new DateTime('tomorrow')],
];
$generator = (new SimpleTestCase())->provideDateTimeInstance();
$generatedElements = GeneratorUtility::getGeneratorElements($generator);
/* @var DateTime $instance1 */
$instance1 = $generatedElements[0][0];
/* @var DateTime $instance2 */
$instance2 = $generatedElements[1][0];
/* @var DateTime $instance3 */
$instance3 = $generatedElements[2][0];
/* @var DateTime $instance4 */
$instance4 = $generatedElements[3][0];
self::assertCount(count($expectedElements), $generatedElements);
self::assertEquals($instance1->format($dateFormat), (new DateTime())->format($dateFormat));
self::assertEquals($instance2->format($dateFormat), (new DateTime('yesterday'))->format($dateFormat));
self::assertEquals($instance3->format($dateFormat), (new DateTime('now'))->format($dateFormat));
self::assertEquals($instance4->format($dateFormat), (new DateTime('tomorrow'))->format($dateFormat));
}
public function testProvideDateTimeRelativeFormat()
{
$elements = [
['now'],
['yesterday'],
['tomorrow'],
['back of 10'],
['front of 10'],
['last day of February'],
['first day of next month'],
['last day of previous month'],
['last day of next month'],
['Y-m-d'],
['Y-m-d 10:00'],
];
$generator = (new SimpleTestCase())->provideDateTimeRelativeFormat();
self::assertEquals($elements, GeneratorUtility::getGeneratorElements($generator));
}
public function testProvideNotExistingFilePath()
{
$elements = [
['lets-test.doc'],
['lorem/ipsum.jpg'],
['surprise/me/one/more/time.txt'],
];
$generator = (new SimpleTestCase())->provideNotExistingFilePath();
self::assertEquals($elements, GeneratorUtility::getGeneratorElements($generator));
}
/**
* @param string $fileName Name of file
* @param string $directoryPath Path of directory containing the file
*
* @dataProvider provideFileNameAndDirectoryPath
*/
public function testGetFilePathForTesting($fileName, $directoryPath)
{
$path = (new SimpleTestCase())->getFilePathForTesting($fileName, $directoryPath);
if (!empty($directoryPath)) {
$directoryPath .= '/';
}
$expectedContains = sprintf('/.data/tests/%s%s', $directoryPath, $fileName);
static::assertContains($expectedContains, $path);
}
/**
* Provides name of file and path of directory containing the file
*
* @return Generator
*/
public function provideFileNameAndDirectoryPath()
{
yield[
'abc.jpg',
'',
];
yield[
'abc.def.jpg',
'',
];
yield[
'abc.jpg',
'def',
];
yield[
'abc.def.jpg',
'def',
];
}
}
/**
* Simple test case
*
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
* @copyright Meritoo.pl
*/
class SimpleTestCase extends BaseTestCase
{
}

View File

@@ -9,8 +9,8 @@
namespace Meritoo\Common\Test\Type\Base;
use Generator;
use Meritoo\Common\Test\Base\BaseTestCase;
use Meritoo\Common\Type\Base\BaseType;
use PHPUnit\Framework\TestCase;
/**
* Test case of the base / abstract type of something
@@ -18,8 +18,13 @@ use PHPUnit\Framework\TestCase;
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
* @copyright Meritoo.pl
*/
class BaseTypeTest extends TestCase
class BaseTypeTest extends BaseTestCase
{
public function testConstructor()
{
static::assertHasNoConstructor(BaseType::class);
}
/**
* @param BaseType $type Type of something
* @param array $expectedTypes Expected concrete types of given instance of type

View File

@@ -25,7 +25,7 @@ class ArraysTest extends BaseTestCase
private $complexArray;
private $superComplexArray;
public function verifyConstructor()
public function testConstructor()
{
static::assertHasNoConstructor(Arrays::class);
}

View File

@@ -19,7 +19,7 @@ use Meritoo\Common\Utilities\Bundle;
*/
class BundleTest extends BaseTestCase
{
public function verifyConstructor()
public function testConstructor()
{
static::assertHasNoConstructor(Bundle::class);
}

View File

@@ -27,7 +27,7 @@ class ComposerTest extends BaseTestCase
*/
private $composerJsonPath;
public function verifyConstructor()
public function testConstructor()
{
static::assertHasNoConstructor(Composer::class);
}
@@ -88,6 +88,6 @@ class ComposerTest extends BaseTestCase
{
parent::setUp();
$this->composerJsonPath = $this->getFilePathToTests(Composer::FILE_NAME_MAIN);
$this->composerJsonPath = $this->getFilePathForTesting(Composer::FILE_NAME_MAIN);
}
}

View File

@@ -23,7 +23,7 @@ use Meritoo\Common\Utilities\Date;
*/
class DateTest extends BaseTestCase
{
public function verifyConstructor()
public function testConstructor()
{
static::assertHasNoConstructor(Date::class);
}
@@ -223,7 +223,7 @@ class DateTest extends BaseTestCase
*/
public function testGetDayOfWeekIncorrectValues($year, $month, $day)
{
$this->expectException(UnknownDatePartTypeException::class);
$this->setExpectedException(UnknownDatePartTypeException::class);
self::assertEmpty(Date::getDayOfWeek($year, $month, $day));
}

View File

@@ -19,7 +19,7 @@ use Meritoo\Common\Utilities\GeneratorUtility;
*/
class GeneratorUtilityTest extends BaseTestCase
{
public function verifyConstructor()
public function testConstructor()
{
static::assertHasNoConstructor(GeneratorUtility::class);
}

View File

@@ -20,7 +20,7 @@ use Meritoo\Common\Utilities\Locale;
*/
class LocaleTest extends BaseTestCase
{
public function verifyConstructor()
public function testConstructor()
{
static::assertHasNoConstructor(Locale::class);
}

View File

@@ -20,7 +20,7 @@ use Meritoo\Common\Utilities\MimeTypes;
*/
class MimeTypesTest extends BaseTestCase
{
public function verifyConstructor()
public function testConstructor()
{
static::assertHasNoConstructor(MimeTypes::class);
}
@@ -447,12 +447,12 @@ class MimeTypesTest extends BaseTestCase
public function provideFilePathToGetMimeTypeOfRealFile()
{
yield[
$this->getFilePathToTests('minion.jpg'),
$this->getFilePathForTesting('minion.jpg'),
'image/jpeg',
];
yield[
$this->getFilePathToTests('lorem-ipsum.txt'),
$this->getFilePathForTesting('lorem-ipsum.txt'),
'text/plain',
];
}
@@ -465,12 +465,12 @@ class MimeTypesTest extends BaseTestCase
public function provideExistingFilePathToCheckIsImagePath()
{
yield[
$this->getFilePathToTests('minion.jpg'),
$this->getFilePathForTesting('minion.jpg'),
true,
];
yield[
$this->getFilePathToTests('lorem-ipsum.txt'),
$this->getFilePathForTesting('lorem-ipsum.txt'),
false,
];
}

View File

@@ -28,7 +28,7 @@ class MiscellaneousTest extends BaseTestCase
private $stringCommaSeparated;
private $stringDotSeparated;
public function verifyConstructor()
public function testConstructor()
{
static::assertHasNoConstructor(Miscellaneous::class);
}
@@ -159,8 +159,8 @@ class MiscellaneousTest extends BaseTestCase
$expected = "int(123)\n";
if ($xdebugLoaded) {
$libraryPath = realpath(sprintf('%s%s', dirname(__FILE__), '/../../../../..'));
$filePath = sprintf('%s%s', $libraryPath, '/src/Meritoo/Common/Utilities/Miscellaneous.php:');
$libraryPath = realpath(sprintf('%s%s', dirname(__FILE__), '/../..'));
$filePath = sprintf('%s%s', $libraryPath, '/src/Utilities/Miscellaneous.php:');
/*
* Attention. I have to use "\d+" at the end of $filePath, because number of line may be different if new
@@ -663,7 +663,8 @@ class MiscellaneousTest extends BaseTestCase
public function testGetInvertedColorWithIncorrectLength()
{
$this->expectException(IncorrectColorHexLengthException::class);
$this->setExpectedException(IncorrectColorHexLengthException::class);
Miscellaneous::getInvertedColor(null);
Miscellaneous::getInvertedColor('');
Miscellaneous::getInvertedColor(1);
@@ -676,7 +677,8 @@ class MiscellaneousTest extends BaseTestCase
public function testGetInvertedColorWithInvalidValue()
{
$this->expectException(InvalidColorHexValueException::class);
$this->setExpectedException(InvalidColorHexValueException::class);
Miscellaneous::getInvertedColor('0011zz');
Miscellaneous::getInvertedColor('001#zz');
Miscellaneous::getInvertedColor('001!zz');

View File

@@ -33,7 +33,7 @@ use ReflectionProperty;
*/
class ReflectionTest extends BaseTestCase
{
public function verifyConstructor()
public function testConstructor()
{
static::assertHasNoConstructor(Reflection::class);
}
@@ -122,7 +122,7 @@ class ReflectionTest extends BaseTestCase
*/
public function testGetChildClassesInvalidClass($invalidClass)
{
$this->expectException(CannotResolveClassNameException::class);
$this->setExpectedException(CannotResolveClassNameException::class);
self::assertNull(Reflection::getChildClasses($invalidClass));
self::assertNull(Reflection::getChildClasses(123));
@@ -130,7 +130,7 @@ class ReflectionTest extends BaseTestCase
public function testGetChildClassesNotExistingClass()
{
$this->expectException(CannotResolveClassNameException::class);
$this->setExpectedException(CannotResolveClassNameException::class);
self::assertEquals('', Reflection::getChildClasses('xyz'));
}
@@ -161,13 +161,13 @@ class ReflectionTest extends BaseTestCase
public function testGetOneChildClassWithMissingChildClasses()
{
$this->expectException(MissingChildClassesException::class);
$this->setExpectedException(MissingChildClassesException::class);
self::assertEquals('LoremIpsum', Reflection::getOneChildClass(C::class));
}
public function testGetOneChildClassWithTooManyChildClasses()
{
$this->expectException(TooManyChildClassesException::class);
$this->setExpectedException(TooManyChildClassesException::class);
self::assertEquals(B::class, Reflection::getOneChildClass(A::class));
self::assertEquals(C::class, Reflection::getOneChildClass(A::class));
@@ -195,7 +195,7 @@ class ReflectionTest extends BaseTestCase
*/
public function testUsesTraitInvalidClass($class, $trait)
{
$this->expectException(CannotResolveClassNameException::class);
$this->setExpectedException(CannotResolveClassNameException::class);
self::assertNull(Reflection::usesTrait($class, $trait));
}
@@ -205,7 +205,7 @@ class ReflectionTest extends BaseTestCase
*/
public function testUsesTraitInvalidTrait($trait)
{
$this->expectException(CannotResolveClassNameException::class);
$this->setExpectedException(CannotResolveClassNameException::class);
self::assertNull(Reflection::usesTrait(DateTime::class, $trait));
}
@@ -270,7 +270,6 @@ class ReflectionTest extends BaseTestCase
self::assertEquals($city, Reflection::getPropertyValue($f, 'city'));
}
public function testGetPropertyValueWithPrivateGetter()
{
$accountBalance = 1000;

View File

@@ -21,7 +21,7 @@ class RegexTest extends BaseTestCase
private $simpleText;
private $camelCaseText;
public function verifyConstructor()
public function testConstructor()
{
static::assertHasNoConstructor(Regex::class);
}

View File

@@ -19,7 +19,7 @@ use Meritoo\Common\Utilities\Uri;
*/
class UriTest extends BaseTestCase
{
public function verifyConstructor()
public function testConstructor()
{
static::assertHasNoConstructor(Uri::class);
}

View File

@@ -23,7 +23,7 @@ class XmlTest extends BaseTestCase
private $simpleXml;
private $advancedXml;
public function verifyConstructor()
public function testConstructor()
{
static::assertHasNoConstructor(Xml::class);
}