Exemplo n.º 1
0
 public function getAsComment()
 {
     $comment = new Comment();
     $comment->setText($this->getText());
     $comment->setDate($this->getDate());
     $comment->setCommenter($this->getCommenter());
     return $comment;
 }
Exemplo n.º 2
0
 public static function create($text, Commenter $c, Post $p)
 {
     $comment = new Comment();
     $comment->setText($text);
     $comment->setCommenter($c);
     $comment->setPost($p);
     return $comment;
 }
Exemplo n.º 3
0
 public function __construct()
 {
     parent::__construct();
     $this->text = 'Fixtures truly are gnarly!';
     $this->commenter_name = 'Brian Scaturro';
     $this->commenter_email = '*****@*****.**';
     $this->commenter_url = 'http://brianscaturro.com';
 }
Exemplo n.º 4
0
 public function __construct()
 {
     parent::__construct();
     $this->id = 1;
     $this->text = 'Great post!';
     $this->date = \DateTime::createFromFormat('m/d/Y', '06/20/1986');
     $this->commenter_name = 'Brian Scaturro';
     $this->commenter_email = '*****@*****.**';
     $this->commenter_url = 'http://brianscaturro.com';
 }
 public function __construct()
 {
     parent::__construct();
     $this->id = 2;
     $this->text = '<h1>Greetings</h1> there blogger! Click <a href="#">here</a> for more info!!! It is going to be <strong>great!</strong>';
     $this->date = \DateTime::createFromFormat('m/d/Y', '06/20/1987');
     $this->commenter_name = 'Comment Guy';
     $this->commenter_email = '*****@*****.**';
     $this->commenter_url = 'http://commentguy.com';
 }
 public function isNew()
 {
     $this->__load();
     return parent::isNew();
 }
Exemplo n.º 7
0
    $user = $userRepo->get($id);
    if ($user) {
        $app->render('user_posts.phtml', ['user' => $user]);
    } else {
        $app->render('notfound.phtml', ['message' => 'Could not find the user you were looking for'], 404);
    }
});
$app->get('/posts/:id', function ($id) use($app, $postRepo) {
    $post = $postRepo->get($id);
    if ($post) {
        $app->render('single_post.phtml', ['post' => $post]);
    } else {
        $app->render('notfound.phtml', ['message' => 'Could not find the post you were looking for']);
    }
});
$app->post('/posts/:id', function ($pid) use($app, $postRepo, $commentRepo) {
    $post = $postRepo->get($pid);
    $input = new Input\Comment($app->request()->post('comment'));
    $comment = null;
    if ($input->isValid()) {
        $comment = Entities\Comment::create($input->text, new Domain\Commenter($input->commenter_name, $input->commenter_email, $input->commenter_url), $post);
        $sanitizer = new Domain\CommentSanitizer($comment);
        $comment->setText($sanitizer->sanitize());
        $commentRepo->store($comment);
    }
    $app->render('single_post.phtml', ['post' => $post, 'comment' => $input]);
});
$app->get('/users', function () use($app, $userRepo) {
    $users = $userRepo->getAll();
    $app->render('users.phtml', ['users' => $users]);
});
Exemplo n.º 8
0
 public function test_create_method_creates_new_comment()
 {
     $commenter = new Commenter("A", "B", "C");
     $post = new Post();
     $date = new \DateTime('now');
     $comment = Comment::create("text", $commenter, $post);
     $this->assertEquals("text", $comment->getText());
     $this->assertEquals($date, $comment->getDate());
     $this->assertEquals($commenter, $comment->getCommenter());
     $this->assertSame($post, $comment->getPost());
 }