GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

XsdValidatorTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 72
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A tearDown() 0 4 1
A testValidationSuccess() 0 6 1
A testValidationFailsThrowsException() 0 6 1
1
<?php
2
3
namespace Hautzi\SystemMailBundle\Tests\SystemMailer\XML;
4
5
use Hautzi\SystemMailBundle\SystemMailer\XML\XsdValidator;
6
7
class XsdValidatorTest extends \PHPUnit_Framework_TestCase
8
{
9
    protected $xsd = <<<EOL
10
<?xml version="1.0"?>
11
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
12
            targetNamespace="http://christoph-hautzinger.de/schema/system-mail-bundle"
13
            xmlns="http://christoph-hautzinger.de/schema/system-mail-bundle"
14
            elementFormDefault="qualified">
15
16
<xs:element name="email">
17
  <xs:complexType>
18
    <xs:sequence>
19
      <xs:element name="to" type="xs:string"/>
20
      <xs:element name="from" type="xs:string"/>
21
    </xs:sequence>
22
  </xs:complexType>
23
</xs:element>
24
25
</xs:schema>
26
EOL;
27
28
    protected $validXml = <<<EOL
29
<?xml version="1.0"?>
30
<email xmlns="http://christoph-hautzinger.de/schema/system-mail-bundle"
31
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
32
       xsi:schemaLocation="http://christoph-hautzinger.de/schema/system-mail-bundle http://christoph-hautzinger.de/schema/system-mail-bundle/email-1.0.xsd">
33
  <to>hautzi</to>
34
  <from>not-hautzi</from>
35
</email>
36
EOL;
37
38
    protected $invalidXml = <<<EOL
39
<?xml version="1.0"?>
40
<email xmlns="http://christoph-hautzinger.de/schema/system-mail-bundle"
41
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
42
       xsi:schemaLocation="http://christoph-hautzinger.de/schema/system-mail-bundle http://christoph-hautzinger.de/schema/system-mail-bundle/email-1.0.xsd">
43
  <message>hautzi</message>
44
  <from>not-hautzi</from>
45
</email>
46
EOL;
47
48
    protected $tmpXsdFile;
49
50
    protected function setUp()
51
    {
52
        $this->tmpXsdFile = tempnam('/tmp', 'FOO');
53
        file_put_contents($this->tmpXsdFile, $this->xsd);
54
    }
55
56
    protected function tearDown()
57
    {
58
        unlink($this->tmpXsdFile);
59
    }
60
61
62
    public function testValidationSuccess()
63
    {
64
        $xsd = new XsdValidator();
65
66
        $this->assertTrue($xsd->validate($this->validXml, $this->tmpXsdFile));
67
    }
68
69
    /**
70
     * @expectedException \Hautzi\SystemMailBundle\SystemMailer\XML\XsdValidationException
71
     */
72
    public function testValidationFailsThrowsException()
73
    {
74
        $xsd = new XsdValidator();
75
76
        $xsd->validate($this->invalidXml, $this->tmpXsdFile);
77
    }
78
}
79