Skip to content

Commit

Permalink
Merge pull request #3 from m-shule/add-laravel-6-support
Browse files Browse the repository at this point in the history
support laravel 6
  • Loading branch information
ejimba authored Sep 10, 2019
2 parents 2dd543d + cc06a59 commit 36f3dd7
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 37 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"require": {
"php": ">=5.6.4",
"africastalking/africastalking": "^2.0",
"illuminate/notifications": "^5.3",
"illuminate/support": "^5.3"
"illuminate/notifications": "^5.3|^6.0",
"illuminate/support": "^5.3|^6.0"
},
"require-dev": {
"mockery/mockery": "^0.9.5",
"phpunit/phpunit": "4.*"
"orchestra/testbench": "^3.8|^4.0",
"phpunit/phpunit": "^8.0"
},
"autoload": {
"psr-4": {
Expand Down
10 changes: 3 additions & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<php>
<env name="DB_CONNECTION" value="testing"/>
</php>
</phpunit>
5 changes: 1 addition & 4 deletions src/AfricasTalkingChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,7 @@ protected function getFrom($notifiable, Notification $notification)
if ($from = $notification->toAfricasTalking($notifiable)->getFrom()) {
return $from;
}
if (function_exists('config') && $from = config('services.africastalking.from')) {
return $from;
}

return;
return config('services.africastalking.from');
}
}
28 changes: 14 additions & 14 deletions tests/AfricasTalkingChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

namespace MShule\AfricasTalking\Test;

use Mockery;
use AfricasTalking\SDK\AfricasTalking;
use Illuminate\Notifications\Notifiable;
use Illuminate\Notifications\Notification;
use MShule\AfricasTalking\AfricasTalkingChannel;
use MShule\AfricasTalking\AfricasTalkingMessage;
use Mockery;
use PHPUnit_Framework_TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

class AfricasTalkingChannelTest extends PHPUnit_Framework_TestCase
class AfricasTalkingChannelTest extends TestCase
{
use RefreshDatabase;

/** @var AfricasTalking */
private $client;

Expand All @@ -21,20 +23,18 @@ class AfricasTalkingChannelTest extends PHPUnit_Framework_TestCase
/** @var AfricasTalkingMessage */
private $message;

public function setUp()
public function setUp(): void
{
parent::setUp();

$this->loadLaravelMigrations();

$this->client = Mockery::mock(new AfricasTalking('sandbox', 'cc5053b1da44cf59a4d7d58caed6965e79498f991f7bac9b6885db594b7baa02'));
$this->channel = new AfricasTalkingChannel($this->client);
$this->message = new AfricasTalkingMessage();
}

public function tearDown()
{
Mockery::close();
parent::tearDown();
}

/*** @test ***/
/** @test */
public function it_can_be_instantiated()
{
$this->assertInstanceOf(AfricasTalking::class, $this->client);
Expand All @@ -45,8 +45,8 @@ public function it_can_be_instantiated()
/** @test */
public function it_can_send_a_notification()
{
$notifiable = new TestNotifiable;
$notification = new TestNotification;
$notifiable = new TestNotifiable();
$notification = new TestNotification();

$this->channel->send($notifiable, $notification);
}
Expand All @@ -66,6 +66,6 @@ class TestNotification extends Notification
{
public function toAfricasTalking($notifiable)
{
return (new AfricasTalkingMessage())->content('Hello World!');
return (new AfricasTalkingMessage())->content('Hello World!');
}
}
15 changes: 7 additions & 8 deletions tests/AfricasTalkingMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
namespace MShule\AfricasTalking\Test;

use MShule\AfricasTalking\AfricasTalkingMessage;
use PHPUnit_Framework_TestCase;

class AfricasTalkingMessageTest extends PHPUnit_Framework_TestCase
class AfricasTalkingMessageTest extends TestCase
{
/** @test */
public function it_can_be_instantiated()
{
$message = new AfricasTalkingMessage;
$message = new AfricasTalkingMessage();

$this->assertInstanceOf(AfricasTalkingMessage::class, $message);
}
Expand All @@ -35,39 +34,39 @@ public function it_supports_create_method()
/** @test */
public function it_can_set_content()
{
$message = (new AfricasTalkingMessage)->content('FooBar');
$message = (new AfricasTalkingMessage())->content('FooBar');

$this->assertEquals('FooBar', $message->getContent());
}

/** @test */
public function it_can_set_to()
{
$message = (new AfricasTalkingMessage)->to('+254712345678');
$message = (new AfricasTalkingMessage())->to('+254712345678');

$this->assertEquals('+254712345678', $message->getTo());
}

/** @test */
public function it_can_set_to_from_array()
{
$message = (new AfricasTalkingMessage)->to(['+254712345678', '+254712345679', '+254712345680']);
$message = (new AfricasTalkingMessage())->to(['+254712345678', '+254712345679', '+254712345680']);

$this->assertEquals('+254712345678,+254712345679,+254712345680', $message->getTo());
}

/** @test */
public function it_can_set_from()
{
$message = (new AfricasTalkingMessage)->from('+254712345678');
$message = (new AfricasTalkingMessage())->from('+254712345678');

$this->assertEquals('+254712345678', $message->getFrom());
}

/** @test */
public function it_supports_to_json_method()
{
$message = new AfricasTalkingMessage;
$message = new AfricasTalkingMessage();

$this->assertJson($message->toJson());
}
Expand Down
31 changes: 31 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace MShule\AfricasTalking\Test;

use Orchestra\Testbench\TestCase as Orchestra;

class TestCase extends Orchestra
{
/**
* Get package providers.
*
* @param \Illuminate\Foundation\Application $app
*
* @return array
*/
protected function getPackageProviders($app)
{
return [
\MShule\AfricasTalking\AfricasTalkingServiceProvider::class,
];
}

/**
* Define environment setup.
*
* @param \Illuminate\Foundation\Application $app
*/
protected function getEnvironmentSetUp($app)
{
}
}

0 comments on commit 36f3dd7

Please sign in to comment.