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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* File BooleanPrimitiveTraitTest.php
*
* @author Edward Pfremmer <epfremme@nerdery.com>
*/
namespace Epfremme\Swagger\Tests\Entity\Mixin;
use Epfremme\Swagger\Entity\Mixin\Primitives\BooleanPrimitiveTrait;
use Epfremme\Swagger\Entity\Schemas\AbstractSchema;
use Epfremme\Swagger\Entity\Schemas\BooleanSchema;
use Epfremme\Swagger\Tests\Mixin\SerializerContextTrait;
/**
* Class BooleanPrimitiveTraitTest
*
* @package Epfremme\Swagger
* @subpackage Tests\Entity\Schemas\Primitives
*/
class BooleanPrimitiveTraitTest extends \PHPUnit_Framework_TestCase
{
use SerializerContextTrait;
/**
* @var BooleanPrimitiveTrait|\PHPUnit_Framework_MockObject_MockObject
*/
protected $mockTrait;
/**
* Mock Classname
* @var string
*/
protected $mockClass;
/**
* {@inheritdoc}
*/
protected function setUp()
{
$this->mockTrait = $this->getMockForTrait(BooleanPrimitiveTrait::class);
$this->mockClass = get_class($this->mockTrait);
}
/**
* @covers Epfremme\Swagger\Entity\Mixin\Primitives\BooleanPrimitiveTrait
*/
public function testSerialization()
{
$data = json_encode([
'type' => AbstractSchema::BOOLEAN_TYPE
]);
$primitive = $this->getSerializer()->deserialize($data, AbstractSchema::class, 'json');
$this->assertInstanceOf(BooleanSchema::class, $primitive);
$json = $this->getSerializer()->serialize($primitive, 'json');
$this->assertJson($json);
$this->assertJsonStringEqualsJsonString($data, $json);
}
}