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

namespace devmx\Teamspeak3;

/**
 * Test class for Version.
 * Generated by PHPUnit on 2011-10-30 at 19:56:41.
 */
class VersionTest extends \PHPUnit_Framework_TestCase
{

    /**
     * @var Version
     */
    protected $v1;
    /**
     *
     * @var Version 
     */
    protected $v2;

    /**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     */
    protected function setUp()
    {
        $this->v1 = new Version(3,0,1,5001);
        $this->v2 = new Version(3,1,5,1004);
    }

   
    /**
     * tests the creation of a version object from a string
     */
    public function testFromString()
    {
        $fromString = Version::fromString("3.10.1 [Build: 5001]");
        $this->assertEquals(3 , $fromString->getMajorNumber());
        $this->assertEquals(10 , $fromString->getMinorNumber());
        $this->assertEquals(1 , $fromString->getRevisionNumber());
        $this->assertEquals(5001, $fromString->getBuildNumber());
        
        $fromString = Version::fromString("3.10.1");
        $this->assertEquals(3 , $fromString->getMajorNumber());
        $this->assertEquals(10 , $fromString->getMinorNumber());
        $this->assertEquals(1 , $fromString->getRevisionNumber());
    }
    
    /**
     * @expectedException \InvalidArgumentException
     */
    public function testFromInvalidString_Seperator() {
        $fromString = Version::fromString(("3:10:1"));
    }
    
    /**
     * @expectedException \InvalidArgumentException
     */
    public function testFromInvalidString() {
        $fromString = Version::fromString("3.a.1");
    }

    public function testCompare()
    {
        $this->assertEquals(Version::LOWER, $this->v1->compare($this->v2));
        $this->assertEquals(Version::HIGHER, $this->v2->compare($this->v1));
        $this->assertEquals(Version::EQUAL, $this->v1->compare($this->v1));
    }

    
    public function test__toString()
    {
        $this->assertEquals("3.0.1 [Build: 5001]",$this->v1->__toString());
        $this->assertEquals("3.1.5 [Build: 1004]", $this->v2->__toString());
    }

    

}

?>
Return current item: TeamSpeak3-Library