/** * Set up * * @covers \Pushy\Client::__construct */ public function setUp() { // Set up mock user $this->mockUser = Mockery::mock('\\Pushy\\User')->shouldIgnoreMissing(); // Set mock priority $this->mockPriority = Mockery::mock('\\Pushy\\Priority\\PriorityInterface')->shouldIgnoreMissing()->shouldReceive('getApiParameters')->andReturn([])->getMock(); // Set up mock message $this->mockMessage = Mockery::mock('\\Pushy\\Message')->shouldIgnoreMissing(); $this->mockMessage->shouldReceive('getUser')->andReturn($this->mockUser); $this->mockMessage->shouldReceive('getPriority')->andReturn($this->mockPriority); // Set mock transport $this->mockTransport = Mockery::mock('\\Pushy\\Transport\\TransportInterface')->shouldIgnoreMissing(); // Set up client $this->client = new Client('KzGDORePK8gMaC0QOYAMyEEuzJnyUi'); $this->client->setTransport($this->mockTransport); }
/** * Test: Send command * * @covers \Pushy\Command\SendMessage::send */ public function testSend() { // Stub mock client getAPiToken and getTransport $this->mockClient->shouldReceive('getApiToken')->andReturn('abc')->getMock()->shouldReceive('getTransport')->andReturn($this->mockTransport); // Stub mock transport sendRequest and response object $responseObject = (object) ['receipt' => 'receiptid']; $this->mockTransport->shouldReceive('sendRequest')->andReturn($responseObject); // Stub mock message methods $this->mockMessage->shouldReceive('getUser')->andReturn($this->mockUser)->getMock()->shouldReceive('getSound')->andReturn($this->mockSound)->getMock()->shouldReceive('getPriority')->andReturn($this->mockPriority); // Stub sound $this->mockSound->shouldReceive('__toString')->andReturn('soundname'); // Stub mock priority getApiParameters $this->mockPriority->shouldReceive('getApiParameters')->andReturn([]); // Ensure we get a receipt back $this->assertEquals($responseObject->receipt, $this->sendMessageCommand->send($this->mockClient)); }