File tree 3 files changed +25
-18
lines changed
3 files changed +25
-18
lines changed Original file line number Diff line number Diff line change @@ -971,8 +971,8 @@ public function test_can_audit_custom_audit_model_implementation(): void
971
971
*/
972
972
public function itWillAuditSyncWithAuditablePivotClass ()
973
973
{
974
- $ group = factory ( Group::class )->create ();
975
- $ user = factory ( User::class )->create ();
974
+ $ group = Group::factory ( )->create ();
975
+ $ user = User::factory ( )->create ();
976
976
977
977
$ no_of_audits_before = Audit::where ('auditable_type ' , User::class)->count ();
978
978
@@ -996,8 +996,8 @@ public function itWillAuditSyncWithAuditablePivotClass()
996
996
*/
997
997
public function itWillAuditAttachWithAuditablePivotClass ()
998
998
{
999
- $ group = factory ( Group::class )->create ();
1000
- $ user = factory ( User::class )->create ();
999
+ $ group = Group::factory ( )->create ();
1000
+ $ user = User::factory ( )->create ();
1001
1001
1002
1002
$ no_of_audits_before = Audit::where ('auditable_type ' , User::class)->count ();
1003
1003
@@ -1016,8 +1016,8 @@ public function itWillAuditAttachWithAuditablePivotClass()
1016
1016
*/
1017
1017
public function itWillAuditDetachWithAuditablePivotClass ()
1018
1018
{
1019
- $ group = factory ( Group::class )->create ();
1020
- $ user = factory ( User::class )->create ();
1019
+ $ group = Group::factory ( )->create ();
1020
+ $ user = User::factory ( )->create ();
1021
1021
1022
1022
$ user ->groups ()->attach ($ group );
1023
1023
Original file line number Diff line number Diff line change 2
2
3
3
namespace OwenIt \Auditing \Tests \Models ;
4
4
5
+ use Illuminate \Database \Eloquent \Factories \HasFactory ;
6
+ use OwenIt \Auditing \Tests \database \factories \GroupFactory ;
7
+
5
8
class Group extends \Illuminate \Database \Eloquent \Model
6
9
{
10
+ use HasFactory;
11
+ protected static string $ factory = GroupFactory::class;
7
12
}
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- use Faker \ Generator as Faker ;
3
+ namespace OwenIt \ Auditing \ Tests \ database \ factories ;
4
4
5
- /*
6
- |--------------------------------------------------------------------------
7
- | Article Factories
8
- |--------------------------------------------------------------------------
9
- |
10
- */
5
+ use Illuminate \Database \Eloquent \Factories \Factory ;
6
+ use OwenIt \Auditing \Tests \Models \Group ;
11
7
12
- $ factory ->define (\OwenIt \Auditing \Tests \Models \Group::class, function (Faker $ faker ) {
13
- return [
14
- 'name ' => $ faker ->unique ()->colorName (),
15
- ];
16
- });
8
+ class GroupFactory extends Factory
9
+ {
10
+ protected $ model = Group::class;
11
+
12
+ public function definition ()
13
+ {
14
+ return [
15
+ 'name ' => fake ()->unique ()->colorName (),
16
+ ];
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments