PHPackages                             magium/twitter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. magium/twitter

ActiveLibrary[Testing &amp; Quality](/categories/testing)

magium/twitter
==============

Provides a mechanism for logging in to Twitter to validate OAuth-based tests

1.1.1(9y ago)04611ASL-2.0PHP

Since Apr 6Pushed 8y ago1 watchersCompare

[ Source](https://github.com/magium/twitter)[ Packagist](https://packagist.org/packages/magium/twitter)[ Docs](https://github.com/magium/twitter)[ RSS](/packages/magium-twitter/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (1)Versions (5)Used By (1)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9655a6e28f6d2b3b27108d7f06e0f0f1815889c961cd4c1ec984b68c41fe9666/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d616769756d2f747769747465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/magium/twitter/?branch=master)

magium/twitter
==============

[](#magiumtwitter)

This is a simple library to help browser tests perform OAuth logins to Twitter.

To install

```
composer require magium/twitter

```

To use:

```
use Magium\Twitter\Actions\AuthenticateTwitter;

class TwitterTest extends \Magium\AbstractTestCase
{

    public function testLogin()
    {
        // Do something that forwards the browser to the twitter OAuth page.

         $action = $this->getAction(AuthenticateTwitter::ACTION);
        /* @var $action AuthenticateTwitter */
        $action->execute();
    }

}

```

Setting the username and password
---------------------------------

[](#setting-the-username-and-password)

There are two ways to set the username and password

### In code

[](#in-code)

```
use Magium\Twitter\Identities\Twitter
use Magium\Twitter\Actions\AuthenticateTwitter;

class TwitterTest extends \Magium\AbstractTestCase
{

    public function testLogin()
    {

        $identity = $this->getIdentity(Twitter::IDENTITY);
        /* @var $identity Twitter */
        $identity->setUsername('username');
        $identity->setPassword('password');

        // Do something that forwards the browser to the twitter OAuth page.

         $action = $this->getAction(AuthenticateTwitter::ACTION);
        /* @var $action AuthenticateTwitter */
        $action->execute();
    }

}

```

### In configuration

[](#in-configuration)

Create the file `/configuration/Magium/Twitter/Identities/Twitter.php` and enter the following:

```
