PHP User::delete_all Examples

PHP User::delete_all - 8 examples found. These are the top rated real world PHP examples of User::delete_all extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
 public function test_belongs_to()
 {
     MemoryStore::flush();
     Page::delete_all();
     User::delete_all();
     $user = new User();
     $user->email = "ben@allseeing-i.com";
     $user->first_name = "Ben";
     $user->last_name = "Copsey";
     $user->password = "secret";
     $user->accepted_terms_and_conditions = true;
     $user->registration_date = new Date();
     $user->first_name = "Ben";
     $user->save();
     $page1 = new Page();
     $page1->title = "This is page 1";
     $page1->last_modified = new Date();
     $page1->body = "This is the content";
     $page1->url = "page-1";
     $page1->author = $user;
     $page1->save();
     FuzzyTest::assert_equal($page1->author_id, $user->id, "Author not set correctly");
     $user->delete();
     $page = Page::find_by_url('page-1');
     FuzzyTest::assert_true(isset($page), "Page deleted when it should have been preserved");
     FuzzyTest::assert_equal($page->author_id, 0, "Page deleted when it should have been preserved");
     $user->save();
     $page->author = $user;
     $page->save();
     $matches = $user->pages;
     FuzzyTest::assert_equal(count($matches), 1, "Page count should be 1");
 }
Example #2
0
 public function test_validation()
 {
     MemoryStore::flush();
     UserLogin::delete_all();
     User::delete_all();
     $user = new User();
     FuzzyTest::assert_false($user->validate(), "User write should fail because required properties were not set");
     FuzzyTest::assert_true(key_exists("email", $user->validation_errors), "Email validation error not set");
     FuzzyTest::assert_true(key_exists("password", $user->validation_errors), "Password validation error not set");
     FuzzyTest::assert_true(key_exists("accepted_terms_and_conditions", $user->validation_errors), "Boolean validation error not set");
     FuzzyTest::assert_true(key_exists("registration_date", $user->validation_errors), "Required validation error not set");
     $user->accepted_terms_and_conditions = true;
     $user->validate();
     FuzzyTest::assert_false(key_exists("accepted_terms_and_conditions", $user->validation_errors), "Boolean validation error erroneously set");
     $user->email = "ben@allseeing-i.com";
     $user->validate();
     FuzzyTest::assert_false(key_exists("email", $user->validation_errors), "Email validation error erroneously set");
     $user->password = "secret";
     $user->validate();
     FuzzyTest::assert_false(key_exists("password", $user->validation_errors), "Password validation error erroneously set");
     $user->registration_date = new Date();
     $user->validate();
     FuzzyTest::assert_false(key_exists("registration_date", $user->validation_errors), "Required validation error erroneously set");
     $user->first_name = "Ben";
     $user->last_name = "Copsey";
     $user->validate();
     FuzzyTest::assert_false(key_exists("first_name", $user->validation_errors), "Length validation error erroneously set");
     FuzzyTest::assert_false(key_exists("last_name", $user->validation_errors), "Length validation error erroneously set");
     FuzzyTest::assert_true($user->validate(), "Validate should succeed because required properties were set");
 }
Example #3
0
 public function test_simple_write()
 {
     MemoryStore::flush();
     UserLogin::delete_all();
     User::delete_all();
     $user = new User();
     $user->email = "ben@allseeing-i.com";
     $user->password = "secret";
     $user->accepted_terms_and_conditions = true;
     $user->registration_date = new Date("2008-12-12");
     $user->first_name = "Ben";
     $user->last_name = "Copsey";
     FuzzyTest::assert_true($user->write_new(), "Write should succeed because required properties were set");
     $user = new User();
     $user->email = "ben@allseeing-i.com";
     $user->password = "secret";
     $user->accepted_terms_and_conditions = true;
     $user->registration_date = new Date();
     $user->first_name = "Ben";
     $user->last_name = "Copsey";
     FuzzyTest::assert_false($user->write_new(), "Write should fail because we have a duplicate for a unique property");
     $user = new User();
     $user->email = "ben@acknet.co.uk";
     $user->password = "secret";
     $user->accepted_terms_and_conditions = true;
     $user->registration_date = new Date();
     $user->first_name = "Ben";
     $user->last_name = "Copsey";
     FuzzyTest::assert_true($user->save(), "Save should succeed as a write_new");
 }
Example #4
0
 public function __construct()
 {
     MemoryStore::flush();
     UserLogin::delete_all();
     User::delete_all();
     $user = new User();
     $user->email = "ben@allseeing-i.com";
     $user->password = "secret";
     $user->accepted_terms_and_conditions = true;
     $user->registration_date = new Date();
     $user->first_name = "Ben";
     $user->last_name = "Copsey";
     $user->save();
     $user = new User();
     $user->email = "ben@acknet.co.uk";
     $user->password = "secret";
     $user->accepted_terms_and_conditions = true;
     $user->registration_date = new Date();
     $user->first_name = "Ben";
     $user->last_name = "Copsey";
     $user->save();
     $user = new User();
     $user->email = "ben@shared-space.net";
     $user->password = "secret";
     $user->accepted_terms_and_conditions = true;
     $user->registration_date = new Date();
     $user->first_name = "Benjamus";
     $user->last_name = "Copso";
     $user->save();
     Page::delete_all();
     $page = new Page();
     $page->title = "test page";
     $page->url = "test-page";
     $page->body = "thing";
     $page->save();
     $page = new Page();
     $page->title = "test page 2";
     $page->url = "test-page-2";
     $page->body = "thing 2";
     $page->save();
     $page = new Page();
     $page->title = "test page 3";
     $page->url = "test-page-3";
     $page->body = "thing 3";
     $page->save();
 }
Example #5
0
 public function __construct()
 {
     MemoryStore::flush();
     Document::delete_all();
     CustomDocument::delete_all();
     User::delete_all();
     $text = "This is the content of the file";
     $file = new File();
     $file->contents = $text;
     $file->write("/tmp/test.txt");
     $user = new User();
     $user->email = "ben@allseeing-i.com";
     $user->password = "secret";
     $user->accepted_terms_and_conditions = true;
     $user->registration_date = new Date();
     $user->first_name = "Ben";
     $user->last_name = "Copsey";
     $user->save();
 }
Example #6
0
 public function teardown()
 {
     $user = new User();
     $user->delete_all();
 }
Example #7
0
<?php

$ci =& get_instance();
$l = new userlevel();
$l->get_by_id($ci->uri->segment(5));
if (!$l->exists()) {
    $ci->app->add_error("level not found");
} else {
    $usr = new User();
    $usr->get_by_level($l->id);
    $usr->delete_all();
    $l->delete();
    $ci->app->add_info(" level deleted ");
}
Example #8
0
 public function test_has_many()
 {
     UserLogin::delete_all();
     User::delete_all();
     $user = new User();
     $user->email = "ben@allseeing-i.com";
     $user->password = "secret";
     $user->accepted_terms_and_conditions = true;
     $user->registration_date = new Date();
     $user->first_name = "Ben";
     $user->last_name = "Copsey";
     $user->save();
     $user = new User();
     $user->email = "ben@acknet.co.uk";
     $user->password = "secret";
     $user->accepted_terms_and_conditions = true;
     $user->registration_date = new Date();
     $user->first_name = "Ben";
     $user->last_name = "Copsey";
     $user->save();
     $user = User::find_by_email('ben@allseeing-i.com');
     $user_login = new UserLogin();
     $user_login->user_id = $user->id;
     $user_login->date = new Date();
     $user_login->ip_address = "127.0.0.1";
     $user_login->save();
     $matches = $user->logins();
     FuzzyTest::assert_equal(count($matches), 1, "Should find one login here");
     $user_login = new UserLogin();
     $user_login->user_id = $user->id;
     $user_login->date = new Date();
     $user_login->ip_address = "127.0.0.1";
     $user_login->save();
     $matches = UserLogin::find_all_by_user($user);
     FuzzyTest::assert_equal(count($matches), 2, "Should find two logins here");
     $matches = UserLogin::find_all_where("user_id = " . DB::escape($user->id));
     FuzzyTest::assert_equal(count($matches), 2, "Should find two logins here");
     $matches = UserLogin::find_all_where("user_id = " . DB::escape($user->id), 1);
     FuzzyTest::assert_equal(count($matches), 1, "Should find one login here");
     $login = $matches[0];
     $matches = UserLogin::find_all_where("user_id = " . DB::escape($user->id), 2);
     $login2 = $matches[0];
     FuzzyTest::assert_equal($login->id, $login2->id, "Two logins should be equal");
     $matches = UserLogin::find_all_where("user_id = " . DB::escape($user->id), 0, 2);
     $login2 = $matches[0];
     FuzzyTest::assert_equal($login->id, $login2->id, "Two logins should be equal");
     $matches = UserLogin::find_all_where("user_id = " . DB::escape($user->id), 1, 2);
     $login2 = $matches[0];
     FuzzyTest::assert_not_equal($login->id, $login2->id, "Two logins should be equal");
     $matches = $user->logins();
     FuzzyTest::assert_equal(count($matches), 2, "Should find two logins here");
     $login = UserLogin::find_by_user_id($user->id);
     FuzzyTest::assert_equal($login->user_id, $user->id, "Found wrong login");
     $login = UserLogin::find_by_user($user);
     FuzzyTest::assert_equal($login->user_id, $user->id, "Found wrong login");
     $u = User::find_by_login($user_login);
     FuzzyTest::assert_equal($u->id, $user->id, "Found wrong user");
     $user_login = new UserLogin();
     $user_login->user = $user;
     $user_login->date = new Date();
     $user_login->ip_address = "127.0.0.1";
     $user_login->save();
     $matches = $user->logins();
     FuzzyTest::assert_equal(count($matches), 3, "Should find three logins here");
     $user->delete();
     $matches = UserLogin::find_by_user_id($user->id);
     FuzzyTest::assert_equal(count($matches), 0, "Should find zero logins here");
     $matches = UserLogin::find_by_user($user);
     FuzzyTest::assert_equal(count($matches), 0, "Should find zero logins here");
     UserLogin::delete_all();
     $user_login1 = new UserLogin();
     $user_login1->date = new Date();
     $user_login1->ip_address = "127.0.0.1";
     $user_login2 = new UserLogin();
     $user_login2->date = new Date();
     $user_login2->ip_address = "127.0.0.1";
     //$user->save();
     $user->logins = array($user_login1, $user_login2);
     $user->save();
     $matches = $user->logins;
     FuzzyTest::assert_equal(count($matches), 2, "Should find two logins here");
     $user2 = new User();
     $user2 = User::find_by_email('ben@acknet.co.uk');
     $user_login1->user = $user2;
     $user_login1->save();
     $matches = $user->logins;
     FuzzyTest::assert_equal(count($matches), 1, "Should find one login here");
     $matches = $user2->logins();
     FuzzyTest::assert_equal(count($matches), 1, "Should find one login here");
 }