/**
  * Test diff item factory.
  */
 public function testCreateDefaultCase()
 {
     $diffItemFactory = new DiffItemFactory();
     $this->assertEquals(new CreateDiffItem(), $diffItemFactory->create(ActionTypes::CREATE));
     $this->assertEquals(new UpdateDiffItem(), $diffItemFactory->create(ActionTypes::UPDATE));
     $this->assertEquals(new DeleteDiffItem(), $diffItemFactory->create(ActionTypes::DELETE));
     $this->setExpectedException('InvalidArgumentException');
     $diffItemFactory->create(null);
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function current()
 {
     $buffer = $this->binlogParser->current();
     $type = $buffer[BinlogParser::PARAM_QUERY]['type'];
     $diffItem = DiffItemFactory::create($type);
     $diffItem->setTimestamp($buffer[BinlogParser::PARAM_DATE]);
     $diffItem->setDiffId($buffer[BinlogParser::PARAM_POSITION]);
     $diffItem->setCategory($buffer[BinlogParser::PARAM_QUERY]['table']);
     $mapping = $this->getTableMapping($diffItem->getCategory());
     if (isset($buffer[BinlogParser::PARAM_QUERY]['where'])) {
         $diffItem->setWhereParams($this->applyMapping($buffer[BinlogParser::PARAM_QUERY]['where'], $mapping));
     }
     if (isset($buffer[BinlogParser::PARAM_QUERY]['set'])) {
         $diffItem->setSetParams($this->applyMapping($buffer[BinlogParser::PARAM_QUERY]['set'], $mapping));
     }
     return $diffItem;
 }