public function testUserUpdatePassword()
 {
     $this->put('update', array(), array('id' => $this->user->id, 'v_password' => 'mypassword', 'user' => array('email' => 'my_new_email@email', 'password' => 'mypassword')), array('user' => $this->user->id));
     $user = User::_find($this->user->id);
     $this->assertNotEquals($this->user->password, $user->password);
     $this->assertEquals('my_new_email@email', $user->email);
     $this->assertRedirect('http://' . DOMAIN . '/' . $this->user->username);
 }
 public function testVerify()
 {
     $user = User::find_by_username('jim');
     $this->get('verify', array(), array('key' => $user->api_key), array());
     $user2 = User::_find($user->id);
     $this->assertEquals(1, $user2->active);
     $this->assertRedirect(url_for('LoginController', 'login'));
 }
 public static function create_package()
 {
     $user = User::find_by_username('bob');
     $file = FileUtils::join(NIMBLE_ROOT, 'test', 'data', 'bobs_other_package-0.0.1.tgz');
     $package = Package::from_upload(array('file' => $file, 'user' => $user));
     foreach (User::_find('all') as $user) {
         $raiting = '0.' . $user->id;
         PackageRating::_create(array('user_id' => $user->id, 'package_id' => $package->id, 'rating' => (double) $raiting));
     }
 }
Пример #4
0
 public function testCanUpdateUserMyintNonNumeric()
 {
     $joe = joe();
     $update = User::update($joe->id, array('my_int' => 'l'));
     $this->assertFalse($update->saved);
     //reload joe
     $joe2 = User::_find($joe->id);
     //assert that nothing changed
     $this->assertTrue(is_null($joe2->my_int));
 }
Пример #5
0
 public function before_save()
 {
     if (!$this->new_record) {
         $old = User::_find($this->id);
         if ($this->password == $old->password) {
             return;
         }
     }
     $this->salt = static::generate_salt();
     $this->password = static::hash_password($this->password, $this->salt);
 }
Пример #6
0
 public function testFind()
 {
     //test finding by ids without cache
     foreach ($this->user_ids as $id) {
         $_user = User::_find($id);
         $this->assertTrue(isset($_user) && !empty($_user));
     }
     //test finding by ids with cache
     foreach ($this->user_ids as $id) {
         $_user = User::find($id);
         $this->assertTrue(isset($_user) && !empty($_user));
     }
 }
Пример #7
0
#!/usr/bin/env php
<?php 
require_once dirname(__FILE__) . '/../../test/nimble_record/config.php';
NimbleRecord::$debug = false;
$start = time();
$start_memory = memory_get_usage();
$number_of_iterations = 10000;
for ($i = 0; $i < $number_of_iterations; ++$i) {
    User::find(1);
}
$t1 = time();
$m1 = memory_get_usage();
for ($i = 0; $i < $number_of_iterations; ++$i) {
    User::_find(1);
}
$t2 = time();
$m2 = memory_get_usage();
printf("Finder profile test, {$number_of_iterations} iterations:\n\n");
printf("Caching Memusage: %d\n", $m1 - $start_memory);
printf("Caching: %d sec.\n", $t1 - $start);
printf("No Caching: %d sec.\n", $t2 - $t1);
printf("No Caching Memusage: %d\n", $m2 - $m1);
printf('Peak Memusage %d', memory_get_peak_usage());
echo "\n";
Пример #8
0
 public function testUpdateUsingSameInt()
 {
     $user = User::find(1);
     $u = User::update($user->id, array('my_int' => $user->my_int));
     $user2 = User::_find(1);
     $this->assertFalse($user2->updated_at === $user->updated_at);
     $this->assertEquals($user2->my_int, $user->my_int);
 }