Skip to content

Commit

Permalink
Remove useless method. (#14)
Browse files Browse the repository at this point in the history
* complete usage docs.

* complete usage docs.

* complete usage docs.

* complete usage docs.

* complete usage docs.

* complete usage docs.

* complete usage docs.

* complete usage docs.

* complete usage docs.

* complete usage docs.

* complete usage docs.

* coding standard.

* update github action

* coding standard.

* remove unused dependencies.

* Marking class Message as deprecated.

* Marking class Message as deprecated.

* Marking class Message as deprecated.

* Marking class Message as deprecated.

* remove class Message. (#15)

* Remove useless method.

* Remove useless method.

* Remove useless method.
  • Loading branch information
zingimmick authored May 5, 2020
1 parent c51cd42 commit 16e9e07
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 46 deletions.
27 changes: 2 additions & 25 deletions src/Connectors/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,38 +116,15 @@ public function send($number, $message)
$message = $this->formatMessage($message);

try {
$this->sending($number, $message);
Event::dispatch(new SmsSending($number, $message));
Log::debug(sprintf('number: %s, message: "%s", template: "%s", data: %s, type: %s', $number, $message->getContent($this->driver), $message->getTemplate($this->driver), json_encode($message->getData($this->driver)), $message->getMessageType()));
$result = $this->driver->send($number, $message, $this->config);
Log::debug(sprintf('number: %s, message: "%s", template: "%s", data: %s, type: %s', $number, $message->getContent($this->driver), $message->getTemplate($this->driver), json_encode($message->getData($this->driver)), $message->getMessageType()), (array) $result);
$this->sent($number, $message, $result);
Event::dispatch(new SmsSent($number, $message, $result));

return $result;
} catch (Throwable $exception) {
throw CouldNotSendNotification::captureExceptionInDriver($exception);
}
}

/**
* @param \Overtrue\EasySms\PhoneNumber $number
* @param \Overtrue\EasySms\Message $message
*
* @deprecated useless method
*/
public function sending($number, $message): void
{
Event::dispatch(new SmsSending($number, $message));
}

/**
* @param \Overtrue\EasySms\PhoneNumber $number
* @param \Overtrue\EasySms\Message $message
* @param mixed $result
*
* @deprecated useless method
*/
public function sent($number, $message, $result): void
{
Event::dispatch(new SmsSent($number, $message, $result));
}
}
14 changes: 0 additions & 14 deletions src/Message.php

This file was deleted.

14 changes: 7 additions & 7 deletions tests/Drivers/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Zing\LaravelSms\Tests\Drivers;

use Exception;
use Mockery;
use Illuminate\Support\Facades\Event;
use Overtrue\EasySms\Message;
use Overtrue\EasySms\PhoneNumber;
use Zing\LaravelSms\Connectors\Connector;
Expand All @@ -18,21 +18,21 @@ public function testException(): void
{
$number = new PhoneNumber(18188888888);
$message = new Message([]);
$driver = Mockery::mock(Connector::class . '[sending]', [[]]);
$driver->shouldReceive('sending')->andThrow(new Exception('test'));
Event::fake();
Event::shouldReceive('dispatch')->andThrow(new Exception('test'));
$this->expectException(CouldNotSendNotification::class);
$this->expectExceptionMessage('test');
$driver->send($number, $message);
(new Connector([]))->send($number, $message);
}

public function testStaticException(): void
{
$number = new PhoneNumber(18188888888);
$message = new Message([]);
$driver = Mockery::mock(Connector::class . '[sending]', [[]]);
$driver->shouldReceive('sending')->andThrow(new CouldNotSendNotification('test'));
Event::fake();
Event::shouldReceive('dispatch')->andThrow(new CouldNotSendNotification('test'));
$this->expectException(CouldNotSendNotification::class);
$this->expectExceptionMessage('test');
$driver->send($number, $message);
(new Connector([]))->send($number, $message);
}
}

0 comments on commit 16e9e07

Please sign in to comment.