Exemplo n.º 1
0
 function test_sample()
 {
     $this->assertEquals(Info::take()->post_type, "info");
     $this->assertCount(10, Test\Event::fetch("posts_per_page=10"));
     foreach (Event::where("posts_per_page=3") as $item) {
         $this->assertInstanceOf("Test\\Event", $item);
     }
     $this->assertEquals(Event::take()->post_status, "publish");
     $this->assertEquals(Event::take()->post_type, "event");
 }
Exemplo n.º 2
0
 function test_errors()
 {
     try {
         Event::find(99999);
     } catch (Artovenry\Wp\Error $e) {
         $this->assertInstanceOf("Artovenry\\Wp\\CustomPost\\Error", $e);
         $this->assertInstanceOf("Artovenry\\Wp\\CustomPost\\RecordNotFound", $e);
     }
     try {
         $event = Event::take();
         $event->set_meta("hogehoge", 10);
     } catch (Artovenry\Wp\Error $e) {
         $this->assertInstanceOf("Artovenry\\Wp\\CustomPost\\AttributeNotDefined", $e);
     }
     try {
         $event = Event::take();
         $event->set_meta("scheduled_on", []);
     } catch (Artovenry\Wp\Error $e) {
         $this->assertInstanceOf("Artovenry\\Wp\\CustomPost\\TypeIsNotScalar", $e);
     }
 }