Skip to content

Commit e0a5378

Browse files
committed
Adding user auth interfaces to tests, see issue mongodb#37
1 parent 7edd0f4 commit e0a5378

File tree

4 files changed

+59
-11
lines changed

4 files changed

+59
-11
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"illuminate/events": "4.0.x"
1717
},
1818
"require-dev": {
19-
"illuminate/cache": "4.0.x"
19+
"illuminate/cache": "4.0.x",
20+
"illuminate/auth": "4.0.x"
2021
},
2122
"autoload": {
2223
"psr-0": {

tests/app.php

+6-9
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,12 @@ function bound() {}
2525
# Cache driver
2626
$app['cache'] = new Repository(new ArrayStore);
2727

28-
# Database configuration
29-
$app['config']['database.fetch'] = null;
30-
$app['config']['database.default'] = 'mongodb';
31-
$app['config']['database.connections']['mongodb'] = array(
32-
'name' => 'mongodb',
33-
'driver' => 'mongodb',
34-
'host' => 'localhost',
35-
'database' => 'unittest'
36-
);
28+
# Load database configuration
29+
$config = require 'config/database.php';
30+
foreach ($config as $key => $value)
31+
{
32+
$app['config']["database.$key"] = $value;
33+
}
3734

3835
# Initialize database manager
3936
$app['db.factory'] = new ConnectionFactory(new Container);

tests/config/database.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
return array(
4+
5+
'fetch' => PDO::FETCH_CLASS,
6+
'default' => 'mongodb',
7+
8+
'connections' => array(
9+
'mongodb' => array(
10+
'name' => 'mongodb',
11+
'driver' => 'mongodb',
12+
'host' => 'localhost',
13+
'database' => 'unittest',
14+
),
15+
)
16+
17+
);

tests/models/User.php

+34-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
use Jenssegers\Mongodb\Model as Eloquent;
44

5-
class User extends Eloquent {
5+
use Illuminate\Auth\UserInterface;
6+
use Illuminate\Auth\Reminders\RemindableInterface;
7+
8+
class User extends Eloquent implements UserInterface, RemindableInterface {
69

710
protected $collection = 'users';
811

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

29+
/**
30+
* Get the unique identifier for the user.
31+
*
32+
* @return mixed
33+
*/
34+
public function getAuthIdentifier()
35+
{
36+
return $this->getKey();
37+
}
38+
39+
/**
40+
* Get the password for the user.
41+
*
42+
* @return string
43+
*/
44+
public function getAuthPassword()
45+
{
46+
return $this->password;
47+
}
48+
49+
/**
50+
* Get the e-mail address where password reminders are sent.
51+
*
52+
* @return string
53+
*/
54+
public function getReminderEmail()
55+
{
56+
return $this->email;
57+
}
58+
2659
}

0 commit comments

Comments
 (0)