1 | <?php |
||||||
2 | |||||||
3 | use craft\events\ExceptionEvent; |
||||||
4 | use craft\web\ErrorHandler; |
||||||
5 | use markhuot\craftpest\test\TestCase; |
||||||
0 ignored issues
–
show
|
|||||||
6 | use yii\base\Event; |
||||||
0 ignored issues
–
show
This use statement conflicts with another class in this namespace,
Event . Consider defining an alias.
Let?s assume that you have a directory layout like this: .
|-- OtherDir
| |-- Bar.php
| `-- Foo.php
`-- SomeDir
`-- Foo.php
and let?s assume the following content of // Bar.php
namespace OtherDir;
use SomeDir\Foo; // This now conflicts the class OtherDir\Foo
If both files PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as // Bar.php
namespace OtherDir;
use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
![]() |
|||||||
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) |
||||||
0 ignored issues
–
show
The function
uses was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
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