コード例 #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);
 }
コード例 #2
0
 /**
  *
  */
 public function testAppend()
 {
     $initial = 'hello';
     $string = ' world';
     $stream = new Stream($initial);
     $fh = fopen($stream->getUri(), 'a');
     $written = fwrite($fh, $string);
     $written += fwrite($fh, $string);
     $written += fwrite($fh, $string);
     fclose($fh);
     $this->assertEquals($initial . $string . $string . $string, $stream->getContent());
     $this->assertEquals($written, 3 * strlen($string));
 }
コード例 #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());
 }