66
77declare (strict_types=1 );
88
9+ use Mockery \MockInterface ;
910use Nette \Database \Structure ;
1011use Tester \Assert ;
1112use Tester \TestCase ;
@@ -29,21 +30,17 @@ class StructureMock extends Structure
2930 */
3031class StructureTestCase extends TestCase
3132{
32- private Nette \Database \Connection $ connection ;
33- private Nette \Database \Drivers \Engine $ engine ;
34- private Nette \Caching \Storage $ storage ;
35- private Structure $ structure ;
33+ private Nette \Database \Drivers \Engine |MockInterface $ engine ;
34+ private Nette \Caching \Cache |MockInterface $ cache ;
35+ private Structure |MockInterface $ structure ;
3636
3737
3838 protected function setUp ()
3939 {
4040 parent ::setUp ();
4141 $ this ->engine = Mockery::mock (Nette \Database \Drivers \Engine::class);
42- $ this ->connection = Mockery::mock (Nette \Database \Connection::class);
43- $ this ->storage = Mockery::mock (Nette \Caching \Storage::class);
42+ $ this ->cache = Mockery::mock (Nette \Caching \Cache::class);
4443
45- $ this ->connection ->shouldReceive ('getDsn ' )->once ()->andReturn ('' );
46- $ this ->connection ->shouldReceive ('getDatabaseEngine ' )->once ()->andReturn ($ this ->engine );
4744 $ this ->engine ->shouldReceive ('getTables ' )->once ()->andReturn ([
4845 ['name ' => 'authors ' , 'view ' => false ],
4946 ['name ' => 'Books ' , 'view ' => false ],
@@ -71,7 +68,6 @@ class StructureTestCase extends TestCase
7168 ['name ' => 'id ' , 'primary ' => false , 'autoIncrement ' => false , 'vendor ' => []],
7269 ['name ' => 'title ' , 'primary ' => false , 'autoIncrement ' => false , 'vendor ' => []],
7370 ]);
74- $ this ->connection ->shouldReceive ('getDatabaseEngine ' )->times (4 )->andReturn ($ this ->engine );
7571 $ this ->engine ->shouldReceive ('getForeignKeys ' )->with ('authors ' )->once ()->andReturn ([]);
7672 $ this ->engine ->shouldReceive ('getForeignKeys ' )->with ('Books ' )->once ()->andReturn ([
7773 ['local ' => ['author_id ' ], 'table ' => 'authors ' , 'foreign ' => ['id ' ], 'name ' => 'authors_fk1 ' ],
@@ -83,7 +79,7 @@ class StructureTestCase extends TestCase
8379 ['local ' => ['tag_id ' ], 'table ' => 'tags ' , 'foreign ' => ['id ' ], 'name ' => 'books_x_tags_fk2 ' ],
8480 ]);
8581
86- $ this ->structure = new StructureMock ($ this ->connection , $ this ->storage );
82+ $ this ->structure = new StructureMock ($ this ->engine , $ this ->cache );
8783 }
8884
8985
@@ -132,7 +128,6 @@ class StructureTestCase extends TestCase
132128
133129 public function testGetPrimaryKeySequence ()
134130 {
135- $ this ->connection ->shouldReceive ('getDatabaseEngine ' )->times (4 )->andReturn ($ this ->engine );
136131 $ this ->engine ->shouldReceive ('isSupported ' )->with ('sequence ' )->once ()->andReturn (false );
137132 $ this ->engine ->shouldReceive ('isSupported ' )->with ('sequence ' )->times (3 )->andReturn (true );
138133
0 commit comments