Author: Mike Lively (m@digitalsandwich.com)
Inheritance: extends PHPUnit_Extensions_Database_DataSet_AbstractDataSet
Ejemplo n.º 1
0
 public function createQueryDataset($tables)
 {
     $ds = new \PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection());
     foreach ($tables as $table => $query) {
         $ds->addTable($table, $query);
     }
     return $ds;
 }
Ejemplo n.º 2
0
 /**
  * assembles the table from the schema and provides it to PHPUnit
  *
  * @return PHPUnit_Extensions_Database_DataSet_QueryDataSet assembled schema for PHPUnit
  **/
 public final function getDataSet()
 {
     $dataset = new PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection());
     // add all the tables for the project here
     // THESE TABLES *MUST* BE LISTED IN THE SAME ORDER THEY WERE CREATED!!!!
     $dataset->addTable("profile");
     $dataset->addTable("tweet");
     $dataset->addTable("favorite");
     return $dataset;
 }
 public function test_cur()
 {
     $userMapper = new userMapper($this->db);
     $s1 = new current_student();
     $s1->setId(800895555);
     $userMapper->insert($s1);
     $this->assertEquals(1, $this->getConncetion()->getRowCount('id'));
     $expected = $this->createFlatDataSet(__DIR__ . '/db_insertData.xml');
     $actual = new PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection());
     $actual->addTable('current_student');
     $this->assertDataSetsEqual($expected, $actual);
 }
Ejemplo n.º 4
0
 public function testDeleteItems()
 {
     $model = $this->_getModel();
     $model->deleteItems(1);
     $dataSet = new \PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection());
     foreach (static::$_tables as $table) {
         if ($table == 'ClientsAndGroups' or $table == 'DuplicateMacAddresses' or $table == 'SoftwareDefinitions') {
             continue;
         }
         $table = static::$serviceManager->get("Database\\Table\\{$table}")->table;
         $dataSet->addTable($table, "SELECT hardware_id FROM {$table}");
     }
     $this->assertDataSetsEqual($this->_loadDataSet('DeleteItems'), $dataSet);
 }
Ejemplo n.º 5
0
 /**
  * Test the Joomla\Log\Logger\Database::addEntry method.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function testAddEntry01()
 {
     $config = array('db' => self::$driver);
     $logger = new Database($config);
     // Get the expected database from XML.
     $expected = $this->createXMLDataSet(__DIR__ . '/stubs/S01E01.xml');
     // Add the new entries to the database.
     $logger->addEntry(new LogEntry('Testing Entry 02', Log::INFO, null, '2009-12-01 12:30:00'));
     $logger->addEntry(new LogEntry('Testing3', Log::EMERGENCY, 'deprecated', '2010-12-01 02:30:00'));
     // Get the actual dataset from the database.
     $actual = new \PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection());
     $actual->addTable('jos_log_entries');
     // Verify that the data sets are equal.
     $this->assertDataSetsEqual($expected, $actual);
 }
Ejemplo n.º 6
0
 public final function getDataSet()
 {
     $dataset = new \PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection());
     //Add all the tables for the project here
     $dataset->addTable("profile");
     $dataset->addTable("image");
     $dataset->addTable("tag");
     $dataset->addTable("comment");
     $dataset->addTable("vote");
     $dataset->addTable("imageTag");
     $dataset->addTable("follower");
     return $dataset;
 }
Ejemplo n.º 7
0
 /**
  * Test the JLoggerDatabase::addEntry method.
  */
 public function testAddEntry02()
 {
     // Setup the logger.
     $config = array('db_driver' => 'sqlite', 'db_database' => ':memory:', 'db_prefix' => 'jos_');
     $logger = new JLoggerDatabase($config);
     TestReflection::setValue($logger, 'dbo', JFactory::$database);
     // Get the expected database from XML.
     $expected = $this->createXMLDataSet(__DIR__ . '/stubs/database/S01E01.xml');
     // Add the new entries to the database.
     $logger->addEntry(new JLogEntry('Testing Entry 02', JLog::INFO, null, '2009-12-01 12:30:00'));
     $logger->addEntry(new JLogEntry('Testing3', JLog::EMERGENCY, 'deprecated', '2010-12-01 02:30:00'));
     // Get the actual dataset from the database.
     $actual = new PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection());
     $actual->addTable('jos_log_entries');
     // Verify that the data sets are equal.
     $this->assertDataSetsEqual($expected, $actual);
 }
 /**
  * assembles the table from the schema and provides it to PHPUnit
  *
  * @return \PHPUnit_Extensions_Database_DataSet_QueryDataSet assembled schema for PHPUnit
  **/
 public final function getDataSet()
 {
     $dataset = new \PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection());
     //add all the tables for the project here
     //THESE TABLES *MUST* BE LISTED IN THE SAME ORDER THEY WERE CREATED!
     $dataset->addTable("company");
     $dataset->addTable("crew");
     $dataset->addTable("access");
     $dataset->addTable("user");
     $dataset->addTable("schedule");
     $dataset->addTable("request");
     $dataset->addTable("shift");
     return $dataset;
 }
Ejemplo n.º 9
0
 /**
  * assembles the table from the schema and provides it to PHPUnit
  *
  * @return PHPUnit_Extensions_Database_DataSet_QueryDataSet assembled schema for PHPUnit
  **/
 public final function getDataSet()
 {
     $dataset = new PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection());
     // add all the tables for the project here
     // THESE TABLES *MUST* BE LISTED IN THE SAME ORDER THEY WERE CREATED!!!!
     $dataset->addTable("segment");
     $dataset->addTable("user");
     $dataset->addTable("trail");
     $dataset->addTable("comment");
     $dataset->addTable("rating");
     $dataset->addTable("trailRelationship");
     return $dataset;
 }
Ejemplo n.º 10
0
 /**
  * Test the JLoggerDatabase::addEntry method.
  */
 public function testAddEntry02()
 {
     // Setup the basic configuration.
     @(include_once JPATH_TESTS . '/config.php');
     if (class_exists('JTestConfig')) {
         $config = new JTestConfig();
     }
     // Setup the basic configuration.
     $config = array('db_driver' => $config->dbtype, 'db_host' => $config->host, 'db_user' => $config->user, 'db_pass' => $config->password, 'db_database' => $config->db, 'db_prefix' => $config->dbprefix);
     $logger = new JLoggerDatabaseInspector($config);
     // Get the expected database from XML.
     $expected = $this->createXMLDataSet(__DIR__ . '/stubs/database/S01E01.xml');
     // Add the new entries to the database.
     $logger->addEntry(new JLogEntry('Testing Entry 02', JLog::INFO, null, '2009-12-01 12:30:00'));
     $logger->addEntry(new JLogEntry('Testing3', JLog::EMERGENCY, 'deprecated', '2010-12-01 02:30:00'));
     // Get the actual dataset from the database.
     $actual = new PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection());
     $actual->addTable('jos_log_entries');
     // Verify that the data sets are equal.
     $this->assertDataSetsEqual($expected, $actual);
 }
Ejemplo n.º 11
0
 /**
  * assembles the table from the schema and provides it to PHPUnit
  *
  * @return PHPUnit_Extensions_Database_DataSet_QueryDataSet assembled schema for PHPUnit
  **/
 public final function getDataSet()
 {
     $dataset = new PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection());
     // add all the tables for the project here
     // THESE TABLES *MUST* BE LISTED IN THE SAME ORDER THEY WERE CREATED!!!!
     $dataset->addTable("organization");
     $dataset->addTable("volunteer");
     //$dataset->addTable("administrator");
     $dataset->addTable("listingType");
     $dataset->addTable("listing");
     $dataset->addTable("message");
     return $dataset;
 }
Ejemplo n.º 12
0
 /**
  * assembles the table from the schema and provides it to PHPUnit
  *
  * @return PHPUnit_Extensions_Database_DataSet_QueryDataSet assembled schema for PHPUnit
  **/
 public final function getDataSet()
 {
     $dataset = new PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection());
     // add all the tables for the project here
     // THESE TABLES *MUST* BE LISTED IN THE SAME ORDER THEY WERE CREATED!!!!
     $dataset->addTable("user");
     $dataset->addTable("unitOfMeasure");
     $dataset->addTable("alertLevel");
     $dataset->addTable("vendor");
     $dataset->addTable("product");
     $dataset->addTable("productAlert");
     $dataset->addTable("location");
     $dataset->addTable("finishedProduct");
     $dataset->addTable("productLocation");
     $dataset->addTable("movement");
     $dataset->addTable("notification");
     return $dataset;
 }
Ejemplo n.º 13
0
 public function testGetTableNames()
 {
     $this->assertEquals(array('table1', 'query1'), $this->dataSet->getTableNames());
 }
Ejemplo n.º 14
0
 /**
  * Verify successful update of organization contact.
  */
 public function testUpdateOrganizationWithAll()
 {
     // Insert a row in civicrm_contact creating organization contact
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, $this->createXMLDataSet(dirname(__FILE__) . '/dataset/contact_org.xml'));
     $params = array('id' => 24, 'organization_name' => 'WebAccess India Pvt Ltd', 'legal_name' => 'WebAccess', 'sic_code' => 'ABC12DEF', 'contact_type' => 'Organization');
     $this->callAPISuccess('Contact', 'Update', $params);
     // Check updated civicrm_contact against expected.
     $expected = $this->createXMLDataSet(dirname(__FILE__) . '/dataset/contact_org_upd.xml');
     $actual = new PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->_dbconn);
     $actual->addTable('civicrm_contact');
     $expected->matches($actual);
 }
Ejemplo n.º 15
0
 public function testDataSet()
 {
     if ($this->__debug) {
         echo __METHOD__ . "\n";
     }
     // Assert 1
     $dataSet = self::$__conn->createDataSet(['session']);
     $expected = $this->getDataSet('session');
     $this->assertDataSetsEqual($expected, $dataSet);
     // Assert 2
     $dataSet = new PHPUnit_Extensions_Database_DataSet_QueryDataSet(self::$__conn);
     $dataSet->addTable('session', 'SELECT sess_key FROM session');
     $expectedDataSet = $this->getDataSet('special');
     $this->assertDataSetsEqual($expectedDataSet, $dataSet);
 }
Ejemplo n.º 16
0
 /**
  * @covers ::update
  */
 public function testUpdate()
 {
     $carTable = new CarTable($this->pdo);
     $cars = $carTable->findAll();
     $this->assertCount(2, $cars);
     /**
      * Alter first car
      */
     $firstCar = $cars[0];
     $this->assertFalse($firstCar->isAltered());
     $firstCar->set('horsepower', 21);
     $this->assertTrue($firstCar->isAltered());
     $carTable->update($firstCar);
     /**
      * Alter second car
      */
     $secondCar = $cars[1];
     $this->assertFalse($secondCar->isAltered());
     $secondCar->set('horsepower', 41);
     $this->assertTrue($secondCar->isAltered());
     $carTable->update($secondCar);
     /**
      * Assert data set
      */
     $expectedCsvDataSet = new \PHPUnit_Extensions_Database_DataSet_CsvDataSet();
     $expectedCsvDataSet->addTable('cars', dirname(__FILE__) . '/../Fixture/cars_after-update.csv');
     $expectedDataSet = new \PHPUnit_Extensions_Database_DataSet_DataSetFilter($expectedCsvDataSet);
     $expectedDataSet->setExcludeColumnsForTable('cars', ['modified', 'created']);
     $dataSet = new \PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection());
     $dataSet->addTable('cars', 'SELECT * FROM `cars`');
     $dataSet = new \PHPUnit_Extensions_Database_DataSet_DataSetFilter($dataSet);
     $dataSet->setExcludeColumnsForTable('cars', ['modified', 'created']);
     $this->assertDataSetsEqual($expectedDataSet, $dataSet);
 }
Ejemplo n.º 17
0
 public function testWithDatasetOnly()
 {
     // Create a dataset from live table through sql dataset
     // This is also a kind of live data only
     $ds1 = new PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection());
     $ds1->addTable('user');
     $ds2 = $this->getArrayDataset();
     $filterDataSet = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($ds2);
     $filterDataSet->addIncludeTables(array('user'));
     $this->assertDataSetsEqual($ds1, $filterDataSet);
 }