@@ -31,7 +31,6 @@ public function testSerializeAttribute()
3131
3232 public function testUnserializeAttribute ()
3333 {
34- $ uuid = 'cf98906e-9074-11e7-9c8e-437b4bab8527 ' ;
3534 $ mutator = M::mock (MutatorContract::class)
3635 ->shouldReceive ('get ' )
3736 ->with ('test_mutator ' )
@@ -52,6 +51,47 @@ public function testUnserializeAttribute()
5251 $ this ->assertEquals ('serialized_attribute ' , $ model ->id );
5352 }
5453
54+ public function testGetOriginal ()
55+ {
56+ $ mutator = M::mock (MutatorContract::class)
57+ ->shouldReceive ('get ' )
58+ ->with ('test_mutator ' )
59+ ->andReturnSelf ()
60+ ->once ()
61+ ->shouldReceive ('unserializeAttribute ' )
62+ ->with ('unserialized_attribute ' )
63+ ->andReturn ('serialized_attribute ' )
64+ ->once ()
65+ ->getMock ();
66+
67+ app ()['mutator ' ] = $ mutator ;
68+
69+ $ model = new SampleModel ();
70+ $ original = $ model ->getOriginal ();
71+
72+ $ this ->assertIsArray ($ original );
73+ $ this ->assertEquals ('serialized_attribute ' , $ original ['id ' ]);
74+ }
75+
76+ public function testGetOriginalProperty ()
77+ {
78+ $ mutator = M::mock (MutatorContract::class)
79+ ->shouldReceive ('get ' )
80+ ->with ('test_mutator ' )
81+ ->andReturnSelf ()
82+ ->once ()
83+ ->shouldReceive ('unserializeAttribute ' )
84+ ->with ('unserialized_attribute ' )
85+ ->andReturn ('serialized_attribute ' )
86+ ->once ()
87+ ->getMock ();
88+
89+ app ()['mutator ' ] = $ mutator ;
90+
91+ $ model = new SampleModel ();
92+ $ this ->assertEquals ('serialized_attribute ' , $ model ->getOriginal ('id ' ));
93+ }
94+
5595 public function testGetMutators ()
5696 {
5797 $ this ->assertEquals (['id ' => 'test_mutator ' ], (new SampleModel ())->getMutators ());
0 commit comments