Laravel version update

Laravel version update
This commit is contained in:
Manish Verma
2018-08-06 18:48:58 +05:30
parent d143048413
commit 126fbb0255
13678 changed files with 1031482 additions and 778530 deletions

View File

@@ -1,223 +1,232 @@
<?php namespace LaravelFCM\Mocks;
<?php
namespace LaravelFCM\Mocks;
use LaravelFCM\Response\DownstreamResponse;
use LaravelFCM\Response\DownstreamResponseContract;
/**
* Class MockDownstreamResponse **Only use it for testing**
*
* @package LaravelFCM\Response
* Class MockDownstreamResponse **Only use it for testing**.
*/
class MockDownstreamResponse implements DownstreamResponseContract {
class MockDownstreamResponse implements DownstreamResponseContract
{
/**
* @internal
*
* @var int
*/
protected $numberTokensSuccess = 0;
/**
* @internal
*
* @var
*/
protected $messageId;
/**
* @internal
*
* @var int
*/
protected $numberTokensSuccess = 0;
/**
* @internal
*
* @var array
*/
protected $tokensToDelete = [];
/**
* @internal
*
* @var array
*/
protected $tokensToModify = [];
/**
* @internal
*
* @var array
*/
protected $tokensToRetry = [];
/**
* @internal
*
* @var
*/
protected $messageId;
/**
* @internal
*
* @var array
*/
protected $tokensWithError = [];
/**
* @internal
*
* @var array
*/
protected $tokensToDelete = [];
/**
* @internal
*
* @var bool
*/
protected $hasMissingToken = false;
/**
* @internal
*
* @var array
*/
/**
* DownstreamResponse constructor.
*
* @param $numberSuccess
*/
public function __construct($numberSuccess)
{
$this->numberTokensSuccess = $numberSuccess;
}
protected $tokensToModify = [];
/**
* @internal
*
* @var array
*/
/**
* Not using it.
*
* @param DownstreamResponse $response
*
* @throws \Exception
*/
public function merge(DownstreamResponse $response)
{
throw new \Exception('You cannot use this method for mocking response');
}
protected $tokensToRetry = [];
/**
* Get the number of device reached with success + numberTokenToModify.
*
* @return int
*/
public function numberSuccess()
{
return $this->numberTokensSuccess + count($this->tokensToModify);
}
/**
* @internal
*
* @var array
*/
protected $tokensWithError = [];
/**
* Get the number of device which thrown an error.
*
* @return int
*/
public function numberFailure()
{
return count($this->tokensToDelete()) + count($this->tokensWithError);
}
/**
* @internal
* @var bool
*/
protected $hasMissingToken = false;
/**
* Get the number of device that you need to modify their token.
*
* @return int
*/
public function numberModification()
{
return count($this->tokensToModify());
}
/**
* DownstreamResponse constructor.
*
* @param $numberSuccess
*/
public function __construct($numberSuccess)
{
$this->numberTokensSuccess = $numberSuccess;
}
/**
* Add a token to delete.
*
* @param $token
* @return MockDownstreamResponse
*/
public function addTokenToDelete($token)
{
$this->tokensToDelete[] = $token;
return $this;
}
/**
* Not using it
*
* @param DownstreamResponse $response
*
* @throws \Exception
*/
public function merge(DownstreamResponse $response)
{
throw new \Exception('You cannot use this method for mocking response');
}
/**
* get token to delete
* remove all tokens returned by this method in your database.
*
* @return array
*/
public function tokensToDelete()
{
return $this->tokensToDelete;
}
/**
* Get the number of device reached with success + numberTokenToModify
*
* @return int
*/
public function numberSuccess()
{
return $this->numberTokensSuccess + count($this->tokensToModify);
}
/**
* Add a token to modify.
*
* @param $oldToken
* @param $newToken
* @return MockDownstreamResponse
*/
public function addTokenToModify($oldToken, $newToken)
{
$this->tokensToModify[$oldToken] = $newToken;
return $this;
}
/**
* Get the number of device which thrown an error
*
* @return int
*/public function numberFailure()
{
return count($this->tokensToDelete()) + count($this->tokensWithError);
}
/**
* get token to modify
* key: oldToken
* value: new token
* find the old token in your database and replace it with the new one.
*
* @return array
*/
public function tokensToModify()
{
return $this->tokensToModify;
}
/**
* Get the number of device that you need to modify their token
*
* @return int
*/
public function numberModification()
{
return count($this->tokensToModify());
}
/**
* Add a token to retry.
*
* @param $token
* @return MockDownstreamResponse
*/
public function addTokenToRetry($token)
{
$this->tokensToRetry[] = $token;
return $this;
}
/**
* Add a token to delete
*
* @param $token
*/
public function addTokenToDelete($token)
{
$this->tokensToDelete[] = $token;
}
/**
* Get tokens that you should resend using exponential backoof.
*
* @return array
*/
public function tokensToRetry()
{
return $this->tokensToRetry;
}
/**
* get token to delete
* remove all tokens returned by this method in your database
*
* @return array
*/
public function tokensToDelete()
{
return $this->tokensToDelete;
}
/**
* Add a token to errors.
*
* @param $token
* @param $message
* @return MockDownstreamResponse
*/
public function addTokenWithError($token, $message)
{
$this->tokensWithError[$token] = $message;
return $this;
}
/**
* Add a token to modify
*
* @param $oldToken
* @param $newToken
*/
public function addTokenToModify($oldToken, $newToken)
{
$this->tokensToModify[$oldToken] = $newToken;
}
/**
* Get tokens that thrown an error
* key : token
* value : error
* In production, remove these tokens from you database.
*
* @return array
*/
public function tokensWithError()
{
return $this->tokensWithError;
}
/**
* get token to modify
* key: oldToken
* value: new token
* find the old token in your database and replace it with the new one
*
* @return array
*/
public function tokensToModify()
{
return $this->tokensToModify;
}
/**
* change missing token state.
*
* @param $hasMissingToken
* @return MockDownstreamResponse
*/
public function setMissingToken($hasMissingToken)
{
$this->hasMissingToken = $hasMissingToken;
return $this;
}
/**
* Add a token to retry
*
* @param $token
*/
public function addTokenToRetry($token)
{
$this->tokensToRetry[] = $token;
}
/**
* Get tokens that you should resend using exponential backoof
*
* @return array
*/
public function tokensToRetry()
{
return $this->tokensToRetry;
}
/**
* Add a token to errors
*
* @param $token
* @param $message
*/
public function addTokenWithError($token, $message)
{
$this->tokensWithError[$token] = $message;
}
/**
* Get tokens that thrown an error
* key : token
* value : error
* In production, remove these tokens from you database
*
* @return array
*/
public function tokensWithError()
{
return $this->tokensWithError;
}
/**
* change missing token state
* @param $hasMissingToken
*/
public function setMissingToken($hasMissingToken)
{
$this->hasMissingToken = $hasMissingToken;
}
/**
* check if missing tokens was given to the request
* If true, remove all the empty token in your database
*
* @return bool
*/
public function hasMissingToken()
{
return $this->hasMissingToken;
}
}
/**
* check if missing tokens was given to the request
* If true, remove all the empty token in your database.
*
* @return bool
*/
public function hasMissingToken()
{
return $this->hasMissingToken;
}
}

View File

@@ -1,88 +1,123 @@
<?php namespace LaravelFCM\Mocks;
<?php
namespace LaravelFCM\Mocks;
use LaravelFCM\Response\GroupResponseContract;
/**
* Class MockGroupResponse **Only use it for testing**
*
* @package LaravelFCM\Response
* Class MockGroupResponse **Only use it for testing**.
*/
class MockGroupResponse implements GroupResponseContract {
class MockGroupResponse implements GroupResponseContract
{
/**
* @internal
*
* @var int
*/
protected $numberTokensSuccess = 0;
/**
* @internal
* @var int
*/
protected $numberTokensSuccess = 0;
/**
* @internal
*
* @var int
*/
protected $numberTokensFailure = 0;
/**
* @internal
* @var int
*/
protected $numberTokensFailure = 0;
/**
* @internal
*
* @var array
*/
protected $tokensFailed = [];
/**
* @internal
* @var array
*/
protected $tokensFailed = [];
/**
* @internal
*
* @var string
*/
protected $to;
/**
* set number of success
* @param $numberSuccess
*/
public function setNumberSuccess($numberSuccess)
{
$this->numberTokensSuccess = $numberSuccess;
}
/**
* set number of success.
*
* @param int $numberSuccess
* @return MockGroupResponse
*/
public function setNumberSuccess($numberSuccess)
{
$this->numberTokensSuccess = $numberSuccess;
return $this;
}
/**
* Get the number of device reached with success
*
* @return int
*/
public function numberSuccess()
{
return $this->numberTokensSuccess;
}
/**
* Get the number of device reached with success.
*
* @return int
*/
public function numberSuccess()
{
return $this->numberTokensSuccess;
}
/**
* set number of failures
*
* @param $numberFailures
*/
public function setNumberFailure($numberFailures)
{
$this->numberTokensSuccess = $numberFailures;
}
/**
* set number of failures.
*
* @param $numberFailures
* @return MockGroupResponse
*/
public function setNumberFailure($numberFailures)
{
$this->numberTokensSuccess = $numberFailures;
return $this;
}
/**
* Get the number of device which thrown an error
*
* @return int
*/
public function numberFailure()
{
return $this->numberTokensFailure;
}
/**
* Get the number of device which thrown an error.
*
* @return int
*/
public function numberFailure()
{
return $this->numberTokensFailure;
}
/**
* add a token to the failed list
*
* @param $tokenFailed
*/
public function addTokenFailed($tokenFailed)
{
$this->tokensFailed[] = $tokenFailed;
}
/**
* add a token to the failed list.
*
* @param $tokenFailed
* @return MockGroupResponse
*/
public function addTokenFailed($tokenFailed)
{
$this->tokensFailed[] = $tokenFailed;
return $this;
}
/**
* Get all token in group that fcm cannot reach
*
* @return array
*/
public function tokensFailed()
{
return $this->tokensFailed;
}
}
/**
* Get all token in group that fcm cannot reach.
*
* @return array
*/
public function tokensFailed()
{
return $this->tokensFailed;
}
/**
* @return string
*/
public function getTo()
{
return $this->to;
}
/**
* @param string $to
* @return MockGroupResponse
*/
public function setTo($to)
{
$this->to = $to;
return $this;
}
}

View File

@@ -1,86 +1,94 @@
<?php namespace LaravelFCM\Mocks;
<?php
namespace LaravelFCM\Mocks;
use LaravelFCM\Response\TopicResponseContract;
/**
* Class MockTopicResponse **Only use it for testing**
*
* @package LaravelFCM\Response
* Class MockTopicResponse **Only use it for testing**.
*/
class MockTopicResponse implements TopicResponseContract {
class MockTopicResponse implements TopicResponseContract
{
/**
* @internal
*
* @var string
*/
protected $topic;
/**
* @internal
*
* @var string
*/
protected $messageId;
/**
* @internal
* @var string
*/
protected $topic;
/**
* @internal
*
* @var string
*/
protected $error;
/**
* @internal
* @var string
*/
protected $messageId;
/**
* @internal
*
* @var bool
*/
protected $needRetry = false;
/**
* @internal
* @var string
*/
protected $error;
/**
* if success set a message id.
*
* @param $messageId
* @return MockTopicResponse
*/
public function setSuccess($messageId)
{
$this->messageId = $messageId;
return $this;
}
/**
* @internal
* @var bool
*/
protected $needRetry = false;
/**
* true if topic sent with success.
*
* @return bool
*/
public function isSuccess()
{
return (bool) $this->messageId;
}
/**
* if success set a message id
*
* @param $messageId
*/
public function setSuccess($messageId)
{
$this->messageId = $messageId;
}
/**
* set error.
*
* @param $error
* @return MockTopicResponse
*/
public function setError($error)
{
$this->error = $error;
return $this;
}
/**
* true if topic sent with success
*
* @return bool
*/
public function isSuccess()
{
return (bool) $this->messageId;
}
/**
* return error message
* you should test if it's necessary to resent it.
*
* @return string error
*/
public function error()
{
$this->error;
}
/**
* set error
* @param $error
*/
public function setError($error)
{
$this->error = $error;
}
/**
* return error message
* you should test if it's necessary to resent it
*
* @return string error
*/
public function error()
{
$this->error;
}
/**
* return true if it's necessary resent it using exponential backoff
*
* @return bool
*/
public function shouldRetry()
{
$this->error;
}
}
/**
* return true if it's necessary resent it using exponential backoff.
*
* @return bool
*/
public function shouldRetry()
{
$this->error;
}
}