Пример #1
0
 /**
  * @param mixed $value
  */
 protected function setValue($value)
 {
     //We use the string assertion first
     parent::setValue($value);
     //and then check, if we really got an item class
     Assertion::implementsInterface($value, 'Prooph\\Processing\\Type\\Type');
 }
Пример #2
0
 public function provideStringCollection()
 {
     $string1 = String::fromNativeValue("Processing");
     $string2 = String::fromNativeValue("Workflow");
     $string3 = String::fromNativeValue("Framework");
     $stringCollection = StringCollection::fromNativeValue([$string1, $string2, $string3]);
     return [[$stringCollection]];
 }
Пример #3
0
 /**
  * @test
  */
 function it_can_be_set_up_from_array()
 {
     $task = ManipulatePayload::with(__DIR__ . '/../../Mock/manipulation/append_world.php');
     $taskData = $task->getArrayCopy();
     $copiedTask = ManipulatePayload::reconstituteFromArray($taskData);
     $payload = Payload::fromType(String::fromNativeValue('Hello'));
     $copiedTask->performManipulationOn($payload);
     $this->assertEquals('Hello World', $payload->extractTypeData());
 }
Пример #4
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]];
 }
Пример #5
0
 /**
  * @test
  */
 public function it_constructs_collection_from_json_decoded_value()
 {
     $fruits = StringCollection::fromNativeValue(array("Apple", String::fromNativeValue("Banana"), "Strawberry"));
     $jsonString = json_encode($fruits);
     $decodedJson = json_decode($jsonString);
     $decodedFruits = StringCollection::fromJsonDecodedData($decodedJson);
     $fruitList = array();
     foreach ($decodedFruits->value() as $fruit) {
         $fruitList[] = $fruit->value();
     }
     $this->assertEquals(array("Apple", "Banana", "Strawberry"), $fruitList);
 }
 /**
  * @test
  */
 function it_can_be_converted_to_array_and_back()
 {
     $processingTypes = ProcessingTypes::support([String::prototype(), Integer::prototype()]);
     $definition = $processingTypes->toArray();
     $copiedProcessingTypes = ProcessingTypes::fromArray($definition);
     $this->assertTrue($copiedProcessingTypes->isSupported(String::prototype()));
     $this->assertTrue($copiedProcessingTypes->isSupported(Integer::prototype()));
     $this->assertFalse($copiedProcessingTypes->isSupported(Float::prototype()));
     $allProcessingTypes = ProcessingTypes::supportAll();
     $definition = $allProcessingTypes->toArray();
     $copiedProcessingTypes = ProcessingTypes::fromArray($definition);
     $this->assertTrue($copiedProcessingTypes->isSupported(Float::prototype()));
 }
Пример #7
0
 /**
  * @return array[propertyName => Prototype]
  */
 public static function getPropertyPrototypes()
 {
     return array('id' => Integer::prototype(), 'name' => String::prototype(), 'address' => SourceAddress::prototype());
 }
Пример #8
0
 /**
  * @test
  */
 function it_creates_linear_messaging_process_with_manipulate_payload_task_from_definition()
 {
     $definition = ["process_type" => Definition::PROCESS_LINEAR_MESSAGING, "tasks" => [["task_type" => Definition::TASK_MANIPULATE_PAYLOAD, 'manipulation_script' => __DIR__ . '/../Mock/manipulation/append_world.php']]];
     $processFactory = new ProcessFactory();
     $process = $processFactory->createProcessFromDefinition($definition, NodeName::defaultName());
     $this->assertInstanceOf('Prooph\\Processing\\Processor\\LinearProcess', $process);
     $message = WorkflowMessage::newDataCollected(String::fromString('Hello'), 'test-case', NodeName::defaultName());
     $process->perform($this->workflowEngine, $message);
     $this->assertTrue($process->isSuccessfulDone());
     $this->assertEquals('Hello World', $message->payload()->extractTypeData());
 }
Пример #9
0
 /**
  * @return array[propertyName => Prototype]
  */
 public static function getPropertyPrototypes()
 {
     return ['id' => IntegerOrNull::prototype(), 'name' => String::prototype(), 'age' => Integer::prototype()];
 }
Пример #10
0
 /**
  * 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 String::prototype();
 }
Пример #11
0
 /**
  * @test
  */
 function it_manipulates_data_of_payload_with_callback()
 {
     $addWorld = Func::prepare('manipulate', null, function ($string) {
         return $string . ' World';
     });
     $payload = Payload::fromType(String::fromNativeValue('Hello'));
     $addWorld($payload);
     $this->assertEquals('Hello World', $payload->extractTypeData());
 }
Пример #12
0
 /**
  * @return array[propertyName => Prototype]
  */
 public static function getPropertyPrototypes()
 {
     return array('street' => String::prototype(), 'streetNumber' => Integer::prototype(), 'zip' => String::prototype(), 'city' => String::prototype());
 }
Пример #13
0
 /**
  * @return array[propertyName => Prototype]
  */
 public static function getPropertyPrototypes()
 {
     return ['name' => \Prooph\Processing\Type\String::prototype(), 'age' => \Prooph\Processing\Type\Integer::prototype(), 'created_at' => \Prooph\Processing\Type\DateTime::prototype(), 'price' => \Prooph\Processing\Type\Float::prototype(), 'active' => \Prooph\Processing\Type\Boolean::prototype()];
 }
Пример #14
0
 /**
  * @return array[propertyName => Prototype]
  */
 public static function getPropertyPrototypes()
 {
     return ['ean' => String::prototype(), 'name' => String::prototype(), 'price' => Integer::prototype(), 'currency' => String::prototype()];
 }
Пример #15
0
 /**
  * @test
  */
 function it_is_equal_to_a_similar_message()
 {
     $message1 = Message::emulateProcessingWorkflowMessage(MessageType::collectData(), String::prototype(), ProcessingMetadata::fromArray(['meta' => 'data']));
     $message2 = Message::emulateProcessingWorkflowMessage(MessageType::collectData(), String::prototype(), ProcessingMetadata::fromArray(['meta' => 'data']));
     $this->assertTrue($message1->equals($message2));
 }
Пример #16
0
 /**
  * @test
  * @expectedException \Prooph\Processing\Type\Exception\InvalidTypeException
  */
 public function it_only_allows_utf8_encoded_string()
 {
     $nonUtf8 = mb_convert_encoding("Ü", "ISO-8859-1", "UTF-8");
     String::fromString($nonUtf8);
 }