-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* develop: Added coveralls. Added test cases for the service provider. Updated composer.json. Conflicts: composer.json
- Loading branch information
Showing
8 changed files
with
137 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
service_name: travis-ci |
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
22 changes: 22 additions & 0 deletions
22
tests/Elevencodes/InstagramLaravel/Tests/InstagramLaravelFacadeTest.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,22 @@ | ||
<?php namespace Elevencodes\InstagramLaravel\Tests; | ||
|
||
use Elevencodes\InstagramLaravel\Facades\InstagramLaravel as Instagram; | ||
|
||
class InstagramLaravelFacadeTest extends InstagramTestCase | ||
{ | ||
/** | ||
* @expectedException Instagram\Core\ApiAuthException | ||
*/ | ||
public function testFacadeCanBeResolvedToServiceInstance() | ||
{ | ||
$app = $this->setupApplication(); | ||
$instagram = $this->setupServiceProvider($app); | ||
$app->register($instagram); | ||
$instagram->boot(); | ||
$app['session']->set('instagram_access_token', 'foo'); | ||
|
||
// Mount facades | ||
Instagram::setFacadeApplication($app); | ||
Instagram::getCurrentUser(); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
tests/Elevencodes/InstagramLaravel/Tests/InstagramLaravelServiceProviderTest.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,35 @@ | ||
<?php namespace Elevencodes\InstagramLaravel\Tests; | ||
|
||
class InstagramLaravelServiceProviderTest extends InstagramTestCase | ||
{ | ||
public function testRegisterServiceProviderWithPackageConfig() | ||
{ | ||
$app = $this->setupApplication(); | ||
$instagram = $this->setupServiceProvider($app); | ||
$app->register($instagram); | ||
$instagram->boot(); | ||
|
||
$instance = $app['instagram']; | ||
$this->assertInstanceOf('Instagram\Auth', $instance); | ||
} | ||
|
||
public function testRegisterServiceProviderWithInstagramSession() | ||
{ | ||
$app = $this->setupApplication(); | ||
$instagram = $this->setupServiceProvider($app); | ||
$session = $app['session']; | ||
$session->set('instagram_access_token', 'foo'); | ||
$app->register($instagram); | ||
$instagram->boot(); | ||
|
||
$instance = $app['instagram']; | ||
$this->assertInstanceOf('Instagram\Instagram', $instance); | ||
} | ||
|
||
public function testServiceNameIsProvided() | ||
{ | ||
$app = $this->setupApplication(); | ||
$provider = $this->setupServiceProvider($app); | ||
$this->assertContains('instagram', $provider->provides()); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
tests/Elevencodes/InstagramLaravel/Tests/InstagramTestCase.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,56 @@ | ||
<?php namespace Elevencodes\InstagramLaravel\Tests; | ||
|
||
use Illuminate\Config\Repository; | ||
use Illuminate\Filesystem\Filesystem; | ||
use Illuminate\Foundation\Application; | ||
use Illuminate\Session\SessionServiceProvider; | ||
use Elevencodes\InstagramLaravel\InstagramLaravelServiceProvider; | ||
|
||
abstract class InstagramTestCase extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* Setup application. | ||
* | ||
* @return Application | ||
*/ | ||
protected function setupApplication() | ||
{ | ||
// Create the application such that the config is loaded | ||
$app = new Application(); | ||
$app->instance('path', 'foobar'); | ||
$app->instance('files', new Filesystem); | ||
$app->instance('config', new Repository($app->getConfigLoader(), 'foobar')); | ||
|
||
return $app; | ||
} | ||
|
||
/** | ||
* Setup service provider. | ||
* | ||
* @param Application $app | ||
* @return InstagramLaravelServiceProvider | ||
*/ | ||
protected function setupServiceProvider(Application $app) | ||
{ | ||
$this->setupSessionServiceProvider($app); | ||
$instagram = new InstagramLaravelServiceProvider($app); | ||
// $app->register($instagram); | ||
// $instagram->boot(); | ||
|
||
return $instagram; | ||
} | ||
|
||
/** | ||
* Setup session service provider. | ||
* | ||
* @param Application $app | ||
* @return SessionServiceProvider | ||
*/ | ||
protected function setupSessionServiceProvider(Application $app) | ||
{ | ||
$session = new SessionServiceProvider($app); | ||
$app->register($session); | ||
|
||
return $session; | ||
} | ||
} |
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,12 @@ | ||
<?php | ||
|
||
// Make sure Composer has been run | ||
if (!file_exists(__DIR__ . '/../composer.lock')) { | ||
die('You must do a Composer install before running the tests.'); | ||
} | ||
|
||
// Include Composer autoloader | ||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
// Include the base test class that doesn't get autoloaded | ||
require_once __DIR__ . '/Elevencodes/InstagramLaravel/Tests/InstagramTestCase.php'; |