/** * @param NodeInterface $node * * @return NodeInterface */ public function flow(NodeInterface $node) { if (!$node instanceof FileNodeCollectionInterface) { throw new InvalidArgumentException("Node: {$node} should be an instance of FileNodeCollectionInterface"); } $each = new Each(new CopyFile($this->targetDirectory)); return $each->flow($node); }
public function testFlow() { $eachFlow = m::mock(FlowInterface::class); $flow = new Each($eachFlow); $node = m::mock(NodeInterface::class); $collection = new NodeCollection([$node]); $eachFlow->shouldReceive('flow')->with($node)->andReturn($node); $response = $flow->flow($collection); static::assertNotSame($response, $collection); static::assertEquals($collection->getAll(), $response->getAll()); static::assertInstanceOf(NodeCollectionInterface::class, $response); }