Passed
Pull Request — master (#119)
by
unknown
02:26
created

XPathXMLGeneratorTest::testXMLGeneration2()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
namespace EWW\Dpf\Tests\Unit\Services;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
use Nimut\TestingFramework\TestCase\UnitTestCase;
0 ignored issues
show
Bug introduced by
The type Nimut\TestingFramework\TestCase\UnitTestCase was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
19
class XPathXMLGeneratorTest extends UnitTestCase
20
{
21
22
    /**
23
     * @var XPathXMLGenerator
24
     */
25
    private $xpathGenerator = null;
26
27
    protected function setUp() {
28
        $this->xpathGenerator = new \EWW\Dpf\Services\XPathXMLGenerator();
0 ignored issues
show
Documentation Bug introduced by
It seems like new EWW\Dpf\Services\XPathXMLGenerator() of type EWW\Dpf\Services\XPathXMLGenerator is incompatible with the declared type EWW\Dpf\Tests\Unit\Services\XPathXMLGenerator of property $xpathGenerator.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
29
    }
30
31
    /**
32
     * @test
33
     */
34
    public function testXMLGeneration1()
35
    {
36
        $xpath = 'mods:name[mods:role/mods:roleTerm[@type="code"][@authority="marcrelator"]="edt"]/mods:displayForm';
37
        $expectedXml = '<mods:name><mods:role><mods:roleTerm type="code" authority="marcrelator">edt</mods:roleTerm></mods:role><mods:displayForm/></mods:name>';
38
39
        $this->xpathGenerator->loop($xpath);
40
41
        $this->assertEquals(
42
            $expectedXml,
43
            $this->xpathGenerator->getXML()
44
        );
45
    }
46
47
    /**
48
     * @test
49
     */
50
    public function testXMLGeneration2()
51
    {
52
        $xpath = 'mods:language/mods:languageTerm[@authority="iso639-2b"][@type="code"]="ger"';
53
        $expectedXml = '<mods:language><mods:languageTerm authority="iso639-2b" type="code">ger</mods:languageTerm></mods:language>';
54
55
        $this->xpathGenerator->loop($xpath);
56
57
        $this->assertEquals(
58
            $expectedXml,
59
            $this->xpathGenerator->getXML()
60
        );
61
    }
62
63
}
64