Passed
Branch proxy (abe564)
by leo
03:17
created

XmlAuthenticationFailureResponseTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 29
rs 10
c 1
b 0
f 1
wmc 2
lcom 1
cbo 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: leo108
5
 * Date: 2016/10/25
6
 * Time: 13:29
7
 */
8
9
namespace Leo108\CAS\Responses;
10
11
use TestCase;
12
13
class XmlAuthenticationFailureResponseTest extends TestCase
14
{
15
    public function testSetFailure()
16
    {
17
        $resp    = new XmlAuthenticationFailureResponse();
18
        $content = $this->getXML($resp);
19
        $this->assertNotContains('cas:authenticationFailure', $content);
20
        $resp->setFailure('code1', 'desc1');
21
        $content = $this->getXML($resp);
22
        $this->assertContains('cas:authenticationFailure', $content);
23
        $this->assertContains('code1', $content);
24
        $this->assertContains('desc1', $content);
25
        $resp->setFailure('code2', 'desc2');
26
        $content = $this->getXML($resp);
27
        $this->assertContains('cas:authenticationFailure', $content);
28
        $this->assertNotContains('code1', $content);
29
        $this->assertContains('code2', $content);
30
        $this->assertNotContains('desc1', $content);
31
        $this->assertContains('desc2', $content);
32
    }
33
34
    protected function getXML(XmlAuthenticationFailureResponse $resp)
35
    {
36
        $property = self::getNonPublicProperty($resp, 'node');
37
        $node     = $property->getValue($resp);
38
39
        return $node->asXML();
40
    }
41
}
42