Skip to content

Commit

Permalink
Add custom Pint configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
hofmannsven committed Mar 4, 2024
1 parent 5102d50 commit 9b0fa72
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
/.gitignore export-ignore
/.styleci.yml export-ignore
/phpunit.xml.dist export-ignore
/pint.json export-ignore
/art export-ignore
/tests export-ignore
6 changes: 6 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
preset: laravel

enabled:
- short_array_syntax
- declare_strict_types
- fully_qualified_strict_types
- protected_to_private

disabled:
- single_class_element_per_statement
10 changes: 10 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"preset": "laravel",
"rules": {
"array_syntax": true,
"declare_parentheses": true,
"declare_strict_types": true,
"fully_qualified_strict_types": true,
"protected_to_private": true
}
}
2 changes: 1 addition & 1 deletion src/Brevo.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class Brevo
{
protected Configuration $configuration;
private Configuration $configuration;

public function __construct()
{
Expand Down
4 changes: 1 addition & 3 deletions src/BrevoServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public function register(): void
$this->mergeConfigFrom(__DIR__.'/../config/brevo.php', 'brevo');

// Bind the service to the container.
$this->app->singleton('brevo', function () {
return new Brevo();
});
$this->app->singleton('brevo', fn () => new Brevo());
}
}
48 changes: 24 additions & 24 deletions tests/LaravelBrevoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,31 @@
use Orchestra\Testbench\TestCase as Orchestra;
use PHPUnit\Framework\Attributes\Test;

class LaravelBrevoTest extends Orchestra
final class LaravelBrevoTest extends Orchestra
{
#[Test]
public function it_tests_if_configuration_is_instance_of_brevo_client(): void
{
$this->assertInstanceOf(Configuration::class, Brevo::getConfiguration());
}

#[Test]
public function it_tests_if_configuration_is_set(): void
{
$config = new Configuration();
$brevo = new Brevo();
$brevo::setConfiguration($config);
$this->assertEquals($config, $brevo::getConfiguration());
}

#[Test]
public function it_tests_if_config_keys_are_set(): void
{
$config = Brevo::getConfiguration();
$this->assertEquals($config->getApiKey('api-key'), config('brevo.api_key'));
$this->assertEquals($config->getApiKey('partner-key'), config('brevo.partner_key'));
}

/**
* @param \Illuminate\Foundation\Application $app
*/
Expand Down Expand Up @@ -40,27 +63,4 @@ protected function getPackageAliases($app): array
'Brevo' => Brevo::class,
];
}

#[Test]
public function it_tests_if_configuration_is_instance_of_brevo_client(): void
{
$this->assertInstanceOf(Configuration::class, Brevo::getConfiguration());
}

#[Test]
public function it_tests_if_configuration_is_set(): void
{
$config = new Configuration();
$brevo = new Brevo();
$brevo::setConfiguration($config);
$this->assertEquals($config, $brevo::getConfiguration());
}

#[Test]
public function it_tests_if_config_keys_are_set(): void
{
$config = Brevo::getConfiguration();
$this->assertEquals($config->getApiKey('api-key'), config('brevo.api_key'));
$this->assertEquals($config->getApiKey('partner-key'), config('brevo.partner_key'));
}
}

0 comments on commit 9b0fa72

Please sign in to comment.