Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  Added coveralls.
  Added test cases for the service provider.
  Updated composer.json.

Conflicts:
	composer.json
  • Loading branch information
sumardi committed Dec 18, 2013
2 parents 651acbf + 935fe51 commit c6679d7
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 5 deletions.
1 change: 1 addition & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
service_name: travis-ci
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ php:

before_script:
- curl -s http://getcomposer.org/installer | php
- php composer.phar require satooshi/php-coveralls:dev-master --dev --no-progress --prefer-source
- php composer.phar install --dev

script: phpunit --coverage-text
script:
- mkdir -p build/logs
- phpunit --coverage-clover build/logs/clover.xml

after_script:
- php vendor/bin/coveralls -v
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"php": ">=5.3.0",
"illuminate/support": "4.1.x",
"illuminate/foundation": "4.1.x",
"php-instagram-api/php-instagram-api": "dev-master"
},
"require-dev": {
Expand All @@ -27,8 +27,8 @@
"component": "package",
"frameworks": ["Laravel 4"],
"branch-alias": {
"dev-master": "2.0-dev"
}
"dev-master": "2.0-dev"
}
},
"minimum-stability": "dev"
}
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
bootstrap="./tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
Expand Down
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();
}
}
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 tests/Elevencodes/InstagramLaravel/Tests/InstagramTestCase.php
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;
}
}
12 changes: 12 additions & 0 deletions tests/bootstrap.php
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';

0 comments on commit c6679d7

Please sign in to comment.