public function test_basic_find()
{
$count = User::count();
FuzzyTest::assert_equal($count, 3, "Should find three users here");
$matches = User::find_all();
FuzzyTest::assert_equal(count($matches), 3, "Should find three users here");
$count = User::count(array('email' => 'ben@allseeing-i.com'));
FuzzyTest::assert_equal($count, 1, "Should find one user here");
$matches = User::find(array('email' => 'ben@allseeing-i.com'));
FuzzyTest::assert_equal(count($matches), 1, "Should find one user here");
$u = $matches[0];
FuzzyTest::assert_equal($u->email, "ben@allseeing-i.com", "Found wrong user");
$count = User::count(array('first_name' => 'Ben'));
FuzzyTest::assert_equal($count, 2, "Should find two users here");
$matches = User::find(array('first_name' => 'Ben'));
FuzzyTest::assert_equal(count($matches), 2, "Should find two users here");
$matches = User::find_all_by_first_name('Ben');
FuzzyTest::assert_equal(count($matches), 2, "Should find two users here");
$count = User::count_by_first_name('Ben');
FuzzyTest::assert_equal($count, 2, "Should find two users here");
$matches = User::find_all_by_email('ben@allseeing-i.com');
FuzzyTest::assert_equal(count($matches), 1, "Should find one user here");
$count = User::count_by_email('ben@allseeing-i.com');
FuzzyTest::assert_equal($count, 1, "Should find one user here");
$u = $matches[0];
FuzzyTest::assert_equal($u->email, "ben@allseeing-i.com", "Found wrong user");
$u = User::find_by_email('ben@allseeing-i.com');
FuzzyTest::assert_equal($u->email, "ben@allseeing-i.com", "Found wrong user");
$matches = User::find_all_by_email_and_first_name('ben@allseeing-i.com', 'Ben');
FuzzyTest::assert_equal(count($matches), 1, "Should find one user here");
$count = User::count_by_email_and_first_name('ben@allseeing-i.com', 'Ben');
FuzzyTest::assert_equal($count, 1, "Should find one user here");
$u = $matches[0];
FuzzyTest::assert_equal($u->email, "ben@allseeing-i.com", "Found wrong user");
$matches = User::find(array('first_name' => 'Ben', 'limit' => 1));
FuzzyTest::assert_equal(count($matches), 1, "Should find one user here");
$matches = User::find(array('first_name' => 'Ben', 'order_by' => 'registration_date'));
FuzzyTest::assert_equal(count($matches), 2, "Should find two users here");
$u = $matches[0];
FuzzyTest::assert_equal($u->email, "ben@allseeing-i.com", "Sorted results in the wrong order");
$matches = User::find(array('first_name' => 'Ben', 'order_by' => 'email', 'sort' => "descending"));
FuzzyTest::assert_equal(count($matches), 2, "Should find two users here");
$u = $matches[0];
FuzzyTest::assert_equal($u->email, "ben@allseeing-i.com", "Sorted results in the wrong order");
$matches = User::find(array('first_name' => 'Ben', 'order_by' => 'email', 'sort' => "ascending"));
FuzzyTest::assert_equal(count($matches), 2, "Should find two users here");
$u = $matches[1];
FuzzyTest::assert_equal($u->email, "ben@allseeing-i.com", "Found wrong user");
$matches = User::find(array('email_not' => 'ben@allseeing-i.com'));
FuzzyTest::assert_equal(count($matches), 2, "Should find two users here");
}