Skip to content

Commit

Permalink
[BUGFIX] Fix unit test framework
Browse files Browse the repository at this point in the history
  • Loading branch information
einpraegsam committed Jul 11, 2021
1 parent 93c43b0 commit 2caf913
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -19,3 +19,4 @@ node_modules/
composer.lock
package-lock.json
.php_cs.cache
var/
10 changes: 10 additions & 0 deletions Classes/Exception/FileNotFoundException.php
@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace In2code\Lux\Exception;

/**
* Class FileNotFoundException
*/
class FileNotFoundException extends \Exception
{
}
28 changes: 28 additions & 0 deletions Tests/Unit/bootstrap.php
@@ -0,0 +1,28 @@
<?php
if (empty($webRoot = getenv('TYPO3_PATH_WEB'))) {
putenv('TYPO3_PATH_WEB=' . $webRoot = realpath(__DIR__ . '/../../.Build/Web') . '/');
} else {
$webRoot = rtrim($webRoot, '/') . '/';
}
$buildRoot = realpath($webRoot . '/..');
$autoload = $buildRoot . '/vendor/autoload.php';
if (!file_exists($autoload)) {
throw new \In2code\Lux\Exception\FileNotFoundException('Can not find autoload path', 1626011935);
}

$bootstrapLoaded = false;
$bootstrap = $webRoot . '/typo3/sysext/core/Build/UnitTestsBootstrap.php';
$bootstrapNimut = $buildRoot . '/vendor/nimut/testing-framework/res/Configuration/UnitTestsBootstrap.php';
if (file_exists($bootstrap)) {
require($bootstrap);
$bootstrapLoaded = true;
} elseif (file_exists($bootstrapNimut)) {
require($bootstrapNimut);
$bootstrapLoaded = true;
}
if ($bootstrapLoaded === false) {
throw new \In2code\Lux\Exception\FileNotFoundException(
'Can not find unit test bootstrap file. Did you do a composer update?',
1626011924
);
}
12 changes: 12 additions & 0 deletions Tests/Unit/readme.md
@@ -0,0 +1,12 @@
# Unit tests in lux

Before you start with testing, just do a `composer install` in the lux main folder to install all needed resources and
testing frameworks.

## Start in PhpStorm

Just right click on file `phpunit.xml.dist` and select `run`

## Start from CLI

`.Build/vendor/phpunit/phpunit/phpunit`
6 changes: 3 additions & 3 deletions composer.json
Expand Up @@ -37,11 +37,11 @@
},
"require-dev": {
"typo3/cms-core": ">=9.5.0 <11.0.0",
"nimut/testing-framework": "^4.0",
"nimut/testing-framework": "^5.0",
"mikey179/vfsstream": "^1.6",
"phpunit/phpunit": "^6.0",
"squizlabs/php_codesniffer": "^3.3",
"phpmd/phpmd": "@stable"
"squizlabs/php_codesniffer": "^3.5",
"phpmd/phpmd": "^2.8"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Expand Up @@ -5,7 +5,7 @@
backupStaticAttributes="false"
cacheTokens="false"
colors="true"
bootstrap=".Build/vendor/nimut/testing-framework/res/Configuration/UnitTestsBootstrap.php"
bootstrap="Tests/Unit/bootstrap.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
Expand Down

0 comments on commit 2caf913

Please sign in to comment.