Ejemplo n.º 1
0
 public function testParseSimpleDocumentFromUri()
 {
     $handler = $this->getParserHandlerMock();
     $handler->expects($this->once())->method('start')->with('root', array());
     $handler->expects($this->once())->method('append')->with('content');
     $handler->expects($this->once())->method('end')->with('root');
     $stream = new Stream("<root>content</root>");
     $parser = new XmlParser();
     $parser->parse($stream->getUri(), $handler);
 }
Ejemplo n.º 2
0
 public function stat()
 {
     if ($this->content === false) {
         return false;
     }
     return parent::stat();
 }
Ejemplo n.º 3
0
 public function testWriteToUri()
 {
     $origin = new \stdClass();
     $definition = $this->getDefinitionMock();
     $definition->expects($this->once())->method('isScalar')->will($this->returnValue(true));
     $definition->expects($this->once())->method('getNodeName')->will($this->returnValue('scalar'));
     $definition->expects($this->once())->method('extract')->with($origin)->will($this->returnValue('foo'));
     $stream = new Stream();
     $writer = new XmlWriter();
     $writer->write($stream->getUri(), $origin, $definition);
     $this->assertXmlStringEqualsXmlString("<scalar>foo</scalar>", $stream->getContent());
 }
Ejemplo n.º 4
0
 /**
  * @param $start
  * @param $offset
  * @param $whence
  * @param $size
  * @param $tell
  *
  * @dataProvider provideSeekAndTell
  */
 public function testSeekAndTell($start, $offset, $whence, $size, $tell)
 {
     $stream = new Stream(str_repeat('X', $size));
     $stream->seek($start, SEEK_SET);
     $stream->seek($offset, $whence);
     $this->assertEquals($tell, $stream->tell());
 }