@@ -74,7 +74,15 @@ public function testSave()
74
74
->mappedStatementRepository
75
75
->expects ($ this ->once ())
76
76
->method ('storeMappedStatement ' )
77
- ->with ($ this ->equalTo (MappedStatement::createFromModel ($ statement )), true );
77
+ ->with (
78
+ $ this ->callback (function (MappedStatement $ mappedStatement ) use ($ statement ) {
79
+ return $ this ->assertMappedStatement (
80
+ MappedStatement::createFromModel ($ statement ),
81
+ $ mappedStatement
82
+ );
83
+ }),
84
+ true
85
+ );
78
86
79
87
$ this ->statementRepository ->storeStatement ($ statement );
80
88
}
@@ -86,7 +94,15 @@ public function testSaveWithoutFlush()
86
94
->mappedStatementRepository
87
95
->expects ($ this ->once ())
88
96
->method ('storeMappedStatement ' )
89
- ->with ($ this ->equalTo (MappedStatement::createFromModel ($ statement )), false );
97
+ ->with (
98
+ $ this ->callback (function (MappedStatement $ mappedStatement ) use ($ statement ) {
99
+ return $ this ->assertMappedStatement (
100
+ MappedStatement::createFromModel ($ statement ),
101
+ $ mappedStatement
102
+ );
103
+ }),
104
+ false
105
+ );
90
106
91
107
$ this ->statementRepository ->storeStatement ($ statement , false );
92
108
}
@@ -98,4 +114,57 @@ protected function createMappedStatementRepositoryMock()
98
114
{
99
115
return $ this ->getMock ('\Xabbuh\XApi\Storage\Doctrine\Repository\MappedStatementRepository ' );
100
116
}
117
+
118
+ private function assertMappedStatement (MappedStatement $ expected , MappedStatement $ actual )
119
+ {
120
+ if ($ expected ->id !== $ actual ->id ) {
121
+ return false ;
122
+ }
123
+
124
+ if (!$ expected ->actor ->equals ($ actual ->actor )) {
125
+ return false ;
126
+ }
127
+
128
+ if (!$ expected ->verb ->equals ($ actual ->verb )) {
129
+ return false ;
130
+ }
131
+
132
+ if (!$ expected ->object ->equals ($ actual ->object )) {
133
+ return false ;
134
+ }
135
+
136
+ if (null === $ expected ->result && null !== $ actual ->result ) {
137
+ return false ;
138
+ }
139
+
140
+ if (null !== $ expected ->result && null === $ actual ->result ) {
141
+ return false ;
142
+ }
143
+
144
+ if (null !== $ expected ->result && !$ expected ->result ->equals ($ actual ->result )) {
145
+ return false ;
146
+ }
147
+
148
+ if (null === $ expected ->authority && null !== $ actual ->authority ) {
149
+ return false ;
150
+ }
151
+
152
+ if (null !== $ expected ->authority && null === $ actual ->authority ) {
153
+ return false ;
154
+ }
155
+
156
+ if (null !== $ expected ->authority && !$ expected ->authority ->equals ($ actual ->authority )) {
157
+ return false ;
158
+ }
159
+
160
+ if ($ expected ->created != $ actual ->created ) {
161
+ return false ;
162
+ }
163
+
164
+ if (null === $ actual ->stored ) {
165
+ return false ;
166
+ }
167
+
168
+ return true ;
169
+ }
101
170
}
0 commit comments