-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathXmlResponseTest.php
43 lines (39 loc) · 1.12 KB
/
XmlResponseTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace Hyunk3l\Test\PhpDesignPatterns\Structural\Decorator;
use Hyunk3l\PhpDesignPatterns\Structural\Decorator\ResponseInterface;
use Hyunk3l\PhpDesignPatterns\Structural\Decorator\XmlResponse;
use PHPUnit\Framework\TestCase;
/**
* Class XmlResponseTest
* @package PhpDesignPatterns\Tests\Structural\Decorator
*/
class XmlResponseTest extends TestCase
{
/**
* Test instance.
*
* @var XmlResponse
*/
private $xml_render;
/**
* Testing decorated render.
*/
public function testRender()
{
$fake_render = array('message' => 'api response to xml');
$api_mock = $this->getMockBuilder(ResponseInterface::class)
->setMethods(array('render'))
->getMock();
$api_mock
->expects($this->once())
->method('render')
->will($this->returnValue($fake_render))
;
$this->xml_render = new XmlResponse($api_mock);
$expected = <<<XML
<?xml version="1.0"?>
<root><message>api response to xml</message></root>\n
XML;
$this->assertEquals($expected, $this->xml_render->render());
}
}