Login   Register  
PHP Classes
elePHPant
Icontem

File: test/WebPower/gcm/server/MessageTest.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/MessageTest.php  >  Download  
File: test/WebPower/gcm/server/MessageTest.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: 1,722 bytes
 

Contents

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

class 
MessageTest extends \PHPUnit_Framework_TestCase
{
    public function 
testRequiredParameters()
    {
        
$message Message::builder()->build();
        
$this->assertNull($message->getCollapseKey());
        
$this->assertNull($message->isDelayWhileIdle());
        
$this->assertEmpty($message->getData());
        
$this->assertNull($message->getTimeToLive());
        
$toString $message->__toString();
        
$this->assertNotContains('collapsekey'$toString);
        
$this->assertNotContains('timeToLive'$toString);
        
$this->assertNotContains('delayWhileIdle'$toString);
        
$this->assertNotContains('data'$toString);
    }

    public function 
testOptionalParameters()
    {
        
$message Message::builder()
            ->
collapseKey('108')
            ->
delayWhileIdle(true)
            ->
timeToLive(42)
            ->
addData('k1''old value')
            ->
addData('k1''v1')
            ->
addData('k2''v2')
            ->
build()
        ;

        
$this->assertEquals("108"$message->getCollapseKey());
        
$this->assertTrue($message->isDelayWhileIdle());
        
$this->assertEquals(42$message->getTimeToLive());
        
$data $message->getData();
        
$this->assertEquals(2count($data));
        
$this->assertEquals('v1'$data['k1']);
        
$this->assertEquals('v2'$data['k2']);

        
$toString $message->__toString();
        
$this->assertContains('collapseKey=108'$toString);
        
$this->assertContains('timeToLive=42'$toString);
        
$this->assertContains('delayWhileIdle=true'$toString);
        
$this->assertContains('k1=v1'$toString);
        
$this->assertContains('k2=v2'$toString);
    }
}