public function setUp()
 {
     $this->mysqlCredentials = new \stdClass();
     $this->mysqlCredentials->host = 'mysql.host';
     $this->mysqlCredentials->dbuser = '******';
     $this->mysqlCredentials->dbpass = '******';
     $this->mysqlCredentials->dbname = 'database1';
     $this->PDOMock = \Mockery::mock('\\PDOMock')->makePartial();
     $databaseEntries = array(array('database1'), array('database2'));
     $this->PDOMock->shouldReceive('query')->with('SHOW DATABASES')->andReturn($databaseEntries);
     $this->PDOMock->shouldReceive('query')->with('use database1');
     $this->PDOMock->shouldReceive('query')->with('use database2');
     $this->PDOMock->shouldReceive('query')->with('SHOW TABLES')->once()->andReturn(array(array('table1'), array('table2')));
     $this->PDOMock->shouldReceive('query')->with('SHOW TABLES')->once()->andReturn(array(array('table3')));
     $database1_table1_TablesEntries = array('Create Table' => $this->table['table_1']);
     $database1_table2_TablesEntries = array('Create Table' => $this->table['table_2']);
     $database2_table3_TablesEntries = array('Create Table' => $this->table['table_3']);
     $database1_table1_TablesEntries_Mock = \Mockery::mock('\\PDOQueryMock')->makePartial();
     $database1_table1_TablesEntries_Mock->shouldReceive('fetch')->andReturn($database1_table1_TablesEntries);
     $database1_table2_TablesEntries_Mock = \Mockery::mock('\\PDOQueryMock')->makePartial();
     $database1_table2_TablesEntries_Mock->shouldReceive('fetch')->andReturn($database1_table2_TablesEntries);
     $database2_table3_TablesEntries_Mock = \Mockery::mock('\\PDOQueryMock')->makePartial();
     $database2_table3_TablesEntries_Mock->shouldReceive('fetch')->andReturn($database2_table3_TablesEntries);
     $this->PDOMock->shouldReceive('query')->with('SHOW CREATE TABLE `table1`')->andReturn($database1_table1_TablesEntries_Mock);
     $this->PDOMock->shouldReceive('query')->with('SHOW CREATE TABLE `table2`')->andReturn($database1_table2_TablesEntries_Mock);
     $this->PDOMock->shouldReceive('query')->with('SHOW CREATE TABLE `table3`')->andReturn($database2_table3_TablesEntries_Mock);
     $systemMock = \Mockery::mock('\\MySQLExtractor\\SystemMock')->makePartial();
     $systemMock->shouldReceive('getPDO')->with($this->mysqlCredentials)->andReturn($this->PDOMock);
     $systemMock->shouldReceive('flush');
     $systemMockHelper = new \PHPUnitProtectedHelper(new System());
     $systemMockHelper->setValue('mock', $systemMock);
     $this->object = new Server($this->mysqlCredentials);
     $this->objectHelper = new \PHPUnitProtectedHelper($this->object);
 }
 /**
  * when pdo connection is not mocked then throw PDOException if invalid host
  */
 public function testWhenPDOConnectionIsNotMockedThenThrowPDOExceptionIfInvalidHost()
 {
     $systemMockHelper = new \PHPUnitProtectedHelper(new System());
     $systemMockHelper->setValue('mock', null);
     try {
         $object = new Server($this->mysqlCredentials);
         $this->fail();
     } catch (\PDOException $e) {
         $message = $e->getMessage();
         $this->assertNotEmpty($message);
     }
 }