Skip to content

Commit

Permalink
added translator mock (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
takdeniz authored Mar 6, 2020
1 parent e578f92 commit 7513045
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"guzzlehttp/guzzle": "^6.5",
"illuminate/support": "^6.0|^7.0",
"illuminate/notifications": "^6.0|^7.0",
"illuminate/translation": "^6.0|^7.0",
"nesbot/carbon": "^2.0",
"ext-simplexml": "*"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/AbstractNetgsmException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ abstract class AbstractNetgsmException extends Exception
{
public function __construct($message = '', $code = 0, Throwable $previous = null)
{
parent::__construct(\Lang::get($message), $code, $previous);
parent::__construct(trans($message), $code, $previous);
}
}
2 changes: 1 addition & 1 deletion src/NetgsmChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function send($notifiable, Notification $notification)
$message = $notification->toNetgsm($notifiable);

if (! $message instanceof AbstractNetgsmMessage) {
throw new Exception(\Lang::get('netgsm::errors.invalid_netgsm_message'));
throw new Exception(trans('netgsm::errors.invalid_netgsm_message'));
}

if (! $message->getRecipients()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Sms/AbstractNetgsmMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function getSendMethod(): string
public function setSendMethod(string $sendMethod): self
{
if (! in_array($sendMethod, $this->sendMethods)) {
throw new Exception(\Lang::get('method_not_allowed', ['method' => $sendMethod]));
throw new Exception(trans('method_not_allowed', ['method' => $sendMethod]));
}

$this->sendMethod = $sendMethod;
Expand Down
11 changes: 11 additions & 0 deletions tests/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace TarfinLabs\Netgsm\Tests;

use Faker\Factory;
use Illuminate\Foundation\Application;
use Mockery;
use PHPUnit\Framework\TestCase;

class BaseTestCase extends TestCase
Expand All @@ -14,6 +16,15 @@ class BaseTestCase extends TestCase

public function setUp(): void
{
parent::setUp();
$this->faker = Factory::create();

$app = new Application();
$app->singleton('translator', function () {
$translate = Mockery::mock();
$translate->shouldReceive('get')->andReturnArg(0);

return $translate;
});
}
}

0 comments on commit 7513045

Please sign in to comment.