Inheritance: extends HTTPSender
示例#1
0
    /**
     * @test
     */
    public function an_empty_array_of_tokens_thrown_an_exception()
    {
        $response = new Response(400, [], '{ 
						  "multicast_id": 216,
						  "success": 3,
						  "failure": 3,
						  "canonical_ids": 1,
						  "results": [
							    { "message_id": "1:0408" },
							    { "error": "Unavailable" },
							    { "error": "InvalidRegistration" },
							    { "message_id": "1:1516" },
							    { "message_id": "1:2342", "registration_id": "32" },
							    { "error": "NotRegistered"}
	                      ]
					}');
        $client = Mockery::mock(Client::class);
        $client->shouldReceive('post')->once()->andReturn($response);
        $fcm = new FCMSender($client, 'http://test.test');
        $this->setExpectedException(\LaravelFCM\Response\Exceptions\InvalidRequestException::class);
        $fcm->sendTo([]);
    }
示例#2
0
 /**
  * @test
  */
 public function it_send_a_notification_to_a_topic_and_return_error()
 {
     $response = new Response(200, [], '{"error":"TopicsMessageRateExceeded"}');
     $client = Mockery::mock(Client::class);
     $client->shouldReceive('post')->once()->andReturn($response);
     $fcm = new FCMSender($client, 'http://test.test');
     $topics = new Topics();
     $topics->topic('test');
     $response = $fcm->sendToTopic($topics);
     $this->assertFalse($response->isSuccess());
     $this->assertTrue($response->shouldRetry());
     $this->assertEquals('TopicsMessageRateExceeded', $response->error());
 }