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