Location: PHPKode > projects > TeamSpeak3-Library > devMX-TeamSpeak3-Library-e93460b/test/src/devmx/Teamspeak3/Query/CommandTest.php
<?php

namespace devmx\Teamspeak3\Query;


/**
 * Test class for Command.
 * Generated by PHPUnit on 2011-08-29 at 18:44:03.
 */
class CommandTest extends \PHPUnit_Framework_TestCase
{

    public function testGetName() {
        $cmd = new Command('foo');
        $this->assertEquals('foo', $cmd->getName());
    }
   
    public function testGetSingleParams() {
        $cmd = new Command('foo', array('foo'=>'bar', 'asdf'=>123));
        $this->assertEquals('bar', $cmd->getParameter('foo'));
        $this->assertEquals(123, $cmd->getParameter('asdf'));
    }
   
    public function testGetArrayParams() {
        $cmd = new Command('foo', array('foo'=>array('bar',123), 'asdf'=>array(123,'foo')));
        $this->assertEquals(array('bar',123), $cmd->getParameter('foo'));
        $this->assertEquals(array(123,'foo'), $cmd->getParameter('asdf'));
        $this->assertEquals(array('foo'=>array('bar',123), 'asdf'=>array(123,'foo')), $cmd->getParameters());
    }
   
    public function testGetParamElse() {
        $cmd = new Command('foo');
        $this->assertEquals('sthelse', $cmd->getParameter('foo', 'sthelse'));
    }
   
    public function testGetOption() {
        $cmd = new Command('foo', array(), array('a','b','c'));
        $this->assertTrue($cmd->optionIsSet('a'));
        $this->assertTrue($cmd->optionIsSet('b'));
        $this->assertEquals(array('a','b','c'), $cmd->getOptions());
    }
   
    public function testEquals_orderIndependence() {
        $cmd1 = new Command("foo", Array("foo" => "bar", "bar" => "foo"), Array("foo", "asdf") );
         
        $cmd2 = new Command("foo", Array("bar" => "foo", "foo" => "bar"), Array("asdf", "foo") );
        
        $this->assertTrue($cmd1->equals($cmd2));
    }
    
    public function testEquals_otherOptionName() {
        $cmd1 = new Command("foo",
                            Array(), 
                            Array("foo", "bar"));
        
        $cmd2 = new Command("foo", 
                            Array(), 
                            Array("foo", "barz"));
        $this->assertFalse($cmd1->equals($cmd2));
    }
    
    
    public function testEquals_additionalOption() {
        $cmd1 = new Command("foo",
                            Array(), 
                            Array("foo", "bar"));
        
        $cmd2 = new Command("foo", 
                            Array(), 
                            Array("foo", "bar", "asdf"));
        
        $this->assertFalse($cmd1->equals($cmd2));
    }
    
    public function testEquals_Name() {
        $cmd1 = new Command('foo');
        $cmd2 = new Command('bar');
        $this->assertFalse($cmd1->equals($cmd2));
    }
    
    public function testEquals_AdditionalParam() {
        $cmd1 = new Command('foo', array('a'=>'b'));
        $cmd2 = new Command('foo', array('a'=>'b', 'c'=>'d'));
        $this->assertFalse($cmd1->equals($cmd2));
    }
    
    public function testEquals_optionOnly() {
        $cmd1 = new Command('foo', array(), array('a', 'b'));
        $cmd2 = new Command('foo', array(), array('a', 'b'));
        $this->assertTrue($cmd1->equals($cmd2));
    }
}

?>
Return current item: TeamSpeak3-Library