Passed
Pull Request — master (#119)
by
unknown
07:31
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
include_once 'Classes/Services/XPathXMLGenerator.php';
19
20
class XPathXMLGeneratorTest extends UnitTestCase
21
{
22
23
    /**
24
     * @var XPathXMLGenerator
25
     */
26
    private $xpathGenerator = null;
27
28
    protected function setUp() {
29
        $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...
30
    }
31
32
    /**
33
     * @test
34
     */
35
    public function testXMLGeneration1()
36
    {
37
        $xpath = 'mods:name[mods:role/mods:roleTerm[@type="code"][@authority="marcrelator"]="edt"]/mods:displayForm';
38
        $expectedXml = '<mods:name><mods:role><mods:roleTerm type="code" authority="marcrelator">edt</mods:roleTerm></mods:role><mods:displayForm/></mods:name>';
39
40
        $this->xpathGenerator->loop($xpath);
41
42
        $this->assertEquals(
43
            $expectedXml,
44
            $this->xpathGenerator->getXML()
45
        );
46
    }
47
48
    /**
49
     * @test
50
     */
51
    public function testXMLGeneration2()
52
    {
53
        $xpath = 'mods:language/mods:languageTerm[@authority="iso639-2b"][@type="code"]="ger"';
54
        $expectedXml = '<mods:language><mods:languageTerm authority="iso639-2b" type="code">ger</mods:languageTerm></mods:language>';
55
56
        $this->xpathGenerator->loop($xpath);
57
58
        $this->assertEquals(
59
            $expectedXml,
60
            $this->xpathGenerator->getXML()
61
        );
62
    }
63
64
    /**
65
     * @test
66
     */
67
    public function testXMLGeneration3()
68
    {
69
        $xpath = 'mods:originInfo[@eventType="publication"]';
70
        $expectedXml = '<mods:originInfo eventType="publication"/>';
71
72
        $this->xpathGenerator->loop($xpath);
73
74
        $this->assertEquals(
75
            $expectedXml,
76
            $this->xpathGenerator->getXML()
77
        );
78
    }
79
80
81
82
}
83