Beispiel #1
0
 /**
  * @depends testWPPostData 
  */
 public function testWPPostModify()
 {
     if (self::$wp->isLogged()) {
         $posts = self::$blog->getPosts("post", "draft", 3);
         $this->assertSame($posts->getLength(), 3);
         foreach ($posts as $id => $post) {
             $this->assertTrue(in_array(intval($id), self::$ids));
             $i = intval($post->getCustomField("test_custom_field"));
             $post->setTitle("Ready to be deleted");
             if ($i > 0) {
                 $parent = new \Comodojo\WPAPI\WPPost(self::$blog);
                 $parent->loadFromID(self::$ids[$i - 1]);
                 $post->setParent($parent);
             }
             $post->setStatus("publish")->cleanCustomFields()->removeCategory("wptest")->removeTag("wpapi")->save();
             $parent = $post->getParent();
             if (!is_null($parent)) {
                 $this->assertTrue(in_array($parent->getID(), self::$ids));
             }
             $this->assertSame($post->getStatus(), "publish");
             $this->assertFalse($post->hasCategory("wptest"));
             $this->assertFalse($post->hasTag("wpapi"));
             $this->assertFalse($post->hasCustomField("test_custom_field"));
         }
     }
 }