1 | <?php |
||||||
2 | |||||||
3 | declare(strict_types=1); |
||||||
4 | |||||||
5 | namespace SimpleSAML\XML\TestUtils; |
||||||
6 | |||||||
7 | use DOMDocument; |
||||||
8 | use PHPUnit\Framework\Attributes\Depends; |
||||||
0 ignored issues
–
show
|
|||||||
9 | |||||||
10 | use function class_exists; |
||||||
11 | |||||||
12 | /** |
||||||
13 | * Test for AbstractElement classes to perform schema validation tests. |
||||||
14 | * |
||||||
15 | * @package simplesamlphp\xml-common |
||||||
16 | * @phpstan-ignore trait.unused |
||||||
17 | */ |
||||||
18 | trait SchemaValidationTestTrait |
||||||
19 | { |
||||||
20 | /** @var string|null */ |
||||||
21 | protected static ?string $schemaFile = null; |
||||||
22 | |||||||
23 | /** @var class-string */ |
||||||
0 ignored issues
–
show
|
|||||||
24 | protected static string $testedClass; |
||||||
25 | |||||||
26 | /** @var \DOMDocument */ |
||||||
27 | protected static DOMDocument $xmlRepresentation; |
||||||
28 | |||||||
29 | |||||||
30 | /** |
||||||
31 | * Test schema validation. |
||||||
32 | */ |
||||||
33 | #[Depends('testSerialization')] |
||||||
34 | public function testSchemaValidation(): void |
||||||
35 | { |
||||||
36 | if (!class_exists(self::$testedClass)) { |
||||||
37 | $this->markTestSkipped( |
||||||
0 ignored issues
–
show
It seems like
markTestSkipped() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
38 | 'Unable to run ' . self::class . '::testSchemaValidation(). Please set ' . self::class |
||||||
39 | . ':$testedClass to a class-string representing the XML-class being tested', |
||||||
40 | ); |
||||||
41 | } elseif (empty(self::$xmlRepresentation)) { |
||||||
42 | $this->markTestSkipped( |
||||||
43 | 'Unable to run ' . self::class . '::testSchemaValidation(). Please set ' . self::class |
||||||
44 | . ':$xmlRepresentation to a DOMDocument representing the XML-class being tested', |
||||||
45 | ); |
||||||
46 | } else { |
||||||
47 | // Validate before serialization |
||||||
48 | self::$testedClass::schemaValidate(self::$xmlRepresentation, self::$schemaFile); |
||||||
49 | |||||||
50 | // Perform serialization |
||||||
51 | $class = self::$testedClass::fromXML(self::$xmlRepresentation->documentElement); |
||||||
52 | $serializedClass = $class->toXML(); |
||||||
53 | |||||||
54 | // Validate after serialization |
||||||
55 | self::$testedClass::schemaValidate($serializedClass->ownerDocument, self::$schemaFile); |
||||||
56 | |||||||
57 | // If we got this far and no exceptions were thrown, consider this test passed! |
||||||
58 | $this->addToAssertionCount(1); |
||||||
0 ignored issues
–
show
It seems like
addToAssertionCount() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
59 | } |
||||||
60 | } |
||||||
61 | |||||||
62 | |||||||
63 | abstract public function testSerialization(): void; |
||||||
64 | } |
||||||
65 |
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