Completed
Branch proxy (a8ed88)
by leo
08:29
created

testSetFailure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 16
nc 1
nop 0
dl 0
loc 18
rs 9.4285
c 1
b 0
f 1
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