Login   Register  
PHP Classes
elePHPant
Icontem

File: test/WebPower/gcm/server/MulticastResultTest.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Christiaan Baartse  >  PHP Google Cloud Messaging Server  >  test/WebPower/gcm/server/MulticastResultTest.php  >  Download  
File: test/WebPower/gcm/server/MulticastResultTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: PHP Google Cloud Messaging Server
Send messages to Android applications using GCM
Author: By
Last change:
Date: 1 year ago
Size: 2,383 bytes
 

Contents

Class file image Download
<?php
namespace WebPower\gcm\server;

class 
MulticastResultTest extends \PHPUnit_Framework_TestCase
{
    public function 
testRequiredParametersNoResults()
    {
        
$result MulticastResult::builder(481516)->build();

        
$this->assertEquals(4$result->getSuccess());
        
$this->assertEquals(8$result->getFailure());
        
$this->assertEquals(12$result->getTotal());
        
$this->assertEquals(16$result->getMulticastId());
        
$this->assertEmpty($result->getResults());
        
$this->assertEmpty($result->getRetryMulticastIds());
    }

    public function 
testRequiredParametersWithResults()
    {
        
$result MulticastResult::builder(481516)
            ->
addResult(Result::builder()->messageId("23")->build())
            ->
addResult(Result::builder()->messageId("42")->build())
            ->
build();

        
$this->assertEquals(4$result->getSuccess());
        
$this->assertEquals(8$result->getFailure());
        
$this->assertEquals(12$result->getTotal());
        
$this->assertEquals(16$result->getMulticastId());

        
$results $result->getResults();
        
$this->assertEquals(2count($results));
        
$this->assertEquals("23"$results[0]->getMessageId());
        
$this->assertEquals("42"$results[1]->getMessageId());
        
$toString $result->__toString();
        
$this->assertContains("multicast_id=16"$toString);
        
$this->assertContains("total=12"$toString);
        
$this->assertContains("success=4"$toString);
        
$this->assertContains("failure=8"$toString);
        
$this->assertContains("canonical_ids=15"$toString);
        
$this->assertContains("results"$toString);
    }

    public function 
testOptionalParameters()
    {
        
$result MulticastResult::builder(481516)
            ->
retryMulticastIds(array(2342))
            ->
build();

        
$this->assertEquals(4$result->getSuccess());
        
$this->assertEquals(8$result->getFailure());
        
$this->assertEquals(12$result->getTotal());
        
$this->assertEquals(16$result->getMulticastId());
        
$this->assertEmpty($result->getResults());
        
$retryMulticastIds $result->getRetryMulticastIds();
        
$this->assertEquals(2count($retryMulticastIds));
        
$this->assertEquals(23$retryMulticastIds[0]);
        
$this->assertEquals(42$retryMulticastIds[1]);
    }
}