$users=$query->query("FROM User-b, User.Phonenumber-l WHERE User.Phonenumber.phonenumber LIKE '%123%'");
$this->assertEqual(trim($query->getQuery()),
"SELECT entity.id AS User__id, phonenumber.id AS Phonenumber__id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE (phonenumber.phonenumber LIKE '%123%') AND (entity.type = 0)");
"SELECT entity.id AS User__id, entity.name AS User__name, entity.loginname AS User__loginname, entity.password AS User__password, entity.type AS User__type, entity.created AS User__created, entity.updated AS User__updated, entity.email_id AS User__email_id FROM entity WHERE (entity.type = 0)");
"SELECT entity.id AS User__id, phonenumber.id AS Phonenumber__id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE (entity.type = 0)");
$this->assertEqual($users->count(),8);
// EXPECTED THAT ONE NEW QUERY IS NEEDED TO GET THE FIRST USER's PHONENUMBER
"SELECT entity.id AS User__id, email.id AS Email__id FROM entity, email WHERE (entity.email_id = email.id) AND (entity.type = 0)");
$this->assertEqual($users->count(),8);
$users=$query->query("FROM Email-b WHERE Email.address LIKE '%@example%'");
$this->assertEqual($query->getQuery(),
"SELECT email.id AS Email__id FROM email WHERE (email.address LIKE '%@example%')");
$this->assertEqual($users->count(),8);
$users=$query->query("FROM User-b WHERE User.name LIKE '%Jack%'");
$this->assertEqual($query->getQuery(),"SELECT entity.id AS User__id FROM entity WHERE (entity.name LIKE '%Jack%') AND (entity.type = 0)");
$this->assertEqual($users->count(),0);
$users=$query->query("FROM User-b WHERE User.Phonenumber.phonenumber REGEXP '[123]'");
$this->assertEqual(trim($query->getQuery()),
"SELECT entity.id AS User__id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE (phonenumber.phonenumber REGEXP '[123]') AND (entity.type = 0)");
$this->assertEqual($users->count(),8);
$users=$query->query("FROM User-b WHERE User.Group.name = 'Action Actors'");
$this->assertEqual(trim($query->getQuery()),
"SELECT entity.id AS User__id FROM entity WHERE (entity.id IN (SELECT user_id FROM groupuser WHERE group_id IN (SELECT entity.id AS Group__id FROM entity WHERE (entity.name = 'Action Actors') AND (entity.type = 1)))) AND (entity.type = 0)");
$users=$query->query("FROM User-b WHERE User.Group.Phonenumber.phonenumber LIKE '123 123'");
$this->assertEqual(trim($query->getQuery()),
"SELECT entity.id AS User__id FROM entity WHERE (entity.id IN (SELECT user_id FROM groupuser WHERE group_id IN (SELECT entity.id AS Group__id FROM entity, phonenumber WHERE (phonenumber.phonenumber LIKE '123 123') AND (entity.type = 1)))) AND (entity.type = 0)");