addIncludeTables() public method

Adds tables to be included in the data set.
public addIncludeTables ( array $tables )
$tables array
 public function testIncludeExcludeMixedDataSet()
 {
     $constraint = new PHPUnit_Extensions_Database_Constraint_DataSetIsEqual($this->expectedDataSet);
     $dataSet = new PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet(dirname(__FILE__) . '/../_files/XmlDataSets/FilteredTestComparison.xml');
     $filteredDataSet = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($dataSet);
     $filteredDataSet->addIncludeTables(array('table1', 'table3'));
     $filteredDataSet->setExcludeColumnsForTable('table1', array('table1_id'));
     $filteredDataSet->setIncludeColumnsForTable('table3', array('column9', 'column10', 'column11', 'column12'));
     self::assertThat($filteredDataSet, $constraint);
 }
示例#2
0
 public function testUsersResetAssignments()
 {
     $role_id_1 = self::$rbac->Roles->add('roles_1', 'roles Description 1');
     $role_id_2 = self::$rbac->Roles->add('roles_2', 'roles Description 2');
     $role_id_3 = self::$rbac->Roles->add('roles_3', 'roles Description 3');
     self::$rbac->Users->assign($role_id_1, 5);
     self::$rbac->Users->assign($role_id_2, 5);
     self::$rbac->Users->assign($role_id_3, 5);
     self::$rbac->Users->resetAssignments(true);
     $dataSet = $this->getConnection()->createDataSet();
     $filterDataSet = new \PHPUnit_Extensions_Database_DataSet_DataSetFilter($dataSet);
     $filterDataSet->addIncludeTables(array(self::$rbac->Users->tablePrefix() . 'userroles'));
     $filterDataSet->setExcludeColumnsForTable(self::$rbac->Users->tablePrefix() . 'userroles', array('assignmentdate'));
     $expectedDataSet = $this->_dataSet('users/expected_reset_assignments');
     $this->assertDataSetsEqual($expectedDataSet, $filterDataSet);
 }
示例#3
0
 /**
  * Load dataset from XML file.
  *
  * @param string $file The name of the file to load
  * @return array
  */
 protected function load_xml_data_file($file)
 {
     static $replacements = null;
     $raw = $this->createXMLDataSet($file);
     $clean = new PHPUnit_Extensions_Database_DataSet_ReplacementDataSet($raw);
     foreach ($this->replacements as $placeholder => $value) {
         $clean->addFullReplacement($placeholder, $value);
     }
     $logs = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($clean);
     $logs->addIncludeTables(array('log'));
     $stats = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($clean);
     $stats->addIncludeTables(array('stats_daily', 'stats_user_daily'));
     return array($logs, $stats);
 }
示例#4
0
 public function testRolesRemoveRecursive()
 {
     $role_id_1 = $this->Instance()->add($this->type() . '_1', $this->type() . ' Description 1');
     $role_id_2 = $this->Instance()->add($this->type() . '_2', $this->type() . ' Description 2', $role_id_1);
     $role_id_3 = $this->Instance()->add($this->type() . '_3', $this->type() . ' Description 3', $role_id_1);
     $role_id_4 = $this->Instance()->add($this->type() . '_4', $this->type() . ' Description 4');
     $perm_id_1 = self::$rbac->Permissions->add('permissions_1', 'permissions Description 1');
     $this->Instance()->assign($role_id_1, $perm_id_1);
     self::$rbac->Users->assign($role_id_1, 5);
     $result = $this->Instance()->remove($role_id_1, true);
     $dataSet = $this->getConnection()->createDataSet();
     $filterDataSet = new \PHPUnit_Extensions_Database_DataSet_DataSetFilter($dataSet);
     $filterDataSet->addIncludeTables(array($this->Instance()->tablePrefix() . 'rolepermissions', $this->Instance()->tablePrefix() . $this->type(), $this->Instance()->tablePrefix() . 'userroles'));
     $filterDataSet->setExcludeColumnsForTable($this->Instance()->tablePrefix() . 'rolepermissions', array('assignmentdate'));
     $filterDataSet->setExcludeColumnsForTable($this->Instance()->tablePrefix() . 'userroles', array('assignmentdate'));
     $expectedDataSet = $this->_dataSet($this->type() . '/expected_remove_recursive');
     $this->assertDataSetsEqual($expectedDataSet, $filterDataSet);
 }
示例#5
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);
 }
示例#6
0
 public function testPermissionsUnassignRoles()
 {
     $perm_id_1 = $this->Instance()->add($this->type() . '_1', $this->type() . ' Description 1');
     $role_id_1 = self::$rbac->Roles->add('roles_1', 'roles Description 1');
     $role_id_2 = self::$rbac->Roles->add('roles_2', 'roles Description 2');
     $role_id_3 = self::$rbac->Roles->add('roles_3', 'roles Description 3');
     $this->Instance()->assign($role_id_1, $perm_id_1);
     $this->Instance()->assign($role_id_2, $perm_id_1);
     $this->Instance()->assign($role_id_3, $perm_id_1);
     $result = $this->Instance()->unassignRoles($perm_id_1);
     $dataSet = $this->getConnection()->createDataSet();
     $filterDataSet = new \PHPUnit_Extensions_Database_DataSet_DataSetFilter($dataSet);
     $filterDataSet->addIncludeTables(array($this->Instance()->tablePrefix() . 'rolepermissions'));
     $filterDataSet->setExcludeColumnsForTable($this->Instance()->tablePrefix() . 'rolepermissions', array('assignmentdate'));
     $expectedDataSet = $this->_dataSet('/' . $this->type() . '/expected_unassign_roles');
     $this->assertDataSetsEqual($expectedDataSet, $filterDataSet);
 }
示例#7
0
 public function testReset()
 {
     $this->Instance()->add($this->type() . '_title_1', $this->type() . ' Description 1');
     $this->Instance()->add($this->type() . '_title_2', $this->type() . ' Description 2');
     $this->Instance()->add($this->type() . '_title_3', $this->type() . ' Description 3');
     $this->Instance()->reset(true);
     $dataSet = $this->getConnection()->createDataSet();
     $filterDataSet = new \PHPUnit_Extensions_Database_DataSet_DataSetFilter($dataSet);
     $filterDataSet->addIncludeTables(array($this->Instance()->tablePrefix() . $this->type()));
     $expectedDataSet = $this->_dataSet('base/expected_reset_' . $this->type());
     $this->assertDataSetsEqual($expectedDataSet, $filterDataSet);
 }