public static function setupBeforeClass()
 {
     self::$admin_user = User::from(['uid' => 1]);
     self::$simple_user = User::from(['uid' => 2]);
     self::$guest_user = new User();
     self::$resolver = new OwnershipResolver(['users' => __NAMESPACE__ . '\\Hooks::resolve_user_ownership']);
 }
Example #2
0
 /**
  * Creates user record.
  */
 protected function process_user()
 {
     global $core;
     try {
         $user = $core->models['users'][1];
     } catch (RecordNotFound $e) {
         $user = new User();
     }
     $options = $core->session->install['user'];
     $user->username = $options['username'];
     $user->email = $options['email'];
     $user->password = $options['password'];
     $user->language = $options['language'];
     $user->save();
     $user->login();
 }
 */
namespace Icybee\Modules\Users\NonceLogin;

use Icybee\Modules\Users\User;
global $core;
$vendor_dir = realpath(__DIR__ . '/../vendor');
require $vendor_dir . '/autoload.php';
/**
 * An instance of this class is used to fake the Session class that is used to handle sessions.
 * Instead of starting a session the class just does nothing.
 */
class FakeSession extends \ICanBoogie\Session
{
    public function __construct()
    {
    }
    public function regenerate_id()
    {
    }
    public function regenerate_token()
    {
    }
}
$core = new \ICanBoogie\Core(array('config paths' => array(__DIR__), 'modules paths' => array($vendor_dir . '/icanboogie-modules', realpath(__DIR__ . '/../')), 'connections' => array('primary' => array('dsn' => 'sqlite::memory:'))));
$core->site = (object) array('url' => 'http://testing.localhost', 'title' => 'testing', 'path' => '');
$core->session = new FakeSession();
$core();
$core->models['users']->install();
$core->models['users.noncelogin']->install();
$user = User::from(array('email' => '*****@*****.**', 'username' => 'olvlvl'));
$user->save();
Example #4
0
global $core;
$core = new \ICanBoogie\Core(\ICanBoogie\array_merge_recursive(\ICanBoogie\get_autoconfig(), ['config-path' => [__DIR__ . DIRECTORY_SEPARATOR . 'config'], 'module-path' => [realpath(__DIR__ . '/../')]]));
$core();
#
# Install modules
#
$errors = new \ICanBoogie\Errors();
foreach (array_keys($core->modules->enabled_modules_descriptors) as $module_id) {
    #
    # The index on the `constructor` column of the `nodes` module clashes with SQLite, we don't
    # care right now, so the exception is discarted.
    #
    try {
        $core->modules[$module_id]->install($errors);
    } catch (\Exception $e) {
        $errors[$module_id] = "Unable to install module: " . $e->getMessage();
    }
}
if ($errors->count()) {
    foreach ($errors as $error) {
        echo "{$module_id}: {$error}\n";
    }
    exit(1);
}
#
# Create a user
#
use Icybee\Modules\Users\User;
use Icybee\Modules\Sites\Site;
User::from(['username' => 'admin', 'email' => '*****@*****.**'])->save();
Site::from(['title' => 'example'])->save();
Example #5
0
 public function test_password()
 {
     $user = new User();
     $user->username = "******";
     $user->email = "*****@*****.**";
     $user->password = '******';
     $this->assertTrue($user->verify_password('P4SSW0RD'));
 }