@@ -996,7 +996,7 @@ public function itFailsToTransitionWhenTheAuditAuditableTypeDoesNotMatchTheModel
996
996
$ this ->expectException (AuditableTransitionException::class);
997
997
$ this ->expectExceptionMessage ('Expected Auditable type OwenIt\Auditing\Tests\Models\Article, got OwenIt\Auditing\Tests\Models\User instead ' );
998
998
999
- $ audit = factory ( Audit::class)-> make ([
999
+ $ audit = new Audit ([
1000
1000
'auditable_type ' => User::class,
1001
1001
]);
1002
1002
@@ -1052,7 +1052,7 @@ public function itFailsToTransitionWhenTheAuditAuditableTypeDoesNotMatchTheMorph
1052
1052
'articles ' => Article::class,
1053
1053
]);
1054
1054
1055
- $ audit = factory ( Audit::class)-> make ([
1055
+ $ audit = new Audit ([
1056
1056
'auditable_type ' => 'users ' ,
1057
1057
]);
1058
1058
@@ -1092,7 +1092,8 @@ public function itFailsToTransitionWhenTheAuditAuditableIdTypeDoesNotMatchTheMod
1092
1092
1093
1093
$ model = factory (Article::class)->create ();
1094
1094
1095
- $ audit = factory (Audit::class)->create ([
1095
+ $ audit = Audit::create ([
1096
+ 'event ' => 'updated ' ,
1096
1097
'auditable_type ' => Article::class,
1097
1098
'auditable_id ' => (string )$ model ->id ,
1098
1099
]);
@@ -1125,7 +1126,8 @@ public function itTransitionsWhenTheAuditAuditableIdTypeDoesNotMatchTheModelIdTy
1125
1126
$ key = (int )$ model ->id ;
1126
1127
}
1127
1128
1128
- $ audit = factory (Audit::class)->create ([
1129
+ $ audit = Audit::create ([
1130
+ 'event ' => 'updated ' ,
1129
1131
'auditable_type ' => Article::class,
1130
1132
'auditable_id ' => $ key ,
1131
1133
]);
@@ -1148,8 +1150,9 @@ public function itFailsToTransitionWhenAnAttributeRedactorIsSet()
1148
1150
'title ' => RightRedactor::class,
1149
1151
];
1150
1152
1151
- $ audit = factory (Audit::class)->create ([
1152
- 'auditable_id ' => $ model ->getKey (),
1153
+ $ audit = Audit::create ([
1154
+ 'event ' => 'created ' ,
1155
+ 'auditable_id ' => $ model ->getKey (),
1153
1156
'auditable_type ' => Article::class,
1154
1157
]);
1155
1158
@@ -1164,9 +1167,9 @@ public function itFailsToTransitionWhenTheAuditableAttributeCompatibilityIsNotMe
1164
1167
{
1165
1168
$ model = factory (Article::class)->create ();
1166
1169
1167
- $ incompatibleAudit = factory ( Audit::class)-> create ([
1168
- 'event ' => 'created ' ,
1169
- 'auditable_id ' => $ model ->getKey (),
1170
+ $ incompatibleAudit = Audit::create ([
1171
+ 'event ' => 'created ' ,
1172
+ 'auditable_id ' => $ model ->getKey (),
1170
1173
'auditable_type ' => Article::class,
1171
1174
'old_values ' => [],
1172
1175
'new_values ' => [
@@ -1175,19 +1178,25 @@ public function itFailsToTransitionWhenTheAuditableAttributeCompatibilityIsNotMe
1175
1178
],
1176
1179
]);
1177
1180
1181
+ $ exceptionWasThrown = false ;
1182
+
1178
1183
try {
1179
1184
$ model ->transitionTo ($ incompatibleAudit );
1180
1185
} catch (AuditableTransitionException $ e ) {
1181
1186
$ this ->assertSame (
1182
- 'Incompatibility between [OwenIt\Auditing\Tests\Models\Article:1] and [OwenIt\Auditing\Models\Audit:3 ] ' ,
1187
+ 'Incompatibility between [OwenIt\Auditing\Tests\Models\Article:1] and [OwenIt\Auditing\Models\Audit:2 ] ' ,
1183
1188
$ e ->getMessage ()
1184
1189
);
1185
1190
1186
1191
self ::Assert ()::assertArraySubset ([
1187
1192
'subject ' ,
1188
1193
'text ' ,
1189
1194
], $ e ->getIncompatibilities (), true );
1195
+
1196
+ $ exceptionWasThrown = true ;
1190
1197
}
1198
+
1199
+ $ this ->assertTrue ($ exceptionWasThrown );
1191
1200
}
1192
1201
1193
1202
/**
@@ -1223,8 +1232,9 @@ public function itTransitionsToAnotherModelState(
1223
1232
$ auditableType = $ morphMap ? 'articles ' : Article::class;
1224
1233
1225
1234
$ audits = $ models ->map (function (Article $ model ) use ($ auditableType , $ oldValues , $ newValues ) {
1226
- return factory (Audit::class)->create ([
1227
- 'auditable_id ' => $ model ->getKey (),
1235
+ return Audit::create ([
1236
+ 'event ' => 'updated ' ,
1237
+ 'auditable_id ' => $ model ->getKey (),
1228
1238
'auditable_type ' => $ auditableType ,
1229
1239
'old_values ' => $ oldValues ,
1230
1240
'new_values ' => $ newValues ,
0 commit comments