Skip to content
This repository was archived by the owner on Oct 7, 2022. It is now read-only.

Commit d166704

Browse files
committed
Tests: Add test w/Nette Tester
1 parent 6eca23f commit d166704

File tree

5 files changed

+79
-3
lines changed

5 files changed

+79
-3
lines changed

.gitattributes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.gitattributes export-ignore
22
.gitignore export-ignore
33
phpstan.neon export-ignore
4-
.travis.yml export-ignore
4+
.travis.yml export-ignore
5+
tests export-ignore

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/composer.lock
2-
/vendor
2+
/vendor/
3+
/tests/output/

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ When `/vendor` is not consistent with `composer.json`, checker throws an Excepti
3131

3232
![Exception from Checker](https://cdn.jakub-boucek.cz/screenshot/190703-jptvw.png)
3333

34+
## Modes
35+
36+
### Strict/Lax mode
37+
Nehlásí chybu, pokud nenajde soubory
38+
39+
POPZOR? výchozéí stan není striktní - vysvětlit v readme
40+
41+
### Silent mode
42+
Vyhodí pouze chybu E_USER_ERROR, ne vyjímku
43+
44+
```php
45+
Composer::validateConsistency($rootDir, $vendorDir, true, false);
46+
(new Composer($rootDir))->strict(false)->validate($debugMode, E_USER_ERROR);
47+
```
48+
3449
### Warning
3550
Because you install Checker as dev-dependency, you should be very careful to hard-linking dependency
3651
insinde your App. Is highly recommended to call validation only on development stage, not on production:

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
}
2020
},
2121
"require-dev": {
22-
"phpstan/phpstan": "^0.12.10"
22+
"phpstan/phpstan": "^0.12.10",
23+
"nette/tester": "^2.3"
2324
},
2425
"replace": {
2526
"jakubboucek/composer-vendor-checker": "self.version"

tests/Checker.compare.phpt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
use JakubBoucek\ComposerConsistency\Checker;
4+
use Tester\Assert;
5+
6+
require __DIR__ . '/../vendor/autoload.php';
7+
8+
Tester\Environment::setup();
9+
10+
// protected methos -> public method
11+
$method = (new ReflectionClass(Checker::class))->getMethod('compareReqs');
12+
$method->setAccessible(true);
13+
14+
$o = new Checker(__DIR__ . '/..');
15+
16+
Assert::same(
17+
[],
18+
$method->invokeArgs(
19+
$o,
20+
[
21+
['nette/tester' => '1.23'],
22+
['nette/tester' => '1.23']
23+
]
24+
)
25+
);
26+
27+
Assert::same(
28+
['nette/tester' => ['required' => '1.23', 'installed' => '4.56']],
29+
$method->invokeArgs(
30+
$o,
31+
[
32+
['nette/tester' => '1.23'],
33+
['nette/tester' => '4.56']
34+
]
35+
)
36+
);
37+
38+
Assert::same(
39+
['nette/tester' => ['required' => null, 'installed' => '4.56']],
40+
$method->invokeArgs(
41+
$o,
42+
[
43+
[],
44+
['nette/tester' => '4.56']
45+
]
46+
)
47+
);
48+
49+
Assert::same(
50+
['nette/tester' => ['required' => '1.23', 'installed' => null]],
51+
$method->invokeArgs(
52+
$o,
53+
[
54+
['nette/tester' => '1.23'],
55+
[]
56+
]
57+
)
58+
);

0 commit comments

Comments
 (0)