Skip to content

Commit

Permalink
Adding user auth interfaces to tests, see issue mongodb#37
Browse files Browse the repository at this point in the history
  • Loading branch information
mnphpexpert committed Sep 10, 2013
1 parent 7edd0f4 commit e0a5378
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 11 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"illuminate/events": "4.0.x"
},
"require-dev": {
"illuminate/cache": "4.0.x"
"illuminate/cache": "4.0.x",
"illuminate/auth": "4.0.x"
},
"autoload": {
"psr-0": {
Expand Down
15 changes: 6 additions & 9 deletions tests/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,12 @@ function bound() {}
# Cache driver
$app['cache'] = new Repository(new ArrayStore);

# Database configuration
$app['config']['database.fetch'] = null;
$app['config']['database.default'] = 'mongodb';
$app['config']['database.connections']['mongodb'] = array(
'name' => 'mongodb',
'driver' => 'mongodb',
'host' => 'localhost',
'database' => 'unittest'
);
# Load database configuration
$config = require 'config/database.php';
foreach ($config as $key => $value)
{
$app['config']["database.$key"] = $value;
}

# Initialize database manager
$app['db.factory'] = new ConnectionFactory(new Container);
Expand Down
17 changes: 17 additions & 0 deletions tests/config/database.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

return array(

'fetch' => PDO::FETCH_CLASS,
'default' => 'mongodb',

'connections' => array(
'mongodb' => array(
'name' => 'mongodb',
'driver' => 'mongodb',
'host' => 'localhost',
'database' => 'unittest',
),
)

);
35 changes: 34 additions & 1 deletion tests/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

use Jenssegers\Mongodb\Model as Eloquent;

class User extends Eloquent {
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

class User extends Eloquent implements UserInterface, RemindableInterface {

protected $collection = 'users';

Expand All @@ -23,4 +26,34 @@ public function role()
return $this->hasOne('Role');
}

/**
* Get the unique identifier for the user.
*
* @return mixed
*/
public function getAuthIdentifier()
{
return $this->getKey();
}

/**
* Get the password for the user.
*
* @return string
*/
public function getAuthPassword()
{
return $this->password;
}

/**
* Get the e-mail address where password reminders are sent.
*
* @return string
*/
public function getReminderEmail()
{
return $this->email;
}

}

0 comments on commit e0a5378

Please sign in to comment.