/**
  * Confirms that $this->app->auth and $this->app->authenticator
  * return the expected class instances
  */
 public function testBootstrap()
 {
     $app = new Slim();
     $adapter = $this->getMockBuilder('Zend\\Authentication\\Adapter\\AbstractAdapter')->disableOriginalConstructor()->getMock();
     $acl = new Acl();
     $bootstrap = new Bootstrap($app, $adapter, $acl);
     $bootstrap->bootstrap();
     $this->assertInstanceOf('JeremyKendall\\Slim\\Auth\\Authenticator', $app->authenticator);
 }
Пример #2
0
use Zend\Authentication\Storage\Session as SessionStorage;
use Zend\Session\Config\SessionConfig;
use Zend\Session\SessionManager;
require '../lib/Acl.php';
require '../settings.php';
$app = new \Slim\slim(array('mode' => 'developement', 'debug' => true));
// Configure Slim Auth components
$validator = new PasswordValidator();
$adapter = new PdoAdapter(getDb(), 'users', 'username', 'password', $validator);
$acl = new lib\Acl();
$sessionConfig = new SessionConfig();
$sessionConfig->setOptions(array('remember_me_seconds' => 60 * 60 * 24 * 7, 'name' => $applicationFolderName));
$sessionManager = new SessionManager($sessionConfig);
$sessionManager->rememberMe();
$storage = new SessionStorage(null, null, $sessionManager);
$authBootstrap = new Bootstrap($app, $adapter, $acl);
$authBootstrap->setStorage($storage);
$authBootstrap->bootstrap();
require '../lib/notorm/NotORM.php';
$pdo = new PDO('mysql:dbhost=' . $hostname . ';dbname=' . $database . ';charset=utf8', $dbuser, $dbpassword);
$db = new NotORM($pdo);
/* Get users */
$app->get('/users', function () use($app, $db) {
    try {
        $users = array();
        foreach ($db->users() as $user) {
            $users[] = array('id' => $user['id'], 'fname' => $user['fname'], 'lname' => $user['lname'], 'title' => $user['title'], 'username' => $user['username'], 'role' => $user['role'], 'email' => $user['email'], 'status' => $user['status']);
        }
        $app->response()->header('Content-Type', 'application/json');
        echo json_encode($users);
    } catch (Exception $e) {