/** * @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 testJoin() { $authors = new AuthorCollection(); $authors->join(new \AuthorBooks\Model\Address()); $authors->fetch(); $sql = $authors->toSQL(); like('/addresses.address\\s+AS\\s+addresses_address/', $sql); }
/** * @rebuild false */ public function testJoinWithAliasAndWithoutRelationId() { $authors = new AuthorCollection(); $authors->join(new \AuthorBooks\Model\Address(), 'LEFT', 'a'); $authors->fetch(); $sql = $authors->toSQL(); ok($sql); }