-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add improved support for static magic findWhere* methods
- Loading branch information
1 parent
e0dbc0f
commit d8758f2
Showing
2 changed files
with
176 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -925,6 +925,67 @@ public function testFindWhere() | |
$newUsers2 = Users::findWhereUsername('testuser27'); | ||
$this->assertEquals(0, $newUsers2->count()); | ||
|
||
$this->db->disconnect(); | ||
} | ||
|
||
public function testFindWhereConditions() | ||
{ | ||
$user = new Users([ | ||
'username' => 'testuser24', | ||
'password' => 'password24', | ||
'email' => '[email protected]', | ||
'logins' => 1 | ||
]); | ||
$user->save(); | ||
|
||
$users = Users::findWhereGreaterThan('logins', 0); | ||
$this->assertGreaterThanOrEqual(1, $users->count()); | ||
|
||
$users = Users::findWhereGreaterThanOrEqual('logins', 1); | ||
$this->assertGreaterThanOrEqual(1, $users->count()); | ||
|
||
$users = Users::findWhereLessThan('logins', 2); | ||
$this->assertGreaterThanOrEqual(1, $users->count()); | ||
|
||
$users = Users::findWhereLessThanOrEqual('logins', 1); | ||
$this->assertGreaterThanOrEqual(1, $users->count()); | ||
|
||
$users = Users::findWhereEquals('logins', 1); | ||
$this->assertGreaterThanOrEqual(1, $users->count()); | ||
|
||
$users = Users::findWhereNotEquals('logins', -1); | ||
$this->assertGreaterThanOrEqual(1, $users->count()); | ||
|
||
$users = Users::findWhereIn('logins', [1]); | ||
$this->assertGreaterThanOrEqual(1, $users->count()); | ||
|
||
$users = Users::findWhereNotIn('logins', [10000000]); | ||
$this->assertGreaterThanOrEqual(1, $users->count()); | ||
|
||
$users = Users::findWhereNull('logins'); | ||
$this->assertEquals(0, $users->count()); | ||
|
||
$users = Users::findWhereNotNull('logins'); | ||
$this->assertGreaterThanOrEqual(1, $users->count()); | ||
|
||
$users = Users::findWhereBetween('logins', '(0, 10)'); | ||
$this->assertGreaterThanOrEqual(1, $users->count()); | ||
|
||
$users = Users::findWhereNotBetween('logins', '(1000000, 1000010)'); | ||
$this->assertGreaterThanOrEqual(1, $users->count()); | ||
|
||
$users = Users::findWhereLike('username', 'testuser%'); | ||
$this->assertGreaterThanOrEqual(1, $users->count()); | ||
|
||
$users = Users::findWhereNotLike('username', 'baduser%'); | ||
$this->assertGreaterThanOrEqual(1, $users->count()); | ||
|
||
$users = Users::findWhereLike('username', '%testuser24'); | ||
$this->assertGreaterThanOrEqual(1, $users->count()); | ||
|
||
$users = Users::findWhereNotLike('username', '%baduser'); | ||
$this->assertGreaterThanOrEqual(1, $users->count()); | ||
|
||
$schema = $this->db->createSchema(); | ||
$schema->dropIfExists('users'); | ||
$schema->execute(); | ||
|