-
Notifications
You must be signed in to change notification settings - Fork 0
/
BridgeTest.php
30 lines (26 loc) · 1.06 KB
/
BridgeTest.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
<?php
namespace Tests;
use Patterns\Structural\Bridge\JsonFormatter;
use Patterns\Structural\Bridge\UsersReport;
use Patterns\Structural\Bridge\XmlFormatter;
class BridgeTest extends BaseTestCase
{
public function testCanGenerateUsersReportUsingXmlFormatter()
{
$data = ['test_1' => 123, 'test_2' => 'abc'];
$xmlFormatter = new XmlFormatter();
$usersReport = new UsersReport($xmlFormatter);
$usersReport->setStatistics($data);
$expectedReport = '<?xml version="1.0"?><root><line id="test_1">123</line><line id="test_2">abc</line></root>';
$this->assertEquals($expectedReport, $usersReport->getReport());
}
public function testCanGenerateUsersReportUsingJsonFormatter()
{
$data = ['test_1' => 123, 'test_2' => 'abc'];
$xmlFormatter = new JsonFormatter();
$usersReport = new UsersReport($xmlFormatter);
$usersReport->setStatistics($data);
$expectedReport = '{"test_1":123,"test_2":"abc"}';
$this->assertEquals($expectedReport, $usersReport->getReport());
}
}