/**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $this->object = new BasicAuthentication();
     //NOTE, in order testAuthenticateSuccess to work all users must
     //have this password
     self::$users = [['id' => 1, 'email' => '*****@*****.**', 'password' => password_hash('123456', PASSWORD_BCRYPT), 'user_type' => 'user'], ['id' => 2, 'email' => '*****@*****.**', 'password' => password_hash('123456', PASSWORD_BCRYPT), 'user_type' => 'moderator']];
     //Initliaze Phramework
     $phramework = new Phramework([], new \Phramework\URIStrategy\URITemplate([]));
     //Set authentication class
     \Phramework\Authentication\Manager::register(BasicAuthentication::class);
     //Set method to fetch user object, including password attribute
     \Phramework\Authentication\Manager::setUserGetByEmailMethod([BasicAuthenticationTest::class, 'getByEmailWithPassword']);
     \Phramework\Authentication\Manager::setAttributes(['user_type', 'email']);
     \Phramework\Authentication\Manager::setOnCheckCallback(function ($params) {
         //var_dump($params);
     });
     \Phramework\Authentication\Manager::setOnAuthenticateCallback(function ($data) {
         //var_dump($params);
     });
 }
Example #2
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $this->object = new JWT();
     //NOTE, in order testAuthenticateSuccess to work all users must
     //have this password
     self::$users = [['id' => 1, 'email' => '*****@*****.**', 'password' => password_hash('123456', PASSWORD_BCRYPT), 'user_type' => 'user'], ['id' => 2, 'email' => '*****@*****.**', 'password' => password_hash('123456', PASSWORD_BCRYPT), 'user_type' => 'moderator']];
     $settings = ['jwt' => ['secret' => 'aabsLgq31/K+zXcyAqpdaabszyaabsoatAmnuwaH0Pgx4lzqjHtBmQ==', 'algorithm' => 'HS256', 'server' => 'test']];
     //Initliaze Phramework, to set settings
     $phramework = new Phramework($settings, new \Phramework\URIStrategy\URITemplate([]));
     //Set authentication class
     \Phramework\Authentication\Manager::register(JWT::class);
     //Set method to fetch user object, including password attribute
     \Phramework\Authentication\Manager::setUserGetByEmailMethod([JWTTest::class, 'getByEmailWithPassword']);
     \Phramework\Authentication\Manager::setAttributes(['user_type', 'email']);
     \Phramework\Authentication\Manager::setOnCheckCallback(function ($params) {
         //var_dump($params);
     });
     \Phramework\Authentication\Manager::setOnAuthenticateCallback(function ($params) {
         //var_dump($params);
     });
 }