Example #1
0
 /**
  * Mocks a table.
  * 
  * @param string $table_name The name of the table to mock.
  * @param mixed $data The data to insert into the mocked table.
  * @param integer $input_format The format of the mocked data, must be one of MockDb::INPUT_FORMAT_ARRAY, MockDb::INPUT_FORMAT_CONSOLE.
  * @param string $profile The profile of the table to mock, defaults to the "default" profile.
  * @throws MockDbInvalidInputFormatException If an unknown input format is specified.
  */
 public function mockTable($table_name, $data, $input_format = self::INPUT_FORMAT_ARRAY, $profile = 'default')
 {
     switch ($input_format) {
         case self::INPUT_FORMAT_CONSOLE:
             $data = $this->parseInputFormatConsole($data);
             break;
         case self::INPUT_FORMAT_ARRAY:
             break;
         default:
             throw new MockDbInvalidInputFormatException('Unknown input format');
     }
     /**
      * Get the structure from the 'real' database
      * @todo throw an exception if the table does not exist.
      */
     $create_table_query = $this->mockDbModelReal->getCreateTableQuery($table_name, $profile);
     $result = $this->mockDbModelTest->createTable($create_table_query);
     $result = $this->mockDbModelTest->insertDataIntoMockedTable($table_name, $data['fields'], $data['data']);
 }
Example #2
0
 /**
  * Gets the PdoConnection object that is being used to connect to the database.
  * 
  * @return PdoConnection
  */
 public function getTestDbObject()
 {
     return $this->mockDbModelTest->getDbObject();
 }