Пример #1
0
 /**
  * @expectedException \Dive\Hydrator\HydratorException
  */
 public function testFindOrCreateRecordByUniqueKeyFindsMoreRecordsThrowsException()
 {
     $this->givenIHaveARecordManager();
     $this->givenIHaveAUniqueConstraintTestTable();
     $recordOneData = array('single_unique' => 'test', 'single_unique_null_constrained' => 'test', 'composite_unique1' => 'test', 'composite_unique2' => 'test', 'composite_unique_null_constrained1' => 'test', 'composite_unique_null_constrained2' => 'test');
     $this->givenIHaveARecordStoredWithData($recordOneData);
     $recordTwoData = array('single_unique' => '123', 'single_unique_null_constrained' => '123', 'composite_unique1' => '123', 'composite_unique2' => '123', 'composite_unique_null_constrained1' => '123', 'composite_unique_null_constrained2' => '123');
     $this->givenIHaveARecordStoredWithData($recordTwoData);
     // record data will join the data of unique data from two records, so it can not be found be its unique keys
     $recordData = array();
     foreach ($this->table->getFieldNames() as $fieldName) {
         if (strpos($fieldName, 'single_unique_') === 0) {
             $recordData[$fieldName] = $recordOneData[$fieldName];
         } else {
             if (isset($recordTwoData[$fieldName])) {
                 $recordData[$fieldName] = $recordTwoData[$fieldName];
             }
         }
     }
     $this->whenIFindOrCreateTheRecordWithData($recordData);
 }