magium/auth0

提供使用Auth0身份验证平台的一种机制

0.0.3 2018-02-12 13:53 UTC

This package is not auto-updated.

Last update: 2024-09-14 18:47:41 UTC


README

目前,这个项目还在开发中,只支持Twitter,尽管添加其他身份验证方法并不困难(并且将添加)。

此库的目的是提供一种在Magium中通过Auth0服务进行浏览器测试自动化的方法。

配置您的Twitter账户

在您的测试项目中创建一个名为 /configuration/Magium/Twitter/Identities/Twitter.php 的文件,其中包含您的Twitter凭据

<?php

/* @var $this \Magium\Twitter\Identities\Twitter */
$this->username = 'username';
$this->password = 'password';

然后在您的Magium测试中,简单地让Auth0动作为您进行身份验证。

<?php

namespace Tests\Magium\Auth0;

use Facebook\WebDriver\WebDriverBy;
use Magium\AbstractTestCase;
use Magium\Auth0\Actions\Login;
use Magium\Auth0\Identities\Twitter;
use Magium\WebDriver\ExpectedCondition;
use Magium\WebDriver\WebDriver;

class TwitterTest extends AbstractTestCase
{

    public function testTwitterAuth()
    {
        $this->commandOpen('http://magiumlib.loc/');
        $this->byText('Log In')->click();
        $action = $this->getAction(Login::ACTION);
        /* @var $action Login */
        $action->setIdentity($this->getIdentity(Twitter::IDENTITY));
        $action->execute();

        $this->webdriver->wait(5)->until(ExpectedCondition::elementExists('login-link'));

    }

}

BOOM! 已认证。