Skip to content

Commit

Permalink
Merge pull request #17 from rossjcooper/feature/php-cs-fixer
Browse files Browse the repository at this point in the history
Feature/php cs fixer
  • Loading branch information
rossjcooper authored Sep 29, 2019
2 parents 555953f + b96013f commit 82bb483
Show file tree
Hide file tree
Showing 11 changed files with 167 additions and 156 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
composer.lock
.DS_Store
.env
.phpunit.result.cache
.phpunit.result.cache
.php_cs.cache
17 changes: 17 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->in(__DIR__)
;

return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
])
->setIndent("\t")
->setLineEnding("\r\n")
->setFinder($finder)
;
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ php:
install:
- 'composer install'
script:
- vendor/bin/phpunit
- 'vendor/bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run --stop-on-violation --using-cache=no'
- 'vendor/bin/phpunit'
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"service"
],
"require-dev": {
"orchestra/testbench": ">=3.4"
"orchestra/testbench": ">=3.4",
"friendsofphp/php-cs-fixer": "^2.15"
}
}
33 changes: 18 additions & 15 deletions src/Facades/HubSpot.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<?php

namespace Rossjcooper\LaravelHubSpot\Facades;

use Illuminate\Support\Facades\Facade;

class HubSpot extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor() { return 'Rossjcooper\LaravelHubSpot\HubSpot'; }
}
<?php

namespace Rossjcooper\LaravelHubSpot\Facades;

use Illuminate\Support\Facades\Facade;

class HubSpot extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'Rossjcooper\LaravelHubSpot\HubSpot';
}
}
20 changes: 9 additions & 11 deletions src/HubSpot.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?php

namespace Rossjcooper\LaravelHubSpot;

use Illuminate\Support\ServiceProvider;
use SevenShores\Hubspot\Factory as Factory;

class HubSpot extends Factory
{

}
<?php

namespace Rossjcooper\LaravelHubSpot;

use SevenShores\Hubspot\Factory as Factory;

class HubSpot extends Factory
{
}
74 changes: 34 additions & 40 deletions src/HubSpotServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@
<?php

namespace Rossjcooper\LaravelHubSpot;

use Illuminate\Support\ServiceProvider;
use Rossjcooper\LaravelHubSpot\HubSpot;

class HubSpotServiceProvider extends ServiceProvider
{

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
//Bind the HubSpot wrapper class
$this->app->bind('Rossjcooper\LaravelHubSpot\HubSpot', function ($app) {
return HubSpot::create(
env('HUBSPOT_API_KEY', config('hubspot.api_key')),
null,
config('hubspot.client_options', [])
);
});
}

/**
* Perform post-registration booting of services.
*
* @return void
*/
public function boot()
{
// config
$this->publishes([
__DIR__ . '/config/hubspot.php' => config_path('hubspot.php')
], 'config');
}
}
<?php

namespace Rossjcooper\LaravelHubSpot;

use Illuminate\Support\ServiceProvider;

class HubSpotServiceProvider extends ServiceProvider
{
/**
* Register the service provider.
*/
public function register()
{
//Bind the HubSpot wrapper class
$this->app->bind('Rossjcooper\LaravelHubSpot\HubSpot', function ($app) {
return HubSpot::create(
env('HUBSPOT_API_KEY', config('hubspot.api_key')),
null,
config('hubspot.client_options', [])
);
});
}

/**
* Perform post-registration booting of services.
*/
public function boot()
{
// config
$this->publishes([
__DIR__.'/config/hubspot.php' => config_path('hubspot.php'),
], 'config');
}
}
20 changes: 9 additions & 11 deletions src/config/hubspot.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?php

return [

'api_key' => env('HUBSPOT_API_KEY'),

'client_options' => [
'http_errors' => true,
],

];
<?php

return [
'api_key' => env('HUBSPOT_API_KEY'),

'client_options' => [
'http_errors' => true,
],
];
47 changes: 23 additions & 24 deletions tests/API/ContactsTest.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
<?php

namespace Tests\API;

use Tests\TestCase;
use Rossjcooper\LaravelHubSpot\HubSpot;

class ContactsTest extends TestCase
{

public function test_get_contacts()
{
$hubspot = app(HubSpot::class);

$response = $hubspot->contacts()->all();

$contact = $response->contacts[0];

$this->assertIsArray($response->contacts);
// Test we have the default test contact
$this->assertEquals('Cool', $contact->properties->firstname->value);
$this->assertEquals('Robot (Sample Contact)', $contact->properties->lastname->value);
}
}
<?php

namespace Tests\API;

use Tests\TestCase;
use Rossjcooper\LaravelHubSpot\HubSpot;

class ContactsTest extends TestCase
{
public function test_get_contacts()
{
$hubspot = app(HubSpot::class);

$response = $hubspot->contacts()->all();

$contact = $response->contacts[0];

$this->assertIsArray($response->contacts);
// Test we have the default test contact
$this->assertEquals('Cool', $contact->properties->firstname->value);
$this->assertEquals('Robot (Sample Contact)', $contact->properties->lastname->value);
}
}
56 changes: 28 additions & 28 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<?php

namespace Tests;

use Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables;
use Orchestra\Testbench\TestCase as OrchTestCase;
use Rossjcooper\LaravelHubSpot\HubSpotServiceProvider;

abstract class TestCase extends OrchTestCase
{
/**
* Load our ServiceProvider
*/
protected function getPackageProviders($app)
{
return [HubSpotServiceProvider::class];
}

/**
* Loads in our package .env file
*/
protected function getEnvironmentSetUp($app)
{
$app->useEnvironmentPath(__DIR__ . '/..');
$app->bootstrapWith([LoadEnvironmentVariables::class]);
parent::getEnvironmentSetUp($app);
}
}
<?php

namespace Tests;

use Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables;
use Orchestra\Testbench\TestCase as OrchTestCase;
use Rossjcooper\LaravelHubSpot\HubSpotServiceProvider;

abstract class TestCase extends OrchTestCase
{
/**
* Load our ServiceProvider.
*/
protected function getPackageProviders($app)
{
return [HubSpotServiceProvider::class];
}

/**
* Loads in our package .env file.
*/
protected function getEnvironmentSetUp($app)
{
$app->useEnvironmentPath(__DIR__.'/..');
$app->bootstrapWith([LoadEnvironmentVariables::class]);
parent::getEnvironmentSetUp($app);
}
}
47 changes: 23 additions & 24 deletions tests/Unit/ServiceProviderTest.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
<?php

namespace Tests\Unit;

use Tests\TestCase;
use Rossjcooper\LaravelHubSpot\HubSpot;
use SevenShores\Hubspot\Factory;

class ServiceProviderTest extends TestCase
{
public function test_service_provider_bindings()
{
$hubspot = app(HubSpot::class);

$this->assertInstanceOf(HubSpot::class, $hubspot);
}

public function test_api_key_set()
{
$hubspot = app(HubSpot::class);

$this->assertEquals(env('HUBSPOT_API_KEY'), $hubspot->client->key);
}
}
<?php

namespace Tests\Unit;

use Tests\TestCase;
use Rossjcooper\LaravelHubSpot\HubSpot;

class ServiceProviderTest extends TestCase
{
public function test_service_provider_bindings()
{
$hubspot = app(HubSpot::class);

$this->assertInstanceOf(HubSpot::class, $hubspot);
}

public function test_api_key_set()
{
$hubspot = app(HubSpot::class);

$this->assertEquals(env('HUBSPOT_API_KEY'), $hubspot->client->key);
}
}

0 comments on commit 82bb483

Please sign in to comment.