Ejemplo n.º 1
0
 public function __construct()
 {
     parent::__construct();
     $this->title = 'How To Use Test Fixtures';
     $this->excerpt = 'Test fixtures are really helpful.';
     $this->content = 'Just use fixtures. You will not regret it';
 }
 public function __construct()
 {
     parent::__construct();
     $this->id = 1;
     $this->title = 'Unit Testing Is Gnarly';
     $this->excerpt = 'A short summary.';
     $this->content = 'This is post content';
     $this->date = \DateTime::createFromFormat('m/d/Y', '06/20/1986');
 }
Ejemplo n.º 3
0
 public function getAsPost()
 {
     $post = new Post();
     $post->setTitle($this->getTitle());
     $post->setExcerpt($this->getExcerpt());
     $post->setContent($this->getContent());
     $post->setDate($this->getDate());
     return $post;
 }
Ejemplo n.º 4
0
 public static function create($title, $content, $excerpt, User $user)
 {
     $post = new Post();
     $post->setTitle($title);
     $post->setContent($content);
     $post->setExcerpt($excerpt);
     $post->setUser($user);
     return $post;
 }
 public function isNew()
 {
     $this->__load();
     return parent::isNew();
 }
Ejemplo n.º 6
0
 public function test_create_method_creates_new_post()
 {
     $user = new User();
     $date = new \DateTime("now");
     $post = Post::create("title", "content", "excerpt", $user);
     $this->assertEquals("title", $post->getTitle());
     $this->assertEquals("excerpt", $post->getExcerpt());
     $this->assertEquals("content", $post->getContent());
     $this->assertSame($user, $post->getUser());
     $this->assertEquals($date, $post->getDate());
 }
Ejemplo n.º 7
0
<?php

use Domain\Entities;
use Presentation\Models\Input;
use Infrastructure\Persistence\Doctrine\PostRepository;
$authService->addRoute('/^\\/admin.*/');
$postRepo = new PostRepository();
$app->get('/admin/post', function () use($app, $postRepo, $authService) {
    $app->render('add_post.phtml', ['user_posts' => $postRepo->getBy(['user' => $authService->getLoggedInUser('superblorg')])]);
});
$app->post('/admin/post', function () use($app, $authService, $postRepo) {
    $input = new Input\Post($app->request()->post('post'));
    $user = $authService->getLoggedInUser('superblorg');
    $post = Entities\Post::create($input->title, $input->content, $input->excerpt, $user);
    if ($input->isValid()) {
        $postRepo->store($post);
    }
    $app->render('add_post.phtml', ['post' => $input, 'user_posts' => $postRepo->getBy(['user' => $user]), 'saved' => $post]);
});
Ejemplo n.º 8
0
 public function setPost(Post $post)
 {
     $post->addComment($this);
     $this->post = $post;
 }