/** * @basedata false */ public function testBooleanCondition() { $a = new Author(); $ret = $a->create(array('name' => 'a', 'email' => 'a@a', 'identity' => 'a', 'confirmed' => false)); $this->assertResultSuccess($ret); $ret = $a->create(array('name' => 'b', 'email' => 'b@b', 'identity' => 'b', 'confirmed' => true)); $this->assertResultSuccess($ret); /* $connManager = \LazyRecord\ConnectionManager::getInstance(); $dbh = $connManager->getConnection('default'); $stm = $dbh->query('SELECT * FROM authors WHERE confirmed = 0'); */ $authors = new AuthorCollection(); $authors->where()->equal('confirmed', false); $ret = $authors->fetch(); $this->assertInstanceOf('LazyRecord\\Result', $ret); $this->assertCollectionSize(1, $authors); $this->assertFalse($authors[0]->confirmed); $authors = new AuthorCollection(); $authors->where()->equal('confirmed', true); $ret = $authors->fetch(); $this->assertInstanceOf('LazyRecord\\Result', $ret); $this->assertCollectionSize(1, $authors); $this->assertTrue($authors[0]->confirmed); $authors->delete(); }
/** * @basedata false */ public function testBooleanCondition() { $a = new Author(); $ret = $a->create(array('name' => 'a', 'email' => 'a@a', 'identity' => 'a', 'confirmed' => false)); $this->assertResultSuccess($ret); $ret = $a->create(array('name' => 'b', 'email' => 'b@b', 'identity' => 'b', 'confirmed' => true)); $this->assertResultSuccess($ret); $authors = new AuthorCollection(); $authors->where()->equal('confirmed', false); $ret = $authors->fetch(); $this->assertInstanceOf('LazyRecord\\Result', $ret); $this->assertCollectionSize(1, $authors); $this->assertFalse($authors[0]->confirmed); $authors = new AuthorCollection(); $authors->where()->equal('confirmed', true); $ret = $authors->fetch(); $this->assertInstanceOf('LazyRecord\\Result', $ret); $this->assertCollectionSize(1, $authors); $this->assertTrue($authors[0]->confirmed); $authors->delete(); }
/** * @basedata false */ public function testBooleanCondition() { $a = new Author(); $ret = $a->create(array('name' => 'a', 'email' => 'a@a', 'identity' => 'a', 'confirmed' => false)); $this->resultOK(true, $ret); $this->assertFalse($a->confirmed); $ret = $a->create(array('name' => 'b', 'email' => 'b@b', 'identity' => 'b', 'confirmed' => true)); $this->resultOK(true, $ret); $this->assertTrue($a->confirmed); $authors = new AuthorCollection(); $this->assertEquals(2, $authors->size(), 'created two authors'); // test collection query with boolean value $authors = new AuthorCollection(); $authors->where()->equal('confirmed', false); $ret = $authors->fetch(); ok($ret); is(1, $authors->size()); $authors = new \AuthorBooks\Model\AuthorCollection(); $authors->where()->equal('confirmed', true); $ret = $authors->fetch(); ok($ret); is(1, $authors->size()); $authors->delete(); }
public function testCollectionPagerAndSelection() { $author = new Author(); foreach (range(1, 10) as $i) { $ret = $author->create(array('name' => 'Foo-' . $i, 'email' => 'foo@foo' . $i, 'identity' => 'foo' . $i, 'confirmed' => true)); ok($author->confirmed, 'is true'); ok($ret->success); } $authors = new AuthorCollection(); $authors->where()->equal('confirmed', true); foreach ($authors as $author) { ok($author->confirmed); } is(10, $authors->size()); /* page 1, 10 per page */ $pager = $authors->pager(1, 10); ok($pager); $pager = $authors->pager(); ok($pager); ok($pager->items()); $array = $authors->toArray(); ok($array[0]); ok($array[9]); ok($authors->items()); is(10, count($authors->items())); foreach ($authors as $a) { $ret = $a->delete(); ok($ret->success); } }