public function testThroughPropel()
 {
     WorkspaceManager::setCurrent(0);
     ItemQuery::create()->deleteAll();
     ItemCategoryQuery::create()->deleteAll();
     WorkspaceManager::setCurrent(0);
     //todo
 }
Esempio n. 2
0
 public function testRulesWithFields()
 {
     ItemCategoryQuery::create()->deleteAll();
     ItemQuery::create()->deleteAll();
     TestQuery::create()->deleteAll();
     $this->getACL()->setCaching(false);
     $this->getACL()->removeObjectRules('test/item');
     $user = new User();
     $user->setUsername('TestUser');
     $user->save();
     $group = new Group();
     $group->setName('ACL Test group');
     $group->addUser($user);
     $group->save();
     $cat1 = new ItemCategory();
     $cat1->setName('Nein');
     $item1 = new Item();
     $item1->setTitle('Item 1');
     $item1->addItemCategory($cat1);
     $item1->save();
     $cat2 = new ItemCategory();
     $cat2->setName('Hiiiii');
     $item2 = new Item();
     $item2->setTitle('Item 2');
     $item2->addItemCategory($cat2);
     $item2->save();
     $this->getACL()->removeObjectRules('test/item');
     $fields = array('oneCategory' => array(array('access' => false, 'condition' => array(array('id', '>', $cat1->getId())))));
     $this->getACL()->setObjectUpdate('test/item', \Jarves\ACL::TARGET_TYPE_USER, $user->getId(), true, $fields);
     $testItemRequest = ACLRequest::create('test/item')->targetUser($user->getId())->onlyUpdateMode();
     $this->assertFalse($this->getACL()->check($testItemRequest->setField(['oneCategory' => $cat2->getId()])));
     $this->assertTrue($this->getACL()->check($testItemRequest->setField(['oneCategory' => $cat1->getId()])));
     $this->getACL()->removeObjectRules('test/item');
     $fields = array('oneCategory' => array(array('access' => false, 'condition' => array(array('name', '=', 'Nein')))));
     $this->getACL()->setObjectUpdate('test/item', \Jarves\ACL::TARGET_TYPE_USER, $user->getId(), true, $fields);
     $this->assertTrue($this->getACL()->check($testItemRequest->setField(['oneCategory' => $cat2->getId()])));
     $this->assertFalse($this->getACL()->check($testItemRequest->setField(['oneCategory' => $cat1->getId()])));
     $this->getACL()->removeObjectRules('test/item');
     $fields = array('title' => array(array('access' => false, 'condition' => array(array('title', 'LIKE', 'peter %')))));
     $this->getACL()->setObjectUpdate('test/item', \Jarves\ACL::TARGET_TYPE_USER, $user->getId(), true, $fields);
     $this->assertTrue($this->getACL()->check($testItemRequest->setField(['title' => 'Heidenau'])));
     $this->assertTrue($this->getACL()->check($testItemRequest->setField(['title' => 'peter'])));
     $this->assertFalse($this->getACL()->check($testItemRequest->setField(['title' => 'peter 2'])));
     $this->assertFalse($this->getACL()->check($testItemRequest->setField(['title' => 'peter asdad'])));
     $this->getACL()->removeObjectRules('test/item');
     $fields = array('title' => array(array('access' => false, 'condition' => array(array('title', '=', 'peter')))));
     $this->getACL()->setObjectUpdate('test/item', \Jarves\ACL::TARGET_TYPE_USER, $user->getId(), true, $fields);
     $this->assertTrue($this->getACL()->check($testItemRequest->setField(['title' => 'Heidenau'])));
     $this->assertFalse($this->getACL()->check($testItemRequest->setField(['title' => 'peter'])));
     $this->assertTrue($this->getACL()->check($testItemRequest->setField(['title' => 'peter2'])));
     $this->getACL()->setCaching(true);
     $this->getACL()->removeObjectRules('test/item');
 }
Esempio n. 3
0
 public function testManyToOne()
 {
     ItemQuery::create()->deleteAll();
     ItemCategoryQuery::create()->deleteAll();
     $id = uniqid();
     $newItemCategory = ['name' => 'Test Category ' . $id, 'items' => [['title' => 'Test Item ' . $id . ' 1'], ['title' => 'Test Item ' . $id . ' 2']]];
     $added = $this->getObjects()->add('test/itemCategory', $newItemCategory);
     $this->assertGreaterThan(0, $added['id']);
     $category = ItemCategoryQuery::create()->findOneById($added['id']);
     $items = $category->getItems();
     $this->assertCount(2, $items);
     $this->assertEquals('Test Item ' . $id . ' 1', $items[0]->getTitle());
     $this->assertEquals('Test Item ' . $id . ' 2', $items[1]->getTitle());
 }