function testLoadingWithMultipleAssociations() { $articles = SActiveStore::findAll('Article', Null, array('include' => array('comments', 'categories'))); $this->assertTrue($articles[0]->comments->isLoaded()); $this->assertEqual(2, $articles[0]->countComments()); $this->assertTrue($articles[0]->categories->isLoaded()); $this->assertEqual(3, $articles[0]->countCategories()); }
protected function findTarget() { return SActiveStore::findAll($this->assocClass, $this->constructSql()); }
public function getPage($page) { return SActiveStore::findAll($this->className, $this->condition, $this->sqlOptions($page)); }
public function index() { $this->{$this->plural_name} = SActiveStore::findAll($this->class_name); $this->renderScaffold(); }
function testDelete() { $this->assertEqual(array($this->topics['list_1'], $this->topics['list_2'], $this->topics['list_3'], $this->topics['list_4']), SActiveStore::findAll('Topic', 'forum_id = 1', array('order' => 'position ASC'))); $topic = new SListDecorator($this->topics['list_2'], 'forum'); $topic->delete(); $this->instanciateFixtures(); $this->assertEqual(array($this->topics['list_1'], $this->topics['list_3'], $this->topics['list_4']), SActiveStore::findAll('Topic', 'forum_id = 1', array('order' => 'position ASC'))); $this->assertEqual(1, $this->topics['list_1']->position); $this->assertEqual(2, $this->topics['list_3']->position); $this->assertEqual(3, $this->topics['list_4']->position); $topic = new SListDecorator($this->topics['list_1'], 'forum'); $topic->delete(); $this->instanciateFixtures(); $this->assertEqual(array($this->topics['list_3'], $this->topics['list_4']), SActiveStore::findAll('Topic', 'forum_id = 1', array('order' => 'position ASC'))); $this->assertEqual(1, $this->topics['list_3']->position); $this->assertEqual(2, $this->topics['list_4']->position); }
function testFindWithBindedCondition() { $companies = SActiveStore::findAll('Company', array("name = :company", array(':company' => 'Groupe W'))); $this->assertEqual(1, count($companies)); }