private function getTestObject()
 {
     $post = new BlogPost('FooooooooooooooooooooooBAR', new Author('Foo'), new \DateTime());
     for ($i = 0; $i < 10; $i++) {
         $post->addComment(new Comment(new Author('foo'), 'foobar'));
     }
     return $post;
 }
Example #2
0
 public function testBlogPost()
 {
     $post = new BlogPost('This is a nice title.', $author = new Author('Foo Bar'), new \DateTime('2011-07-30 00:00', new \DateTimeZone('UTC')), new Publisher('Bar Foo'));
     $post->addComment($comment = new Comment($author, 'foo'));
     $this->assertEquals($this->getContent('blog_post'), $this->serialize($post));
     if ($this->hasDeserializer()) {
         $deserialized = $this->deserialize($this->getContent('blog_post'), get_class($post));
         $this->assertEquals('2011-07-30T00:00:00+0000', $this->getField($deserialized, 'createdAt')->format(\DateTime::ISO8601));
         $this->assertAttributeEquals('This is a nice title.', 'title', $deserialized);
         $this->assertAttributeSame(false, 'published', $deserialized);
         $this->assertAttributeSame('1edf9bf60a32d89afbb85b2be849e3ceed5f5b10', 'etag', $deserialized);
         $this->assertAttributeEquals(new ArrayCollection(array($comment)), 'comments', $deserialized);
         $this->assertAttributeEquals(new Sequence(array($comment)), 'comments2', $deserialized);
         $this->assertAttributeEquals($author, 'author', $deserialized);
     }
 }