1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use craft\events\ExceptionEvent; |
4
|
|
|
use craft\web\ErrorHandler; |
5
|
|
|
use markhuot\craftpest\test\TestCase; |
|
|
|
|
6
|
|
|
use yii\base\Event; |
|
|
|
|
7
|
|
|
|
8
|
|
|
/* |
9
|
|
|
|-------------------------------------------------------------------------- |
10
|
|
|
| Test Case |
11
|
|
|
|-------------------------------------------------------------------------- |
12
|
|
|
| |
13
|
|
|
| The closure you provide to your test functions is always bound to a specific PHPUnit test |
14
|
|
|
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may |
15
|
|
|
| need to change it using the "uses()" function to bind a different classes or traits. |
16
|
|
|
| |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
uses(TestCase::class) |
|
|
|
|
20
|
|
|
->beforeEach(function() { |
21
|
|
|
// Ensure exceptions are thrown, so we can catch them in our tests. |
22
|
|
|
Event::on(ErrorHandler::class, ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
23
|
|
|
function(ExceptionEvent $event) { |
24
|
|
|
throw $event->exception; |
25
|
|
|
} |
26
|
|
|
); |
27
|
|
|
}) |
28
|
|
|
->in('./'); |
29
|
|
|
|
30
|
|
|
/* |
31
|
|
|
|-------------------------------------------------------------------------- |
32
|
|
|
| Expectations |
33
|
|
|
|-------------------------------------------------------------------------- |
34
|
|
|
| |
35
|
|
|
| When you're writing tests, you often need to check that values meet certain conditions. The |
36
|
|
|
| "expect()" function gives you access to a set of "expectations" methods that you can use |
37
|
|
|
| to assert different things. Of course, you may extend the Expectation API at any time. |
38
|
|
|
| |
39
|
|
|
*/ |
40
|
|
|
|
41
|
|
|
/* |
42
|
|
|
|-------------------------------------------------------------------------- |
43
|
|
|
| Constants |
44
|
|
|
|-------------------------------------------------------------------------- |
45
|
|
|
*/ |
46
|
|
|
|
47
|
|
|
/* |
48
|
|
|
|-------------------------------------------------------------------------- |
49
|
|
|
| Functions |
50
|
|
|
|-------------------------------------------------------------------------- |
51
|
|
|
| |
52
|
|
|
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your |
53
|
|
|
| project that you don't want to repeat in every file. Here you can also expose helpers as |
54
|
|
|
| global functions to help you to reduce the number of lines of code in your test files. |
55
|
|
|
| |
56
|
|
|
*/ |
57
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths