Exemple #1
0
    public function testBinary()
    {
        $stream = new Object();
        $stream->setUrl('http://example.org/my_binary.mp3');
        $binary = new Binary();
        $binary->setCompression('deflate');
        $binary->setData('dGhpcyBpcyB1bmNvbXByZXNzZWQgZGF0YQo=');
        $binary->setFileUrl('foo.txt');
        $binary->setLength(25);
        $binary->setMd5('827ae7e1ab45e4dd591d087c741e5770');
        $binary->setMimeType('text/plain');
        $object = new Object();
        $object->setObjectType('note');
        $object->setDisplayName('A note with a binary attachment');
        $object->setAttachments(array($binary));
        $content = <<<JSON
  {
    "objectType": "note",
    "displayName": "A note with a binary attachment",
    "attachments": [
\t  {
\t    "objectType": "binary",
\t    "compression": "deflate",
\t    "data": "dGhpcyBpcyB1bmNvbXByZXNzZWQgZGF0YQo=",
\t    "fileUrl": "foo.txt",
\t    "length": 25,
\t    "md5": "827ae7e1ab45e4dd591d087c741e5770",
\t    "mimeType": "text/plain"
\t  }
    ]
  }
JSON;
        $this->assertRecordEqualsContent($object, $content);
        $this->assertEquals('deflate', $binary->getCompression());
        $this->assertEquals('dGhpcyBpcyB1bmNvbXByZXNzZWQgZGF0YQo=', $binary->getData());
        $this->assertEquals('foo.txt', $binary->getFileUrl());
        $this->assertEquals(25, $binary->getLength());
        $this->assertEquals('827ae7e1ab45e4dd591d087c741e5770', $binary->getMd5());
        $this->assertEquals('text/plain', $binary->getMimeType());
    }