Advertisement
Guest User

Untitled

a guest
Oct 6th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.17 KB | None | 0 0
  1. <?php
  2.  
  3. require_once MODPATH . 'auth/models/user.php';
  4.  
  5. class BaseTest extends PHPUnit_Framework_TestCase
  6. {
  7.     /**
  8.      *
  9.      * @var ORM_Core
  10.      */
  11.     private $user;
  12.    
  13.     protected function setUp() {
  14.        
  15.         $this->user = new User_Model;
  16.        
  17.     }
  18.  
  19.  
  20.     public function testBase()
  21.     {  
  22.         // user object should be created
  23.         $this->assertNotNull($this->user, 'User object initializated');
  24.        
  25.         $this->user->username = $this->user->email = $username = uniqid() . '@polcode.com';
  26.         $this->user->password = $password = substr(md5(rand(100000, 999999) . microtime()), 0, 8);
  27.        
  28.         // add credentials
  29.         $this->user->add(ORM::factory('role', 'login'));
  30.        
  31.         $this->user->save();
  32.        
  33.         // flag should be set to true
  34.         $this->assertTrue($this->user->saved, 'User object saved');
  35.        
  36.         // user should authenticate successful
  37.         $this->assertTrue(Auth::instance()->login($username, $password), 'User logged successfully');
  38.        
  39.  
  40.        
  41.     }
  42.    
  43.     protected function tearDown() {
  44.        
  45.         $this->user->delete();
  46.        
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement