/** * Test method for the <tt>deleteMessage($deleteMessageRequest)</tt> function. * * @group PushwooshTest.deleteMessage */ public function testDeleteMessage() { // Create a fake CURL client $cURLClient = $this->getMock('Gomoob\\Pushwoosh\\ICURLClient'); $cURLClient->expects($this->any())->method('pushwooshCall')->will($this->returnValue(array('status_code' => 200, 'status_message' => 'OK'))); $pushwoosh = new Pushwoosh(); $pushwoosh->setCURLClient($cURLClient); $deleteMessageRequest = DeleteMessageRequest::create()->setMessage('MESSAGE'); // Test with the 'auth' parameter not defined try { $pushwoosh->deleteMessage($deleteMessageRequest); $this->fail('Must have thrown a PushwooshException !'); } catch (PushwooshException $pe) { // Expected } // Test with the 'auth' parameter defined in the Pushwoosh client $pushwoosh->setAuth('AUTH'); $deleteMessageRequest->setAuth(null); $pushwoosh->deleteMessage($deleteMessageRequest); // Test with the 'auth' parameter definied in the request $pushwoosh->setAuth(null); $deleteMessageRequest->setAuth('AUTH'); $deleteMessageResponse = $pushwoosh->deleteMessage($deleteMessageRequest); $this->assertTrue($deleteMessageResponse->isOk()); $this->assertEquals(200, $deleteMessageResponse->getStatusCode()); $this->assertEquals('OK', $deleteMessageResponse->getStatusMessage()); // Test a call with an error response $cURLClient = $this->getMock('Gomoob\\Pushwoosh\\ICURLClient'); $cURLClient->expects($this->any())->method('pushwooshCall')->will($this->returnValue(array('status_code' => 400, 'status_message' => 'KO'))); $pushwoosh->setCURLClient($cURLClient); $deleteMessageResponse = $pushwoosh->deleteMessage($deleteMessageRequest); $this->assertFalse($deleteMessageResponse->isOk()); $this->assertEquals(400, $deleteMessageResponse->getStatusCode()); $this->assertEquals('KO', $deleteMessageResponse->getStatusMessage()); }
/** * Test method for the <tt>create()</tt> function. */ public function testCreate() { $deleteMessageRequest = DeleteMessageRequest::create(); $this->assertNotNull($deleteMessageRequest); }