Esempio n. 1
0
 /**
  * Adds a post
  *
  * @param \SplFileObject $file Post file object
  */
 protected function addPost(\SplFileObject $file)
 {
     $post = new Post($file);
     if (!array_key_exists($post->year(), $this->posts)) {
         $this->posts[$post->year()] = [];
     }
     if (!array_key_exists($post->month(), $this->posts[$post->year()])) {
         $this->posts[$post->year()][$post->month()] = [];
     }
     $this->posts[$post->year()][$post->month()][] = $post;
 }
Esempio n. 2
0
 /**
  * testPost
  *
  * @return void
  */
 public function testPost()
 {
     $filepath = TEST_APP . DS . 'views' . DS . '2012' . DS . '01' . DS . 'post.md';
     $file = new \SplFileObject($filepath);
     $Post = new Post($file);
     $this->assertEquals('2012', $Post->year());
     $this->assertEquals('01', $Post->month());
     $this->assertEquals('Post', $Post->title());
     $this->assertEquals('post', $Post->slug());
     $this->assertEquals($file, $Post->source());
     $link = $Post->link();
     $this->assertRegExp('/<a/', $link);
     $this->assertRegExp('/href=\\"\\/2012\\/01\\/post\\.html\\"/', $link);
     $filepath = TEST_APP . DS . 'views' . DS . '2012' . DS . '01' . DS . 'post.html';
     $file = new \SplFileObject($filepath);
     $Post = new Post($file);
     $this->assertEquals('Post', $Post->title());
     $this->assertEquals('post', $Post->slug());
 }