/** * @test */ function it_adds_new_user_to_existing_table() { $taskListPosition = TaskListPosition::at(TaskListId::linkWith(NodeName::defaultName(), ProcessId::generate()), 1); $user = TestUser::fromNativeValue(['id' => null, 'name' => 'Jane Doe', 'age' => 32]); $message = WorkflowMessage::newDataCollected($user, 'test-case', 'localhost'); $message->connectToProcessTask($taskListPosition); $message = $message->prepareDataProcessing($taskListPosition, 'sql-connector'); $this->tableGateway->handleWorkflowMessage($message); $this->assertInstanceOf('Prooph\\Processing\\Message\\WorkflowMessage', $this->messageReceiver->getLastReceivedMessage()); $query = $this->getDbalConnection()->createQueryBuilder(); $userResultSet = $query->select('*')->from(self::TEST_TABLE)->execute()->fetchAll(); $this->assertEquals(4, count($userResultSet)); $expectedUsers = [['id' => '1', 'name' => 'John Doe', 'age' => '34'], ['id' => '2', 'name' => 'Max Mustermann', 'age' => '41'], ['id' => '3', 'name' => 'Donald Duck', 'age' => '57'], ['id' => '4', 'name' => 'Jane Doe', 'age' => '32']]; $this->assertEquals($expectedUsers, $userResultSet); }
/** * Returns the prototype of the items type * * A collection has always one property with name item representing the type of all items in the collection. * * @return Prototype */ public static function itemPrototype() { return TestUser::prototype(); }