55namespace WayOfDev \Cycle \Testing \Concerns ;
66
77use Cycle \Database \DatabaseProviderInterface ;
8- use Exception ;
98use PHPUnit \Framework \Constraint \Constraint ;
109use PHPUnit \Framework \Constraint \LogicalNot as ReverseConstraint ;
1110use WayOfDev \Cycle \Testing \Constraints \CountInDatabase ;
1211use WayOfDev \Cycle \Testing \Constraints \HasInDatabase ;
13- use WayOfDev \Cycle \Testing \Constraints \NotSoftDeletedInDatabase ;
14- use WayOfDev \Cycle \Testing \Constraints \SoftDeletedInDatabase ;
1512
1613/**
1714 * @method void assertThat($value, Constraint $constraint, string $message = '')
@@ -27,7 +24,7 @@ trait InteractsWithDatabase
2724 protected function assertDatabaseHas ($ table , array $ data , $ connection = null ): static
2825 {
2926 $ this ->assertThat (
30- $ this -> getTable ( $ table) ,
27+ $ table ,
3128 new HasInDatabase (app (DatabaseProviderInterface::class), $ data )
3229 );
3330
@@ -46,7 +43,7 @@ protected function assertDatabaseMissing($table, array $data, $connection = null
4643 new HasInDatabase (app (DatabaseProviderInterface::class), $ data )
4744 );
4845
49- $ this ->assertThat ($ this -> getTable ( $ table) , $ constraint );
46+ $ this ->assertThat ($ table , $ constraint );
5047
5148 return $ this ;
5249 }
@@ -60,7 +57,7 @@ protected function assertDatabaseMissing($table, array $data, $connection = null
6057 protected function assertDatabaseCount ($ table , int $ count , $ connection = null ): static
6158 {
6259 $ this ->assertThat (
63- $ this -> getTable ( $ table) ,
60+ $ table ,
6461 new CountInDatabase (app (DatabaseProviderInterface::class), $ count )
6562 );
6663
@@ -76,64 +73,10 @@ protected function assertDatabaseCount($table, int $count, $connection = null):
7673 protected function assertDatabaseEmpty ($ table , $ connection = null ): static
7774 {
7875 $ this ->assertThat (
79- $ this -> getTable ( $ table) ,
76+ $ table ,
8077 new CountInDatabase (app (DatabaseProviderInterface::class), 0 )
8178 );
8279
8380 return $ this ;
8481 }
85-
86- /**
87- * @param string|object $table
88- * @param string|null $connection
89- * @param string|null $deletedAtColumn
90- *
91- * @throws Exception
92- *
93- * @return $this
94- */
95- protected function assertSoftDeleted ($ table , array $ data = [], $ connection = null , $ deletedAtColumn = 'deleted_at ' ): static
96- {
97- if ($ this ->isSoftDeletableModel ($ table )) {
98- throw new Exception ('Eloquent not supported ' );
99- }
100-
101- $ this ->assertThat (
102- $ this ->getTable ($ table ),
103- new SoftDeletedInDatabase (app (DatabaseProviderInterface::class), $ data , $ deletedAtColumn )
104- );
105-
106- return $ this ;
107- }
108-
109- /**
110- * @param string|object $table
111- * @param string|null $connection
112- * @param string|null $deletedAtColumn
113- *
114- * @throws Exception
115- *
116- * @return $this
117- */
118- protected function assertNotSoftDeleted ($ table , array $ data = [], $ connection = null , $ deletedAtColumn = 'deleted_at ' ): static
119- {
120- if ($ this ->isSoftDeletableModel ($ table )) {
121- throw new Exception ('Eloquent not supported ' );
122- }
123-
124- $ this ->assertThat (
125- $ this ->getTable ($ table ),
126- new NotSoftDeletedInDatabase (app (DatabaseProviderInterface::class), $ data , $ deletedAtColumn )
127- );
128-
129- return $ this ;
130- }
131-
132- /**
133- * @param string|object $table
134- */
135- protected function getTable ($ table ): string
136- {
137- return $ table ;
138- }
13982}
0 commit comments