Jarves\Tests\REST\BasicTest::testAdd PHP Method

testAdd() public method

public testAdd ( )
    public function testAdd()
    {
        ItemQuery::create()->deleteAll();
        $item1 = new Item();
        $item1->setTitle('Item 1');
        $item1->save();
        $id = $item1->getId();
        $response = $this->restCall('/jarves/object/test/item/' . $id);
        $this->assertEquals('Item 1', $response['data']['title']);
        $response = $this->restCall('/jarves/object/test/item/', 'POST', array('title' => 'Item 2'));
        $this->assertEquals(200, $response['status']);
        $this->assertEquals($id + 1, $response['data']['id'] + 0);
        //did we really inserted it?
        $response = $this->restCall('/jarves/object/test/item/' . $response['data']['id']);
        $this->assertEquals($id + 1, $response['data']['id'] + 0);
    }