Esempio n. 1
0
 public function testSetValue()
 {
     $this->structure->expects($this->any())->method('hasField')->with($this->equalTo('fieldName'))->willReturn(true);
     $this->records[0]->expects($this->any())->method('setValue')->with($this->equalTo('fieldName'), $this->equalTo('default'));
     $this->records[1]->expects($this->any())->method('setValue')->with($this->equalTo('fieldName'), $this->equalTo('default'));
     $this->records[2]->expects($this->any())->method('setValue')->with($this->equalTo('fieldName'), $this->equalTo('default'));
     $this->recordCollection->setValue('fieldName', 'default');
 }
Esempio n. 2
0
 /**
  * Set column data
  *
  * @param string $columnName
  * @param mixed $value
  * @return $this
  * @throws Exception
  */
 public function setValue($columnName, $value)
 {
     if ($this->structure && !$this->structure->hasField($columnName)) {
         throw new Exception("Collection Structure does not contain field {$columnName}");
     }
     foreach ($this->data as $item) {
         $item->setValue($columnName, $value);
     }
     return $this;
 }
Esempio n. 3
0
 public function testIntegrityFieldFail()
 {
     $this->ratings = new Ratings($this->destination, $this->logger, $this->progress, 'integrity');
     $this->progress->expects($this->once())->method('start')->with(1);
     $this->progress->expects($this->once())->method('advance');
     $this->progress->expects($this->never())->method('finish');
     $this->destination->expects($this->once())->method('getDocumentList')->willReturn(['rating', 'rating_store']);
     $this->structure->expects($this->once())->method('getFields')->willReturn(['field' => []]);
     $this->document->expects($this->once())->method('getStructure')->willReturn($this->structure);
     $this->destination->expects($this->once())->method('getDocument')->with('rating')->willReturn($this->document);
     $this->logger->expects($this->once())->method('error')->with('Integrity check failed due to "is_active" field does not exist in "rating" document of ' . 'the destination resource');
     $this->assertFalse($this->ratings->perform());
 }
Esempio n. 4
0
 /**
  * @return array
  * @throws Exception
  */
 public function getFields()
 {
     if (empty($this->structure)) {
         throw new Exception("Structure not set");
     }
     return array_keys($this->structure->getFields());
 }
Esempio n. 5
0
 public function testNotHasField()
 {
     $this->assertFalse($this->structure->hasField('new_name'));
 }
 /**
  * @expectedException \Migration\Exception
  * @expectedExceptionMessage Record structure does not match provided Data
  */
 public function testSetDataWithException()
 {
     $this->structure->expects($this->any())->method('getFields')->willReturn(['id', 'name']);
     $this->record->setStructure($this->structure);
     $this->record->setData(['id' => 11, 'wrongName' => 'item2']);
 }