/** * @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'); }
public function provideStringCollection() { $string1 = String::fromNativeValue("Processing"); $string2 = String::fromNativeValue("Workflow"); $string3 = String::fromNativeValue("Framework"); $stringCollection = StringCollection::fromNativeValue([$string1, $string2, $string3]); return [[$stringCollection]]; }
/** * @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()); }
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]]; }
/** * @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())); }
/** * @return array[propertyName => Prototype] */ public static function getPropertyPrototypes() { return array('id' => Integer::prototype(), 'name' => String::prototype(), 'address' => SourceAddress::prototype()); }
/** * @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()); }
/** * @return array[propertyName => Prototype] */ public static function getPropertyPrototypes() { return ['id' => IntegerOrNull::prototype(), 'name' => String::prototype(), 'age' => Integer::prototype()]; }
/** * 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(); }
/** * @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()); }
/** * @return array[propertyName => Prototype] */ public static function getPropertyPrototypes() { return array('street' => String::prototype(), 'streetNumber' => Integer::prototype(), 'zip' => String::prototype(), 'city' => String::prototype()); }
/** * @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()]; }
/** * @return array[propertyName => Prototype] */ public static function getPropertyPrototypes() { return ['ean' => String::prototype(), 'name' => String::prototype(), 'price' => Integer::prototype(), 'currency' => String::prototype()]; }
/** * @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)); }
/** * @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); }