Jarves\Tests\Service\Object\WorkspacesTest::testThroughCoreObjectWrapper PHP Method

testThroughCoreObjectWrapper() public method

    public function testThroughCoreObjectWrapper()
    {
        $this->markTestSkipped('Workspaces are not yet supported.');
        $this->getObjects()->clear('JarvesPublicationBundle:News');
        $count = $this->getObjects()->getCount('JarvesPublicationBundle:News');
        $this->assertEquals(0, $count);
        $id11 = 0;
        for ($i = 1; $i <= 50; $i++) {
            $values = array('title' => 'News ' . $i, 'intro' => str_repeat('L', $i), 'lang' => 'en', 'newsDate' => strtotime('+' . rand(1, 30) . ' day' . '+' . rand(1, 24) . ' hours'));
            $pk = $this->getObjects()->add('JarvesPublicationBundle:News', $values);
            if ($i == 11) {
                $id11 = $pk['id'];
            }
        }
        $count = $this->getObjects()->getCount('JarvesPublicationBundle:News');
        $this->assertEquals(50, $count);
        $item = $this->getObjects()->get('JarvesPublicationBundle:News', $id11);
        $this->assertEquals('News 11', $item['title']);
        $this->getObjects()->update('JarvesPublicationBundle:News', $id11, array('title' => 'New News 11', 'lang' => 'en'));
        $item = $this->getObjects()->get('JarvesPublicationBundle:News', $id11);
        $this->assertEquals('New News 11', $item['title']);
        $this->getObjects()->update('JarvesPublicationBundle:News', $id11, array('title' => 'New News 11 - 2', 'lang' => 'en'));
        //check version counter - we have 2 updates, so we have 2 versions.
        $count = NewsVersionQuery::create()->filterById($id11)->count();
        $this->assertEquals(2, $count);
        $this->getObjects()->remove('JarvesPublicationBundle:News', $id11);
        //check version counter - we have 2 updates and 1 deletion (one deletion creates 2 new versions,
        //first regular version and second placeholder for deletion, so we have 4 versions now.
        $count = NewsVersionQuery::create()->filterById($id11)->count();
        $this->assertEquals(4, $count);
        $item = $this->getObjects()->get('JarvesPublicationBundle:News', $id11);
        $this->assertNull($item);
        //should be gone
        $this->getObjects()->clear('JarvesPublicationBundle:News');
    }