Пример #1
0
 public function provideStringCollection()
 {
     $string1 = String::fromNativeValue("Processing");
     $string2 = String::fromNativeValue("Workflow");
     $string3 = String::fromNativeValue("Framework");
     $stringCollection = StringCollection::fromNativeValue([$string1, $string2, $string3]);
     return [[$stringCollection]];
 }
Пример #2
0
 public function provideStringCollection()
 {
     $string1 = String::fromNativeValue("Processing");
     $string2 = String::fromNativeValue("Workflow");
     $string3 = String::fromNativeValue("Framework");
     $string4 = String::fromNativeValue("Prooph");
     $string5 = String::fromNativeValue("Link");
     $string6 = String::fromNativeValue("Application");
     $stringCollection = StringCollection::fromNativeValue([$string1, $string2, $string3, $string4, $string5, $string6]);
     return [[$stringCollection]];
 }
Пример #3
0
 /**
  * @test
  */
 public function it_applies_premap_callback_to_payload_collection()
 {
     $stringCollection = ["a string", 100, "yet another string"];
     $collection = StringCollection::fromNativeValue($stringCollection);
     $payload = Payload::fromType($collection);
     $string_cast = Func::prepare('premap', null, function ($item, $key, \Iterator $collection) {
         return (string) $item;
     });
     $string_cast($payload);
     $this->assertEquals(["a string", "100", "yet another string"], $payload->extractTypeData());
 }
Пример #4
0
 /**
  * @test
  */
 public function it_returns_item_property_if_requested()
 {
     $stringCol = StringCollection::fromNativeValue(array("Apple", "Banana"));
     $this->assertEquals('Prooph\\Processing\\Type\\String', $stringCol->property('item')->value());
     $this->assertNull($stringCol->property('Apple'));
 }
 /**
  * @test
  */
 public function it_writes_each_string_of_the_collection_to_a_separate_file_and_the_value_is_available_in_the_filename_template_to_create_unique_file_names()
 {
     $taskListPosition = TaskListPosition::at(TaskListId::linkWith(NodeName::defaultName(), ProcessId::generate()), 1);
     $strings = StringCollection::fromNativeValue(["first", "second", "third"]);
     $metadata = [FileGateway::META_FILE_TYPE => 'json', FileGateway::META_PATH => $this->tempPath, FileGateway::META_FILENAME_TEMPLATE => 'string-{{value}}.json', FileGateway::META_WRITE_MULTI_FILES => true];
     $this->tempFiles[] = 'string-first.json';
     $this->tempFiles[] = 'string-second.json';
     $this->tempFiles[] = 'string-third.json';
     $workflowMessage = WorkflowMessage::newDataCollected($strings, NodeName::defaultName()->toString(), 'file-connector');
     $workflowMessage->connectToProcessTask($taskListPosition);
     $workflowMessage = $workflowMessage->prepareDataProcessing($taskListPosition, NodeName::defaultName()->toString(), $metadata);
     $this->fileGateway->handleWorkflowMessage($workflowMessage);
     $this->assertInstanceOf('Prooph\\Processing\\Message\\WorkflowMessage', $this->messageReceiver->getLastReceivedMessage());
     $this->assertTrue(file_exists($this->tempPath . $this->tempFiles[0]));
     $this->assertTrue(file_exists($this->tempPath . $this->tempFiles[1]));
     $this->assertTrue(file_exists($this->tempPath . $this->tempFiles[2]));
     $second = json_decode(file_get_contents($this->tempPath . $this->tempFiles[1]));
     $this->assertEquals('second', $second);
 }