public function testVersionGetPart()
{
/*
* Note: getId() returns a version string in the format ABBCCDE
* where A is the major version, BB is the medium version (2 digits)
* CC is the minor version (2 digits), D is the release type (see Phalcon\Version)
* and E is the release number (for example 2 for RC2)
*/
$this->specify("getPart(VERSION_MAJOR) does not return the correct result", function () {
$id = Version::getId();
$expected = intval($id[0]);
//The major version is the first digit
$actual = Version::getPart(Version::VERSION_MAJOR);
expect($actual)->equals($expected);
});
$this->specify("getPart(VERSION_MEDIUM) does not return the correct result", function () {
$id = Version::getId();
$expected = intval($id[1] . $id[2]);
//The medium version is the second and third digits
$actual = Version::getPart(Version::VERSION_MEDIUM);
expect($actual)->equals($expected);
});
$this->specify("getPart(VERSION_MINOR) does not return the correct result", function () {
$id = Version::getId();
$expected = intval($id[3] . $id[4]);
//The minor version is the fourth and fifth digits
$actual = Version::getPart(Version::VERSION_MINOR);
expect($actual)->equals($expected);
});
$this->specify("getPart(VERSION_SPECIAL) does not return the correct result", function () {
$id = Version::getId();
$expected = $this->numberToSpecial($id[5]);
$actual = Version::getPart(Version::VERSION_SPECIAL);
expect($actual)->equals($expected);
});
$this->specify("getPart(VERSION_SPECIAL_NUMBER) does not return the correct result", function () {
$id = Version::getId();
$special = $this->numberToSpecial($id[5]);
$expected = $special ? $id[6] : 0;
$actual = Version::getPart(Version::VERSION_SPECIAL_NUMBER);
expect($actual)->equals($expected);
});
$this->specify("getPart() with incorrect parameters does not return get()", function () {
$expected = Version::get();
$actual = Version::getPart(7);
expect($actual)->equals($expected);
});
}