Skip to content

Commit 8ac4789

Browse files
committed
Remove test classes accidental autoloading from non-test code.
1 parent 6dc2959 commit 8ac4789

5 files changed

Lines changed: 14 additions & 8 deletions

File tree

composer.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
"MagicPush\\CliToolkit\\": "src/"
1515
}
1616
},
17-
"autoload-dev": {
18-
"psr-4": {
19-
"MagicPush\\CliToolkit\\Tests\\": "tests/"
20-
}
21-
},
2217
"authors": [
2318
{
2419
"name": "Kirill Ulanovskii",

docs/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ This change log references the repository changes and releases, which respect [s
99
1. PHPUnit version is upgraded from `^10` to `12.1.0`.
1010

1111
From now on PHPUnit engine itself is not present in the library and should be installed and launched separately.
12+
1. Test classes are auto-loaded only during actual test launches. E.g. if you accidentally use `tests/utils/CliProcess`
13+
in your production classes under 'dev' environment (when you call `composer install` without `--no-dev` option),
14+
you will get "Class 'XXX' not found in ..." error.
15+
Previously there was no error, until you install composer packages with `--no-dev` flag.
1216

1317
## v2.0.0
1418

docs/todo.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ The list of plans and ideas for future development.
2020
e.g. `git help status` is the same as `git status --help`.
2121
* The `help` subcommand should be added automatically for each config with a subcommand.
2222
* Possible values are all other available subcommand names for the same switch.
23-
1. PHPUnit: the next major version.
24-
1. Try messing with the coverage.
23+
1. PHPUnit: remove the PHAR from the project completely, try OS-based installation.
24+
1. PHPUnit: Try messing with the coverage - make tests call test scripts inside the same processes with test methods.
2525
1. Try out the parameters ambiguity puzzle: `-fctest`, where `-f` is a flag, `-c` is an option and there is
2626
also a `-t` flag. Possible outcomes:
2727
1. `test` is the `-c` value, `-t` flag is not enabled.

tests/Tests/init-console.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44

55
require_once __DIR__ . '/../../vendor/autoload.php';
66

7+
use Composer\Autoload\ClassLoader;
8+
9+
// Loading test classes manually to ensure that the test classes are not loaded accidentally inside '/src' code.
10+
$composerLoader = new ClassLoader(__DIR__ . '/../../vendor');
11+
$composerLoader->addPsr4('MagicPush\\CliToolkit\\Tests\\', [__DIR__ . '/../../tests']);
12+
$composerLoader->register();
13+
714
mb_internal_encoding('UTF-8');
815
setlocale(LC_ALL, 'en_US.UTF-8');
916
ini_set('max_execution_time', 2);

tests/utils/phpunit/phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<phpunit
3-
bootstrap="../../../vendor/autoload.php"
3+
bootstrap="../../Tests/init-console.php"
44
cacheResult="false"
55

66
columns="40"

0 commit comments

Comments
 (0)