File tree Expand file tree Collapse file tree 6 files changed +40
-3
lines changed
Expand file tree Collapse file tree 6 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
55and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
66
7+ ## [ Unreleased]
8+ ### Added
9+ - Issue #5 : ` ResultInterface::get() ` method added.
10+
711## [ 0.6.3] - 2019-11-18
812### Fixed
913- Issue #4 : replacing document root with ` add() ` fixed.
Original file line number Diff line number Diff line change @@ -44,4 +44,9 @@ public function decode()
4444 ->decoder
4545 ->exportValue ($ this ->nodeValue );
4646 }
47+
48+ public function get (): NodeValueInterface
49+ {
50+ return $ this ->nodeValue ;
51+ }
4752}
Original file line number Diff line number Diff line change 33
44namespace Remorhaz \JSON \Pointer \Processor \Result ;
55
6+ use Remorhaz \JSON \Data \Value \NodeValueInterface ;
7+
68final class NonExistingResult implements ResultInterface
79{
810
@@ -27,4 +29,9 @@ public function decode()
2729 {
2830 throw new Exception \ResultNotFoundException ($ this ->source );
2931 }
32+
33+ public function get (): NodeValueInterface
34+ {
35+ throw new Exception \ResultNotFoundException ($ this ->source );
36+ }
3037}
Original file line number Diff line number Diff line change 33
44namespace Remorhaz \JSON \Pointer \Processor \Result ;
55
6+ use Remorhaz \JSON \Data \Value \NodeValueInterface ;
7+
68interface ResultInterface
79{
810
@@ -11,4 +13,6 @@ public function exists(): bool;
1113 public function encode (): string ;
1214
1315 public function decode ();
16+
17+ public function get (): NodeValueInterface ;
1418}
Original file line number Diff line number Diff line change @@ -53,7 +53,6 @@ public function testEncode_EncoderExportsValue_ReturnsSameValue(): void
5353 );
5454
5555 $ encoder
56- ->expects (self ::once ())
5756 ->method ('exportValue ' )
5857 ->willReturn ('a ' );
5958 self ::assertSame ('a ' , $ result ->encode ());
@@ -87,9 +86,19 @@ public function testDecode_DecoderExportsValue_ReturnsSameValue(): void
8786 );
8887
8988 $ decoder
90- ->expects (self ::once ())
9189 ->method ('exportValue ' )
9290 ->willReturn ('a ' );
9391 self ::assertSame ('a ' , $ result ->decode ());
9492 }
93+
94+ public function testGet_ConstructedWithValue_ReturnsSameInstance (): void
95+ {
96+ $ value = $ this ->createMock (NodeValueInterface::class);
97+ $ result = new ExistingResult (
98+ $ this ->createMock (ValueEncoderInterface::class),
99+ $ this ->createMock (ValueDecoderInterface::class),
100+ $ value
101+ );
102+ self ::assertSame ($ value , $ result ->get ());
103+ }
95104}
Original file line number Diff line number Diff line change @@ -27,11 +27,19 @@ public function testEncode_ConstructedWithSource_ThrowsMatchingException(): void
2727 $ result ->encode ();
2828 }
2929
30- public function testDencode_ConstructedWithSource_ThrowsMatchingException (): void
30+ public function testDecode_ConstructedWithSource_ThrowsMatchingException (): void
3131 {
3232 $ result = new NonExistingResult ('a ' );
3333 $ this ->expectException (ResultNotFoundException::class);
3434 $ this ->expectExceptionMessage ('\'a \'' );
3535 $ result ->decode ();
3636 }
37+
38+ public function testGet_ConstructedWithSource_ThrowsMatchingException (): void
39+ {
40+ $ result = new NonExistingResult ('a ' );
41+ $ this ->expectException (ResultNotFoundException::class);
42+ $ this ->expectExceptionMessage ('\'a \'' );
43+ $ result ->get ();
44+ }
3745}
You can’t perform that action at this time.
0 commit comments