Skip to content

Commit

Permalink
Move HTTP comments to new directory layout and add auth unit test (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marlinc authored Aug 14, 2016
1 parent 3ed649e commit f32f66f
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace CvoTechnologies\Twitter\Network\Http\Adapter;
namespace CvoTechnologies\Twitter\Http\Adapter;

use Cake\Network\Http\Adapter\Stream;
use Cake\Network\Http\Request;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace CvoTechnologies\Twitter\Network\Http\Auth;
namespace CvoTechnologies\Twitter\Http\Client\Auth;

use Cake\Http\Client\Auth\Oauth;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace CvoTechnologies\Twitter\Network\Http;
namespace CvoTechnologies\Twitter\Http;

use Cake\Http\Client;
use Cake\Http\Client\Request;
Expand Down
4 changes: 2 additions & 2 deletions src/Webservice/Driver/Twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Cake\Cache\Cache;
use Cake\Network\Http\Client;
use Cake\Utility\Hash;
use CvoTechnologies\Twitter\Network\Http\StreamClient;
use CvoTechnologies\Twitter\Http\StreamClient;
use Muffin\Webservice\AbstractDriver;

/**
Expand Down Expand Up @@ -50,7 +50,7 @@ public function initialize()
$this->client(new Client($clientConfig));
$this->streamClient(new StreamClient(Hash::merge($clientConfig, [
'host' => 'stream.twitter.com',
'adapter' => 'CvoTechnologies\Twitter\Network\Http\Adapter\TwitterStream'
'adapter' => 'CvoTechnologies\Twitter\Http\Adapter\TwitterStream'
])));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Network/Http/Adapter/TwitterStreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Cake\Network\Http\Adapter\Stream;
use Cake\Network\Http\Request;
use Cake\TestSuite\TestCase;
use CvoTechnologies\Twitter\Network\Http\Adapter\TwitterStream;
use CvoTechnologies\Twitter\Http\Adapter\TwitterStream;

/**
* HTTP stream adapter test.
Expand Down
36 changes: 34 additions & 2 deletions tests/TestCase/Network/Http/Auth/TwitterTest.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
<?php

namespace CvoTechnologies\Twitter\Test\TestCase\Network\Http\Auth;
namespace CvoTechnologies\Twitter\Test\TestCase\Http\Client\Auth;

use Cake\Http\Client;
use Cake\Network\Http\Request;
use Cake\TestSuite\TestCase;
use CvoTechnologies\Twitter\Network\Http\Auth\Twitter;
use CvoTechnologies\StreamEmulation\Emulation\HttpEmulation;
use CvoTechnologies\StreamEmulation\StreamWrapper;
use CvoTechnologies\Twitter\Http\Client\Auth\Twitter;
use GuzzleHttp\Psr7\Response;

/**
* Oauth test.
*/
class TwitterTest extends TestCase
{
public function setUp()
{
parent::setUp();

StreamWrapper::overrideWrapper('https');
}

public function tearDown()
{
parent::tearDown();

StreamWrapper::restoreWrapper('https');
}

/**
* @expectedException \Cake\Core\Exception\Exception
*/
Expand Down Expand Up @@ -172,4 +190,18 @@ public function testHmacSigning()
urldecode($result)
);
}

public function testUsingAuth()
{
StreamWrapper::emulate(HttpEmulation::fromCallable(function () {
return new Response();
}));

$client = new Client([
'auth' => [
'type' => 'CvoTechnologies/Twitter.Twitter'
]
]);
$client->get('https://example.com');
}
}

0 comments on commit f32f66f

Please sign in to comment.