-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
818 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Twitter\Test\API\Exception; | ||
|
||
use Twitter\API\Exception\TwitterException; | ||
|
||
class TwitterExceptionTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* Init | ||
*/ | ||
public function setUp() | ||
{ | ||
} | ||
|
||
/** | ||
* Close | ||
*/ | ||
public function tearDown() | ||
{ | ||
\Mockery::close(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itShouldCreateAnException() | ||
{ | ||
$exception = new TwitterException('message'); | ||
|
||
$this->assertEquals('message', $exception->getMessage()); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
tests/unit/API/Exception/TwitterRateLimitExceptionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Twitter\Test\API\Exception; | ||
|
||
use Twitter\API\Exception\TwitterException; | ||
use Twitter\API\Exception\TwitterRateLimitException; | ||
use Twitter\API\REST\DTO\Coordinates; | ||
use Twitter\API\REST\Response\LimitedApiRate; | ||
use Twitter\API\REST\Response\UnlimitedApiRate; | ||
|
||
class TwitterRateLimitExceptionTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* Init | ||
*/ | ||
public function setUp() | ||
{ | ||
} | ||
|
||
/** | ||
* Close | ||
*/ | ||
public function tearDown() | ||
{ | ||
\Mockery::close(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itShouldCreateAnException() | ||
{ | ||
$rate = new LimitedApiRate(5, 0, time()); | ||
$exception = TwitterRateLimitException::create('category', $rate); | ||
|
||
$this->assertEquals( | ||
'You have reached rate limit. You cannot make an API call yet.', | ||
$exception->getMessage() | ||
); | ||
|
||
$this->assertEquals('category', $exception->getCategory()); | ||
$this->assertEquals($rate->nextWindow(), $exception->nextWindow()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Twitter\Test\API\REST\DTO; | ||
|
||
use Twitter\API\REST\DTO\Coordinates; | ||
|
||
class CoordinatesTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* Init | ||
*/ | ||
public function setUp() | ||
{ | ||
} | ||
|
||
/** | ||
* Close | ||
*/ | ||
public function tearDown() | ||
{ | ||
\Mockery::close(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itShouldSerialize() | ||
{ | ||
$coordinates = new Coordinates(54, 42); | ||
|
||
$this->assertEquals(['lat' => 54, 'long' => 42], $coordinates->toArray()); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
tests/unit/API/REST/DTO/DeleteDirectMessageParametersTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Twitter\Test\API\REST\DTO; | ||
|
||
use Twitter\API\REST\DTO\DeleteDirectMessageParameters; | ||
|
||
class DeleteDirectMessageParametersTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* Init | ||
*/ | ||
public function setUp() | ||
{ | ||
} | ||
|
||
/** | ||
* Close | ||
*/ | ||
public function tearDown() | ||
{ | ||
\Mockery::close(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itShouldSerializeWithTrueValue() | ||
{ | ||
$parameters = new DeleteDirectMessageParameters(33, true); | ||
|
||
$this->assertEquals(['id' => 33, 'include_entities' => 'true'], $parameters->toArray()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itShouldSerializeWithFalseValue() | ||
{ | ||
$parameters = new DeleteDirectMessageParameters(33, false); | ||
|
||
$this->assertEquals(['id' => 33, 'include_entities' => 'false'], $parameters->toArray()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Twitter\Test\API\REST\DTO; | ||
|
||
use Twitter\API\REST\DTO\DeleteTweetParameters; | ||
|
||
class DeleteTweetParametersTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* Init | ||
*/ | ||
public function setUp() | ||
{ | ||
} | ||
|
||
/** | ||
* Close | ||
*/ | ||
public function tearDown() | ||
{ | ||
\Mockery::close(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itShouldSerializeWithTrueValue() | ||
{ | ||
$parameters = new DeleteTweetParameters(33, true); | ||
|
||
$this->assertEquals(['id' => 33, 'trim_user' => 'true'], $parameters->toArray()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itShouldSerializeWithFalseValue() | ||
{ | ||
$parameters = new DeleteTweetParameters(33, false); | ||
|
||
$this->assertEquals(['id' => 33, 'trim_user' => 'false'], $parameters->toArray()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Twitter\Test\API\REST\DTO; | ||
|
||
use Twitter\API\REST\DTO\DirectMessageParameters; | ||
use Twitter\API\REST\DTO\UserIdentifier; | ||
|
||
class DirectMessageParametersTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* Init | ||
*/ | ||
public function setUp() | ||
{ | ||
} | ||
|
||
/** | ||
* Close | ||
*/ | ||
public function tearDown() | ||
{ | ||
\Mockery::close(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itShouldSerializeWithIdIdentifier() | ||
{ | ||
$parameters = new DirectMessageParameters( | ||
UserIdentifier::fromId(33), | ||
'message' | ||
); | ||
|
||
$this->assertEquals(['user_id' => 33, 'text' => 'message'], $parameters->toArray()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itShouldSerializeWithNameIdentifier() | ||
{ | ||
$parameters = new DirectMessageParameters( | ||
UserIdentifier::fromScreenName('username'), | ||
'message' | ||
); | ||
|
||
$this->assertEquals(['screen_name' => 'username', 'text' => 'message'], $parameters->toArray()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Twitter\Test\API\REST\DTO; | ||
|
||
use Twitter\API\REST\DTO\FollowParameters; | ||
use Twitter\API\REST\DTO\UserIdentifier; | ||
|
||
class FollowParametersTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* Init | ||
*/ | ||
public function setUp() | ||
{ | ||
} | ||
|
||
/** | ||
* Close | ||
*/ | ||
public function tearDown() | ||
{ | ||
\Mockery::close(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itShouldSerializeWithIdIdentifierAndTrueValue() | ||
{ | ||
$parameters = new FollowParameters( | ||
UserIdentifier::fromId(33), | ||
true | ||
); | ||
|
||
$this->assertEquals(['user_id' => 33, 'follow' => 'true'], $parameters->toArray()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itShouldSerializeWithNameIdentifierAndFalseValue() | ||
{ | ||
$parameters = new FollowParameters( | ||
UserIdentifier::fromScreenName('username'), | ||
false | ||
); | ||
|
||
$this->assertEquals(['screen_name' => 'username', 'follow' => 'false'], $parameters->toArray()); | ||
} | ||
} |
Oops, something went wrong.