mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9dac5bd11c | ||
|
|
12100db058 | ||
|
|
f9ab0a6194 | ||
|
|
b824808cd4 | ||
|
|
71e1eeb81b | ||
|
|
70c273750d | ||
|
|
e5e39651f3 | ||
|
|
4683970c87 | ||
|
|
559466c0ce | ||
|
|
bfd69c1098 | ||
|
|
45493b37b0 |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
54
.docker/config/Dockerfile
Normal file
54
.docker/config/Dockerfile
Normal file
@@ -0,0 +1,54 @@
|
||||
FROM php:5.6-cli
|
||||
|
||||
#
|
||||
# Tools & libraries
|
||||
#
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
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:
|
||||
# - timezone
|
||||
#
|
||||
ARG TIMEZONE
|
||||
RUN echo "date.timezone = $TIMEZONE" >> /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/*
|
||||
7
.docker/config/xdebug.ini
Normal file
7
.docker/config/xdebug.ini
Normal file
@@ -0,0 +1,7 @@
|
||||
[xdebug]
|
||||
zend_extension='xdebug.so'
|
||||
|
||||
xdebug.remote_enable=1
|
||||
xdebug.remote_connect_back=1
|
||||
xdebug.idekey='PHPSTORM'
|
||||
xdebug.remote_port=9001
|
||||
11
.gitignore
vendored
11
.gitignore
vendored
@@ -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
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -59,7 +59,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 +67,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
|
||||
@@ -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>
|
||||
|
||||
@@ -13,6 +13,15 @@ $ composer require meritoo/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:
|
||||
|
||||
12
build.xml
12
build.xml
@@ -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..." />
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "meritoo/common-library",
|
||||
"description": "Useful classes, methods, extensions etc.",
|
||||
"license": "MIT",
|
||||
"version": "0.0.13",
|
||||
"version": "0.0.15",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Meritoo.pl",
|
||||
@@ -17,18 +17,22 @@
|
||||
"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.6",
|
||||
"pdepend/pdepend": "^2.5",
|
||||
"phploc/phploc": "^4.0",
|
||||
"friendsofphp/php-cs-fixer": "^2.6"
|
||||
"phpmd/phpmd": "^2.6",
|
||||
"phpunit/phpunit": "^5.7",
|
||||
"sebastian/phpcpd": "^3.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/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
3494
composer.lock
generated
3494
composer.lock
generated
File diff suppressed because it is too large
Load Diff
15
docker-compose.yml
Normal file
15
docker-compose.yml
Normal 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
|
||||
@@ -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>
|
||||
|
||||
@@ -25,6 +25,13 @@ use ReflectionMethod;
|
||||
*/
|
||||
abstract class BaseTestCase extends TestCase
|
||||
{
|
||||
/**
|
||||
* Path of directory with data used by test cases
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $testsDataDirPath = '.data/tests';
|
||||
|
||||
/**
|
||||
* Provides an empty value
|
||||
*
|
||||
@@ -98,7 +105,7 @@ 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
|
||||
@@ -110,7 +117,7 @@ abstract class BaseTestCase extends TestCase
|
||||
|
||||
$paths = [
|
||||
$rootPath,
|
||||
'data/tests',
|
||||
self::$testsDataDirPath,
|
||||
$directoryPath,
|
||||
$fileName,
|
||||
];
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ class ArraysTest extends BaseTestCase
|
||||
private $complexArray;
|
||||
private $superComplexArray;
|
||||
|
||||
public function verifyConstructor()
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Arrays::class);
|
||||
}
|
||||
@@ -19,7 +19,7 @@ use Meritoo\Common\Utilities\Bundle;
|
||||
*/
|
||||
class BundleTest extends BaseTestCase
|
||||
{
|
||||
public function verifyConstructor()
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Bundle::class);
|
||||
}
|
||||
@@ -27,7 +27,7 @@ class ComposerTest extends BaseTestCase
|
||||
*/
|
||||
private $composerJsonPath;
|
||||
|
||||
public function verifyConstructor()
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Composer::class);
|
||||
}
|
||||
@@ -23,7 +23,7 @@ use Meritoo\Common\Utilities\Date;
|
||||
*/
|
||||
class DateTest extends BaseTestCase
|
||||
{
|
||||
public function verifyConstructor()
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Date::class);
|
||||
}
|
||||
@@ -19,7 +19,7 @@ use Meritoo\Common\Utilities\GeneratorUtility;
|
||||
*/
|
||||
class GeneratorUtilityTest extends BaseTestCase
|
||||
{
|
||||
public function verifyConstructor()
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(GeneratorUtility::class);
|
||||
}
|
||||
@@ -20,7 +20,7 @@ use Meritoo\Common\Utilities\Locale;
|
||||
*/
|
||||
class LocaleTest extends BaseTestCase
|
||||
{
|
||||
public function verifyConstructor()
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Locale::class);
|
||||
}
|
||||
@@ -20,7 +20,7 @@ use Meritoo\Common\Utilities\MimeTypes;
|
||||
*/
|
||||
class MimeTypesTest extends BaseTestCase
|
||||
{
|
||||
public function verifyConstructor()
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(MimeTypes::class);
|
||||
}
|
||||
@@ -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
|
||||
@@ -33,7 +33,7 @@ use ReflectionProperty;
|
||||
*/
|
||||
class ReflectionTest extends BaseTestCase
|
||||
{
|
||||
public function verifyConstructor()
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Reflection::class);
|
||||
}
|
||||
@@ -270,7 +270,6 @@ class ReflectionTest extends BaseTestCase
|
||||
self::assertEquals($city, Reflection::getPropertyValue($f, 'city'));
|
||||
}
|
||||
|
||||
|
||||
public function testGetPropertyValueWithPrivateGetter()
|
||||
{
|
||||
$accountBalance = 1000;
|
||||
@@ -21,7 +21,7 @@ class RegexTest extends BaseTestCase
|
||||
private $simpleText;
|
||||
private $camelCaseText;
|
||||
|
||||
public function verifyConstructor()
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Regex::class);
|
||||
}
|
||||
@@ -19,7 +19,7 @@ use Meritoo\Common\Utilities\Uri;
|
||||
*/
|
||||
class UriTest extends BaseTestCase
|
||||
{
|
||||
public function verifyConstructor()
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Uri::class);
|
||||
}
|
||||
@@ -23,7 +23,7 @@ class XmlTest extends BaseTestCase
|
||||
private $simpleXml;
|
||||
private $advancedXml;
|
||||
|
||||
public function verifyConstructor()
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Xml::class);
|
||||
}
|
||||
Reference in New Issue
Block a user