2
2
3
3
namespace Tests ;
4
4
5
+ use Conner \Tagging \Contracts \TaggableContract ;
5
6
use Conner \Tagging \Providers \TaggingServiceProvider ;
7
+ use Conner \Tagging \Taggable ;
8
+ use Illuminate \Database \Eloquent \Model as Eloquent ;
9
+ use Illuminate \Foundation \Testing \WithFaker ;
6
10
7
11
abstract class TestCase extends \Orchestra \Testbench \TestCase
8
12
{
13
+ use WithFaker;
14
+
9
15
protected function getPackageProviders ($ app )
10
16
{
11
17
return [TaggingServiceProvider::class];
@@ -15,11 +21,19 @@ public function setUp(): void
15
21
{
16
22
parent ::setUp ();
17
23
24
+ $ this ->setUpFaker ();
25
+
18
26
$ this ->artisan ('migrate ' , [
19
27
'--database ' => 'testing ' ,
20
28
'--path ' => realpath (__DIR__ .'/../migrations ' ),
21
29
'--realpath ' => true ,
22
30
]);
31
+
32
+ \Schema::create ('books ' , function ($ table ) {
33
+ $ table ->increments ('id ' );
34
+ $ table ->string ('name ' );
35
+ $ table ->timestamps ();
36
+ });
23
37
}
24
38
25
39
/**
@@ -65,4 +79,23 @@ protected function assertArraysEqual(array $expected, array $actual, $regard_ord
65
79
66
80
$ this ->assertEquals ($ expected , $ actual );
67
81
}
82
+
83
+ function book ($ attributes = []): Book
84
+ {
85
+ $ attributes = array_merge (['name ' =>$ this ->faker ->name ], $ attributes );
86
+
87
+ return Book::create ($ attributes );
88
+ }
89
+ }
90
+
91
+ /**
92
+ * @property string name
93
+ */
94
+ class Book extends Eloquent implements TaggableContract
95
+ {
96
+ use Taggable;
97
+
98
+ protected $ connection = 'testing ' ;
99
+ protected static $ unguarded = true ;
100
+ public $ table = 'books ' ;
68
101
}
0 commit comments