Start names of special directories with dot

BaseTestCase - add setter for path of directory with data used by test cases
This commit is contained in:
Meritoo
2017-10-17 20:49:13 +02:00
parent 70c273750d
commit 71e1eeb81b
11 changed files with 38 additions and 21 deletions

View File

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

6
.gitignore vendored
View File

@@ -14,7 +14,7 @@
# ----------------------------------------------------------------------------------------------------------------------
### Phing
# ----------------------------------------------------------------------------------------------------------------------
/phing/properties
/.phing/properties
# ----------------------------------------------------------------------------------------------------------------------
@@ -32,13 +32,13 @@
# ----------------------------------------------------------------------------------------------------------------------
### Build files
# ----------------------------------------------------------------------------------------------------------------------
/build/
/.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

@@ -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

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

@@ -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

@@ -2,7 +2,7 @@
"name": "meritoo/common-library",
"description": "Useful classes, methods, extensions etc.",
"license": "MIT",
"version": "0.0.14",
"version": "0.0.15",
"authors": [
{
"name": "Meritoo.pl",

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

@@ -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;
}
}