public function testEncoderDecoder() { $hash = new Hash(); /* * Generate 50 random assertions to test ability * to encode an integer into a hash and extract it */ for ($i = 0; $i < 50; $i++) { // Generate a random number $expectedNumber = rand(1, 999999); $code = $hash->generate($expectedNumber); list($actualNumber) = $hash->examine($code); $this->assertEquals($expectedNumber, $actualNumber); } }
public function testResetPassword() { $this->user->login(); $this->assertFalse($this->user->log->hasError()); $result = $this->user->resetPassword('*****@*****.**'); $this->assertFalse($result); $this->assertTrue($this->user->log->hasError()); $result = $this->user->resetPassword('*****@*****.**'); $this->assertInstanceOf('ptejada\\uFlex\\Collection', $result); $this->assertFalse($this->user->log->hasError()); $this->assertEquals('pablo', $result->Username); $this->assertEquals('*****@*****.**', $result->Email); $this->assertEquals(1, $result->ID); $this->assertEquals(40, strlen($result->Confirmation)); // Confirm confirmation was saved on the on DB $user = $this->user->table->getRow(array('ID' => 1)); $this->assertEquals($user->Confirmation, $result->Confirmation); $newPassword = '******'; $success = $this->user->newPassword(Hash::generate(), array('Password' => $newPassword, 'Password2' => $newPassword)); $this->assertFalse($success); $success = $this->user->newPassword($result->Confirmation, array('Password' => $newPassword, 'Password2' => $newPassword)); $this->assertTrue($success); }