示例#1
0
 protected function setUp()
 {
     $this->Message = $this->getMockForAbstractClass('\\BLW\\Type\\MIME\\AMessage');
     $this->Head = $this->getMockForAbstractClass('\\BLW\\Type\\MIME\\IHead');
     $this->Body = $this->getMockForAbstractClass('\\BLW\\Type\\MIME\\IBody');
     $this->Head->expects($this->any())->method('__toString')->will($this->returnValue("Head\r\n"));
     $this->Body->expects($this->any())->method('__toString')->will($this->returnValue("Body\r\n"));
     $Property = new ReflectionProperty($this->Message, '_Head');
     $Property->setAccessible(true);
     $Property->setValue($this->Message, $this->Head);
     $Property = new ReflectionProperty($this->Message, '_Body');
     $Property->setAccessible(true);
     $Property->setValue($this->Message, $this->Body);
 }
示例#2
0
 /**
  * @depends test_construct
  * @covers ::getHeader
  */
 public function test_getHeader()
 {
     $this->Head[] = new GenericHeader('Foo', 'bar');
     $this->Head['Bar'] = 'bar';
     $this->assertInstanceOf('\\BLW\\Type\\MIME\\IHeader', $this->Head->getHeader('Foo'), 'IHead::getHeader() Should return an instance of IHeader');
     $this->assertSame('bar', $this->Head->getHeader('Bar'), 'IHead::getHeader() Should return `bar`');
     $this->assertFalse($this->Head->getHeader(new \SplFileInfo(__FILE__)), 'IHead::getHeader() should return FALSE');
     # Invalid argument
     try {
         $this->Head->getHeader(null);
         $this->fail('Failed to generate exception with invalid arguments');
     } catch (InvalidArgumentException $e) {
     }
 }
示例#3
0
    /**
     * @depends test_construct
     * @covers ::__toString
     */
    public function test_toString()
    {
        $Expected = <<<EOT
Mock Header: foo
Mock Header: foo
Mock Header: foo
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="%s"


EOT;
        $this->assertEquals(sprintf($Expected, $this->Head->getSection()->getBoundary()), @strval($this->Head), '(string) Head returned an invalid format');
    }