/** * Will return table entries. * @runInSeparateProcess */ public function testWillReturnTableEntries() { $expected = ['table_0', 'table_1', 'table_2']; $statement = \Mockery::mock(\PDOStatement::class)->makePartial(); $statement->shouldReceive('execute')->once(); $statement->shouldReceive('fetchAll')->once()->andReturn($expected); $engine = \Mockery::mock(\PDO::class); $engine->shouldReceive('prepare')->once()->with('SHOW TABLES')->andReturn($statement); $instance = new PDOStorage($engine); $response = $instance->getTableNames(); static::assertEquals($expected, $response); }
/** * Will return entries from table. */ public function testWillReturnEntriesFromTable() { $tableName = 'table_name'; $expected = ['index1-response-something']; $statement = \Mockery::mock(\PDOStatement::class)->makePartial(); $statement->shouldReceive('execute')->once(); $statement->shouldReceive('fetchAll')->once()->with(\PDO::FETCH_ASSOC)->andReturn($expected); $engine = \Mockery::mock(\PDO::class); $engine->shouldReceive('prepare')->once()->with('SHOW INDEXES FROM ' . $tableName)->andReturn($statement); $instance = new PDOStorage($engine); $response = $instance->getIndexesByTableName($tableName); static::assertSame($expected, $response); }