Skip to content

Commit 3803176

Browse files
author
Rodion Liuborets
committed
Fix jsonSerialize in IbvOptions
1 parent 9a5eefe commit 3803176

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/DocScan/Session/Create/IbvOptions.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
namespace Yoti\DocScan\Session\Create;
44

5-
class IbvOptions
5+
use JsonSerializable;
6+
use Yoti\Util\Json;
7+
8+
class IbvOptions implements JsonSerializable
69
{
710
/**
811
* @var string
@@ -39,4 +42,16 @@ public function getGuidanceUrl(): ?string
3942
{
4043
return $this->guidanceUrl;
4144
}
45+
46+
47+
/**
48+
* @return \stdClass
49+
*/
50+
public function jsonSerialize(): \stdClass
51+
{
52+
return (object)Json::withoutNullValues([
53+
'support' => $this->getSupport(),
54+
'guidance_url' => $this->getGuidanceUrl(),
55+
]);
56+
}
4257
}

tests/DocScan/Session/Create/IbvOptionsBuilderTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,23 @@ public function builderShouldSetCorrectGuidanceUrlValue()
7878

7979
$this->assertEquals(self::SOME_GUIDANCE_URL, $result->getGuidanceUrl());
8080
}
81+
82+
/**
83+
* @test
84+
* @covers \Yoti\DocScan\Session\Create\IbvOptions::jsonSerialize
85+
*/
86+
public function shouldSerializeWithCorrectProperties(): void
87+
{
88+
$result = (new IbvOptionsBuilder())
89+
->withIbvNotAllowed()
90+
->withGuidanceUrl(self::SOME_GUIDANCE_URL)
91+
->build();
92+
93+
$expected = [
94+
'support' => 'NOT_ALLOWED',
95+
'guidance_url' => self::SOME_GUIDANCE_URL,
96+
];
97+
98+
$this->assertJsonStringEqualsJsonString(json_encode($expected), json_encode($result));
99+
}
81100
}

0 commit comments

Comments
 (0)