Esempio n. 1
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));
 }
Esempio n. 2
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());
 }