Exemplo n.º 1
0
 /**
  * Test a write that is shorter than the available data.
  *
  * @covers \Binary\Field\Text::write
  */
 public function testShortWrite()
 {
     $field = new Text();
     $field->setName('foo');
     $field->setSize($this->getMockedProperty(5));
     $dataSet = $this->getMock('\\Binary\\DataSet');
     $dataSet->expects($this->any())->method('getValue')->with($this->equalTo('foo'))->will($this->returnValue('abcdefg'));
     $stream = new StringStream('');
     $field->write($stream, $dataSet);
     $this->assertEquals('abcde', $stream->getString());
 }
Exemplo n.º 2
0
 public function testSimpleRead()
 {
     $field = new Text();
     $property = $this->getMockBuilder('\\Binary\\Field\\Property\\PropertyInterface')->getMock();
     $property->expects($this->any())->method('get')->will($this->returnValue(4));
     $field->setSize($property);
     $field->setName('foo');
     $stream = $this->getMock('\\Binary\\Stream\\StreamInterface');
     $stream->expects($this->any())->method('read')->will($this->returnValue('barr'));
     $dataSet = $this->getMock('\\Binary\\DataSet');
     $dataSet->expects($this->once())->method('setValue')->with($this->equalTo('foo'), $this->equalTo('barr'));
     $field->read($stream, $dataSet);
 }