Skip to content

Commit

Permalink
styleci fixes
Browse files Browse the repository at this point in the history
styleci fixes
  • Loading branch information
webrobert committed Jan 28, 2023
1 parent 8bc3beb commit 0eb782a
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 76 deletions.
32 changes: 16 additions & 16 deletions build/report.junit.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="" tests="9" assertions="13" errors="0" warnings="0" failures="0" skipped="0" time="1.167195">
<testsuite name="Unit" tests="6" assertions="9" errors="0" warnings="0" failures="0" skipped="0" time="0.218702">
<testsuite name="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" tests="6" assertions="9" errors="0" warnings="0" failures="0" skipped="0" time="0.218702">
<testcase name="testSmsIsSentViaClickSend" class="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" classname="NotificationChannels.ClickSend.Test.Unit.Channels.ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" line="22" assertions="1" time="0.217510"/>
<testcase name="testSmsIsSentViaClickSendWithCustomClient" class="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" classname="NotificationChannels.ClickSend.Test.Unit.Channels.ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" line="47" assertions="2" time="0.000376"/>
<testcase name="testSmsIsSentViaClickSendWithCustomFrom" class="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" classname="NotificationChannels.ClickSend.Test.Unit.Channels.ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" line="75" assertions="1" time="0.000161"/>
<testcase name="testSmsIsSentViaClickSendWithCustomFromAndClient" class="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" classname="NotificationChannels.ClickSend.Test.Unit.Channels.ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" line="100" assertions="2" time="0.000275"/>
<testcase name="testSmsIsSentViaClickSendWithCustomFromAndCustomString" class="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" classname="NotificationChannels.ClickSend.Test.Unit.Channels.ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" line="129" assertions="1" time="0.000183"/>
<testcase name="testSmsIsSentViaClickSendWithCustomClientFromAndClientRef" class="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" classname="NotificationChannels.ClickSend.Test.Unit.Channels.ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" line="155" assertions="2" time="0.000197"/>
<testsuite name="" tests="9" assertions="13" errors="0" warnings="0" failures="0" skipped="0" time="1.490965">
<testsuite name="Unit" tests="6" assertions="9" errors="0" warnings="0" failures="0" skipped="0" time="0.334244">
<testsuite name="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" tests="6" assertions="9" errors="0" warnings="0" failures="0" skipped="0" time="0.334244">
<testcase name="testSmsIsSentViaClickSend" class="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" classname="NotificationChannels.ClickSend.Test.Unit.Channels.ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" line="21" assertions="1" time="0.332520"/>
<testcase name="testSmsIsSentViaClickSendWithCustomClient" class="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" classname="NotificationChannels.ClickSend.Test.Unit.Channels.ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" line="46" assertions="2" time="0.000437"/>
<testcase name="testSmsIsSentViaClickSendWithCustomFrom" class="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" classname="NotificationChannels.ClickSend.Test.Unit.Channels.ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" line="74" assertions="1" time="0.000163"/>
<testcase name="testSmsIsSentViaClickSendWithCustomFromAndClient" class="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" classname="NotificationChannels.ClickSend.Test.Unit.Channels.ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" line="99" assertions="2" time="0.000581"/>
<testcase name="testSmsIsSentViaClickSendWithCustomFromAndCustomString" class="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" classname="NotificationChannels.ClickSend.Test.Unit.Channels.ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" line="128" assertions="1" time="0.000186"/>
<testcase name="testSmsIsSentViaClickSendWithCustomClientFromAndClientRef" class="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" classname="NotificationChannels.ClickSend.Test.Unit.Channels.ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" line="154" assertions="2" time="0.000356"/>
</testsuite>
</testsuite>
<testsuite name="Feature" tests="3" assertions="4" errors="0" warnings="0" failures="0" skipped="0" time="0.948493">
<testsuite name="NotificationChannels\ClickSend\Test\Feature\ClientAPICredentialsTest" file="/app/tests/Feature/ClientAPICredentialsTest.php" tests="1" assertions="1" errors="0" warnings="0" failures="0" skipped="0" time="0.869834">
<testcase name="testClientCreatedWithBasicAPICredentials" class="NotificationChannels\ClickSend\Test\Feature\ClientAPICredentialsTest" classname="NotificationChannels.ClickSend.Test.Feature.ClientAPICredentialsTest" file="/app/tests/Feature/ClientAPICredentialsTest.php" line="15" assertions="1" time="0.869834"/>
<testsuite name="Feature" tests="3" assertions="4" errors="0" warnings="0" failures="0" skipped="0" time="1.156721">
<testsuite name="NotificationChannels\ClickSend\Test\Feature\ClientAPICredentialsTest" file="/app/tests/Feature/ClientAPICredentialsTest.php" tests="1" assertions="1" errors="0" warnings="0" failures="0" skipped="0" time="1.054659">
<testcase name="testClientCreatedWithBasicAPICredentials" class="NotificationChannels\ClickSend\Test\Feature\ClientAPICredentialsTest" classname="NotificationChannels.ClickSend.Test.Feature.ClientAPICredentialsTest" file="/app/tests/Feature/ClientAPICredentialsTest.php" line="15" assertions="1" time="1.054659"/>
</testsuite>
<testsuite name="NotificationChannels\ClickSend\Test\Feature\ClientAccountCredentialsTest" file="/app/tests/Feature/ClientAccountCredentialsTest.php" tests="1" assertions="1" errors="0" warnings="0" failures="0" skipped="0" time="0.036415">
<testcase name="testClientCreatedWithBasicAPICredentials" class="NotificationChannels\ClickSend\Test\Feature\ClientAccountCredentialsTest" classname="NotificationChannels.ClickSend.Test.Feature.ClientAccountCredentialsTest" file="/app/tests/Feature/ClientAccountCredentialsTest.php" line="15" assertions="1" time="0.036415"/>
<testsuite name="NotificationChannels\ClickSend\Test\Feature\ClientAccountCredentialsTest" file="/app/tests/Feature/ClientAccountCredentialsTest.php" tests="1" assertions="1" errors="0" warnings="0" failures="0" skipped="0" time="0.058399">
<testcase name="testClientCreatedWithBasicAPICredentials" class="NotificationChannels\ClickSend\Test\Feature\ClientAccountCredentialsTest" classname="NotificationChannels.ClickSend.Test.Feature.ClientAccountCredentialsTest" file="/app/tests/Feature/ClientAccountCredentialsTest.php" line="15" assertions="1" time="0.058399"/>
</testsuite>
<testsuite name="NotificationChannels\ClickSend\Test\Feature\NoClickSendConfigurationTest" file="/app/tests/Feature/NoClickSendConfigurationTest.php" tests="1" assertions="2" errors="0" warnings="0" failures="0" skipped="0" time="0.042244">
<testcase name="testWhenNoConfigurationIsGivenExceptionIsRaised" class="NotificationChannels\ClickSend\Test\Feature\NoClickSendConfigurationTest" classname="NotificationChannels.ClickSend.Test.Feature.NoClickSendConfigurationTest" file="/app/tests/Feature/NoClickSendConfigurationTest.php" line="15" assertions="2" time="0.042244"/>
<testsuite name="NotificationChannels\ClickSend\Test\Feature\NoClickSendConfigurationTest" file="/app/tests/Feature/NoClickSendConfigurationTest.php" tests="1" assertions="2" errors="0" warnings="0" failures="0" skipped="0" time="0.043664">
<testcase name="testWhenNoConfigurationIsGivenExceptionIsRaised" class="NotificationChannels\ClickSend\Test\Feature\NoClickSendConfigurationTest" classname="NotificationChannels.ClickSend.Test.Feature.NoClickSendConfigurationTest" file="/app/tests/Feature/NoClickSendConfigurationTest.php" line="15" assertions="2" time="0.043664"/>
</testsuite>
</testsuite>
</testsuite>
Expand Down
22 changes: 11 additions & 11 deletions src/ClickSend.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace NotificationChannels\ClickSend;

use Psr\Http\Client\ClientInterface;
use ClickSend\Api\SMSApi as Client;
use ClickSend\Configuration;
use Psr\Http\Client\ClientInterface;
use RuntimeException;

class ClickSend
Expand All @@ -27,8 +27,7 @@ class ClickSend
* Create a new ClickSend instance.
*
* @param array $config
* @param ClientInterface|null $client
*
* @param ClientInterface|null $client
* @return void
*/
public function __construct(array $config = [], ?ClientInterface $client = null)
Expand All @@ -41,8 +40,7 @@ public function __construct(array $config = [], ?ClientInterface $client = null)
* Create a new ClickSend instance.
*
* @param array $config
* @param ClientInterface|null $client
*
* @param ClientInterface|null $client
* @return static
*/
public static function make(array $config, ?ClientInterface $client = null)
Expand All @@ -57,15 +55,15 @@ public static function make(array $config, ?ClientInterface $client = null)
*
* @throws \RuntimeException
*/
public function client() : Client
public function client(): Client
{
[$username, $password] = $this->firstComboOrFail([
'apiCredentials' => [
$this->config['api_username'], $this->config['api_key']
$this->config['api_username'], $this->config['api_key'],
],
'accountCredentials' => [
$this->config['account_username'], $this->config['account_password']
]
$this->config['account_username'], $this->config['account_password'],
],
]);

$credentials = Configuration::getDefaultConfiguration()
Expand All @@ -78,9 +76,11 @@ public function client() : Client
private function firstComboOrFail(array $combos)
{
$credentials = collect($combos)
->first( function($pair) { return ! in_array(null, $pair,true); });
->first(function ($pair) {
return ! in_array(null, $pair, true);
});

if(! $credentials) {
if (! $credentials) {
throw new RuntimeException('Please provide your ClickSend API credentials.
Possible combinations: api_username + api_key OR account_username + account_password.');
}
Expand Down
26 changes: 12 additions & 14 deletions src/ClickSendChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace NotificationChannels\ClickSend;

use NotificationChannels\ClickSend\Exceptions\CouldNotSendNotification;
use ClickSend\Api\SMSApi as ClickSendClient;
use Illuminate\Notifications\Notification;
use ClickSend\Model\SmsMessageCollection;
use ClickSend\Model\SmsMessage;
use ClickSend\ApiException;
use ClickSend\Model\SmsMessage;
use ClickSend\Model\SmsMessageCollection;
use Illuminate\Notifications\Notification;
use NotificationChannels\ClickSend\Exceptions\CouldNotSendNotification;

class ClickSendChannel
{
Expand All @@ -28,9 +28,8 @@ class ClickSendChannel
/**
* Create a new ClickSend channel instance.
*
* @param ClickSendClient $client
* @param string $from
*
* @param ClickSendClient $client
* @param string $from
* @return void
*/
public function __construct(ClickSendClient $client, $from)
Expand All @@ -43,7 +42,7 @@ public function __construct(ClickSendClient $client, $from)
* Send the given notification.
*
* @param mixed $notifiable
* @param Notification $notification
* @param Notification $notification
* @return mixed
*/
public function send($notifiable, Notification $notification): void
Expand All @@ -64,15 +63,14 @@ public function send($notifiable, Notification $notification): void
'body' => trim($message->content),
'from' => $message->from ?: $this->from,
'source' => 'laravel',
'custom_string' => $message->reference
])
'custom_string' => $message->reference,
]),
]);

try {
( $message->client ?? $this->client )->smsSendPost( $sms_messages );
}
catch (ApiException $e) {
($message->client ?? $this->client)->smsSendPost($sms_messages);
} catch (ApiException $e) {
throw CouldNotSendNotification::ClickSendApiException($e);
};
}
}
}
14 changes: 7 additions & 7 deletions src/ClickSendMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ClickSendMessage
/**
* Create a new message instance.
*
* @param string $content
* @param string $content
* @return void
*/
public function __construct($content = '')
Expand All @@ -55,7 +55,7 @@ public function __construct($content = '')
/**
* Set the message content.
*
* @param string $content
* @param string $content
* @return ClickSendMessage
*/
public function content($content)
Expand All @@ -68,7 +68,7 @@ public function content($content)
/**
* Set the phone number the message should be sent from.
*
* @param string $from
* @param string $from
* @return $this
*/
public function from($from)
Expand All @@ -81,7 +81,7 @@ public function from($from)
/**
* Set the client reference (up to 40 characters).
*
* @param string $string
* @param string $string
* @return $this
*/
public function reference($string)
Expand All @@ -91,16 +91,16 @@ public function reference($string)
return $this;
}


/**
* Set the ClickSend SMS client instance.
*
* @param SMSApi $client
* @param SMSApi $client
* @return $this
*/
public function usingClient($client)
{
$this->client = $client;

return $this;
}}
}
}
2 changes: 1 addition & 1 deletion src/ClickSendServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace NotificationChannels\ClickSend;

use ClickSend\Api\SMSApi as Client;
use Illuminate\Notifications\ChannelManager;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\ServiceProvider;
use ClickSend\Api\SMSApi as Client;
use RuntimeException;

class ClickSendServiceProvider extends ServiceProvider
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/CouldNotSendNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CouldNotSendNotification extends \Exception
public static function ClickSendApiException(ApiException $exception): self
{
return new static(
"ClickSend could not send and responded with an error.", null, $exception
'ClickSend could not send and responded with an error.', null, $exception
);
}
}
2 changes: 1 addition & 1 deletion src/Facades/ClickSend.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ClickSend extends Facade
*
* @return string
*/
protected static function getFacadeAccessor() : string
protected static function getFacadeAccessor(): string
{
return Client::class;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/ClientAPICredentialsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function testClientCreatedWithBasicAPICredentials()
{
$credentials = $this->app->make(Client::class)->getConfig();

$this->assertEquals([ 'my_username', 'my_api_key' ],
[ $credentials->getUsername(), $credentials->getPassword() ]);
$this->assertEquals(['my_username', 'my_api_key'],
[$credentials->getUsername(), $credentials->getPassword()]);
}
}
4 changes: 2 additions & 2 deletions tests/Feature/ClientAccountCredentialsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function testClientCreatedWithBasicAPICredentials()
{
$credentials = $this->app->make(Client::class)->getConfig();

$this->assertEquals([ 'my_username', 'my_account_password' ],
[ $credentials->getUsername(), $credentials->getPassword() ]);
$this->assertEquals(['my_username', 'my_account_password'],
[$credentials->getUsername(), $credentials->getPassword()]);
}
}
2 changes: 1 addition & 1 deletion tests/Feature/NoClickSendConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected function getEnvironmentSetUp($app)
public function testWhenNoConfigurationIsGivenExceptionIsRaised()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage( 'Please provide your ClickSend API credentials.
$this->expectExceptionMessage('Please provide your ClickSend API credentials.
Possible combinations: api_username + api_key OR account_username + account_password.');
app(Client::class);
}
Expand Down
39 changes: 19 additions & 20 deletions tests/Unit/Channels/ClickSendSmsChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

namespace NotificationChannels\ClickSend\Test\Unit\Channels;

use ClickSend\Api\SMSApi;
use ClickSend\Api\SMSApi as Client;
use ClickSend\Model\SmsMessage as SMS;
use ClickSend\Model\SmsMessageCollection;
use Hamcrest\Core\IsEqual;
use Illuminate\Notifications\Notifiable;
use Illuminate\Notifications\Notification;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use Mockery as m;
use NotificationChannels\ClickSend\ClickSendChannel;
use NotificationChannels\ClickSend\ClickSendMessage;
use Illuminate\Notifications\Notification;
use ClickSend\Model\SmsMessageCollection;
use Illuminate\Notifications\Notifiable;
use ClickSend\Model\SmsMessage as SMS;
use ClickSend\Api\SMSApi as Client;
use PHPUnit\Framework\TestCase;
use Hamcrest\Core\IsEqual;
use Mockery as m;

class ClickSendSmsChannelTest extends TestCase
{
Expand All @@ -33,8 +32,8 @@ public function testSmsIsSentViaClickSend()
'to' => '5555555555',
'from' =>'4444444444',
'body' => 'this is my message',
'source' => 'laravel'
])
'source' => 'laravel',
]),
]);

$clickSend->shouldReceive('smsSendPost')
Expand All @@ -51,8 +50,8 @@ public function testSmsIsSentViaClickSendWithCustomClient()
'to' => '5555555555',
'from' =>'4444444444',
'body' => 'this is my message',
'source' => 'laravel'
])
'source' => 'laravel',
]),
]);

$customClickSend = m::mock(Client::class);
Expand Down Expand Up @@ -86,8 +85,8 @@ public function testSmsIsSentViaClickSendWithCustomFrom()
'to' => '5555555555',
'from' =>'5554443333',
'body' => 'this is my message',
'source' => 'laravel'
])
'source' => 'laravel',
]),
]);

$clickSend->shouldReceive('smsSendPost')
Expand All @@ -106,8 +105,8 @@ public function testSmsIsSentViaClickSendWithCustomFromAndClient()
'to' => '5555555555',
'from' =>'5554443333',
'body' => 'this is my message',
'source' => 'laravel'
])
'source' => 'laravel',
]),
]);

$customClickSend->shouldReceive('smsSendPost')
Expand Down Expand Up @@ -141,8 +140,8 @@ public function testSmsIsSentViaClickSendWithCustomFromAndCustomString()
'from' =>'5554443333',
'body' => 'this is my message',
'source' => 'laravel',
'custom_string' => '11'
])
'custom_string' => '11',
]),
]);

$clickSend->shouldReceive('smsSendPost')
Expand All @@ -162,8 +161,8 @@ public function testSmsIsSentViaClickSendWithCustomClientFromAndClientRef()
'from' =>'5554443333',
'body' => 'this is my message',
'source' => 'laravel',
'custom_string' => '11'
])
'custom_string' => '11',
]),
]);

$customClickSend->shouldReceive('smsSendPost')
Expand Down

0 comments on commit 0eb782a

Please sign in to comment.