public function testCanAuthenticateWithGoodCredentials()
 {
     $authAdapter = Bootstrap::getServiceManager()->get('ZfSimpleAuth\\Authentication\\Adapter');
     $authAdapter->setIdentity('demo-admin');
     $authAdapter->setCredential('foobar');
     $result = $this->authenticationService->authenticate($authAdapter);
     $this->assertTrue($result->isValid());
     $identity = $this->authenticationService->getIdentity();
     $this->assertInstanceOf('\\ZfSimpleAuth\\Authentication\\Identity', $identity);
     /* @var \ZfSimpleAuth\Authentication\Identity $identity */
     $this->assertEquals('demo-admin', $identity->getName());
     $this->assertEquals(array('admin', 'member'), $identity->getRoles());
 }
 public function setUp()
 {
     $this->setApplicationConfig(Bootstrap::getConfig());
     parent::setUp();
 }
示例#3
0
        $dir = __DIR__;
        $previousDir = '.';
        while (!is_dir($dir . '/' . $path)) {
            $dir = dirname($dir);
            if ($previousDir === $dir) {
                return false;
            }
            $previousDir = $dir;
        }
        return $dir . '/' . $path;
    }
    protected static function initAutoloader()
    {
        $vendorPath = static::findParentPath('vendor');
        $zf2Path = $vendorPath . '/zendframework/zendframework/library';
        if (!$zf2Path) {
            throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or' . ' define a ZF2_PATH environment variable.');
        }
        if (file_exists($vendorPath . '/autoload.php')) {
            include $vendorPath . '/autoload.php';
        }
        include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
        AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array(__NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__))));
    }
    public static function getServiceManager()
    {
        return static::$serviceManager;
    }
}
Bootstrap::init();