diff --git a/tests/Gateways/HuaxinGatewayTest.php b/tests/Gateways/HuaxinGatewayTest.php index 052c12f0d554671ebe72313bfb3ef79618f75963..09432530d8206fd93b0efec7cb73e912fef280b0 100644 --- a/tests/Gateways/HuaxinGatewayTest.php +++ b/tests/Gateways/HuaxinGatewayTest.php @@ -35,7 +35,7 @@ class HuaxinGatewayTest extends TestCase 'password' => 'mock-password', 'account' => 'mock-account', 'mobile' => 18188888888, - 'content' => '【TIGERB】This is a test message.', + 'content' => 'This is a test message.', 'sendTime' => '', 'action' => 'send', 'extno' => '', @@ -53,7 +53,7 @@ class HuaxinGatewayTest extends TestCase 'successCounts' => '0', ])->times(2); - $message = new Message(['content' => '【TIGERB】This is a test message.']); + $message = new Message(['content' => 'This is a test message.']); $config = new Config($config); $this->assertSame( [ diff --git a/tests/Gateways/HuyiGatewayTest.php b/tests/Gateways/HuyiGatewayTest.php index a12e7e446e5f87989e61c014860d07d7c08b8531..dab65fbbb7c01c16513306b74ff38539d93eb209 100644 --- a/tests/Gateways/HuyiGatewayTest.php +++ b/tests/Gateways/HuyiGatewayTest.php @@ -30,7 +30,7 @@ class HuyiGatewayTest extends TestCase $params = [ 'account' => 'mock-api-id', 'mobile' => strval(18188888888), - 'content' => 'This is a huyi test message.', + 'content' => 'This is a test message.', 'format' => 'json', ]; $gateway->shouldReceive('post')->with('http://106.ihuyi.com/webservice/sms.php?method=Submit', \Mockery::subset($params)) @@ -42,7 +42,7 @@ class HuyiGatewayTest extends TestCase 'msg' => 'mock-err-msg', ])->times(2); - $message = new Message(['content' => 'This is a huyi test message.']); + $message = new Message(['content' => 'This is a test message.']); $config = new Config($config); $this->assertSame([ diff --git a/tests/Gateways/SendcloudGatewayTest.php b/tests/Gateways/SendcloudGatewayTest.php index 84c98f9c487ae2d0263f071188143d1c15677c63..1df3ffca4d28b479e449210e72e68f5c1f801eb1 100644 --- a/tests/Gateways/SendcloudGatewayTest.php +++ b/tests/Gateways/SendcloudGatewayTest.php @@ -35,7 +35,6 @@ class SendcloudGatewayTest extends TestCase ]; $gateway->shouldReceive('post') ->with(sprintf(SendcloudGateway::ENDPOINT_TEMPLATE, 'send'), \Mockery::on(function ($params) use ($expected, $config) { - $expected['timestamp'] = $params['timestamp']; ksort($expected); $signString = []; foreach ($expected as $key => $value) { @@ -49,8 +48,8 @@ class SendcloudGatewayTest extends TestCase && $params['templateId'] == $expected['templateId'] && $params['phone'] == $expected['phone'] && $params['vars'] == $expected['vars'] - && $params['timestamp'] >= time() && $params['signature'] == $expectedSignature + && !isset($params['timestamp']) ; })) ->andReturn([ @@ -64,7 +63,7 @@ class SendcloudGatewayTest extends TestCase ])->times(2); $message = new Message([ - 'content' => 'This is a huyi test message.', + 'content' => 'This is a test message.', 'template' => 'mock-tpl-id', 'data' => [ 'code' => 1234, @@ -85,4 +84,40 @@ class SendcloudGatewayTest extends TestCase $gateway->send(18188888888, $message, $config); } + + public function testTimestampConfig() + { + $config = [ + 'sms_user' => 'mock-user', + 'sms_key' => 'mock-key', + 'timestamp' => true, + ]; + $gateway = \Mockery::mock(SendcloudGateway::class.'[post]', [$config])->shouldAllowMockingProtectedMethods(); + + $gateway->shouldReceive('post') + ->with(sprintf(SendcloudGateway::ENDPOINT_TEMPLATE, 'send'), \Mockery::on(function($params) { + return isset($params['timestamp']) && strlen($params['timestamp']) == 13 && $params['timestamp'] <= time() * 1000; + }))->andReturn([ + 'message' => '操作成功', + 'result' => true, + 'statusCode' => 200, + ]); + + $config = new Config($config); + $message = new Message([ + 'content' => 'This is a test message.', + 'template' => 'mock-tpl-id', + 'data' => [ + 'code' => 1234, + ], + ]); + + $this->assertSame([ + 'message' => '操作成功', + 'result' => true, + 'statusCode' => 200, + ], $gateway->send(18188888888, $message, $config)); + + $gateway->send(18188888888, $message, $config); + } }