Ejemplo n.º 1
0
 public function update($id, $data)
 {
     unset($data['id']);
     $regenerateTypes = isset($data['regenerate_type']) ? (bool) $data['regenerate_type'] : false;
     unset($data['regenerate_type']);
     $this->tableConnectorGenerator->updateConnector($id, $data, $regenerateTypes);
     $data['id'] = $id;
     return $data;
 }
 /**
  * @test
  */
 function it_adds_a_new_connector_and_generates_table_types()
 {
     $connectorData = ['dbal_connection' => 'test_db', 'table' => 'test_data', 'name' => 'Test Db Data'];
     $this->tableConnectorGenerator->addConnector(SqlConnectorTranslator::generateConnectorId(), $connectorData);
     $expectedRowClassString = file_get_contents(getcwd() . "/SqlConnector/Mock/TestData.php");
     $expectedCollectionClassString = file_get_contents(getcwd() . "/SqlConnector/Mock/TestDataCollection.php");
     $pathToGeneratedRowFile = sys_get_temp_dir() . "/SqlConnector/TestDb/TestData.php";
     $pathToGeneratedCollectionFile = sys_get_temp_dir() . "/SqlConnector/TestDb/TestDataCollection.php";
     $generatedRowClassString = file_get_contents($pathToGeneratedRowFile);
     $generatedCollectionClassString = file_get_contents($pathToGeneratedCollectionFile);
     $this->assertEquals($expectedRowClassString, $generatedRowClassString);
     $this->assertEquals($expectedCollectionClassString, $generatedCollectionClassString);
     /** @var $lastMessage AddConnectorToConfig */
     $lastMessage = $this->commandBus->getLastMessage();
     $this->assertInstanceOf('Prooph\\Link\\Application\\Command\\AddConnectorToConfig', $lastMessage);
     $this->assertTrue(strpos($lastMessage->connectorId(), "sqlconnector:::") === 0);
     $this->assertEquals('Test Db Data', $lastMessage->connectorName());
     $this->assertEquals([MessageNameUtils::COLLECT_DATA, MessageNameUtils::PROCESS_DATA], $lastMessage->allowedMessage());
     $this->assertEquals(['Prooph\\Link\\Application\\DataType\\SqlConnector\\TestDb\\TestData', 'Prooph\\Link\\Application\\DataType\\SqlConnector\\TestDb\\TestDataCollection'], $lastMessage->allowedTypes());
     $this->assertEquals(['dbal_connection' => 'test_db', 'table' => 'test_data', 'icon' => TableConnectorGenerator::ICON, 'ui_metadata_riot_tag' => TableConnectorGenerator::METADATA_UI_KEY], $lastMessage->additionalData());
 }