diff options
author | Georgy Redkozubov <georgy.redkozubov@linaro.org> | 2012-05-23 11:11:02 +0400 |
---|---|---|
committer | Georgy Redkozubov <georgy.redkozubov@linaro.org> | 2012-05-23 11:11:02 +0400 |
commit | e446473285ab309bc48469d418855a156bcc6489 (patch) | |
tree | ff9ac96b7ab0fc53c6ba0301b6b4c4d0097186a4 /tests/BuildInfoTest.php | |
parent | 6effe13d2e956022d1fa797a1dcb422c68d97285 (diff) |
Added PHP unit tests for BuildInfo class
Diffstat (limited to 'tests/BuildInfoTest.php')
-rw-r--r-- | tests/BuildInfoTest.php | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/tests/BuildInfoTest.php b/tests/BuildInfoTest.php new file mode 100644 index 0000000..550c373 --- /dev/null +++ b/tests/BuildInfoTest.php @@ -0,0 +1,122 @@ +<?php + +require_once("licenses/BuildInfo.php"); + +class BuildInfoTest extends PHPUnit_Framework_TestCase +{ + + private $temp_filename; + private $good_bi; + private $bi; + + public function __construct() + { + $this->good_bi = new BuildInfo(); + $this->good_bi->readFile("tests/BUILD-INFO.txt"); + $this->temp_filename = tempnam(sys_get_temp_dir(), "build-info"); + $this->bi = new BuildInfo(); + $this->bi->readFile($this->temp_filename); + } + + /** + * Running readFile on a directory path returns false. + */ + public function test_readFile_nonFile() + { + $this->assertFalse(BuildInfo::readFile(dirname(__FILE__))); + } + + /** + * Running readFile on a nonexistent file returns false. + */ + public function test_readFile_nonexistentFile() + { + $this->assertFalse(BuildInfo::readFile("nonexistent.file")); + } + + /** + * Running readFile on a regular file returns true. + */ + public function test_readFile_file() + { + $bi = new BuildInfo(); + $this->assertTrue($bi->readFile(__FILE__)); + } + + /** + * Running 'get' functions on an empty fields returns false. + */ + public function test_getFormatVersion_empty() + { + $this->assertFalse($this->bi->getFormatVersion()); + } + + /** + * Running 'get' functions on non-empty fields returns string value. + */ + public function test_getFormatVersion() + { + $this->assertInternalType('string', $this->good_bi->getFormatVersion()); + } + + public function test_getBuildName_empty() + { + $this->assertFalse($this->bi->getBuildName()); + } + + public function test_getBuildName() + { + $this->assertInternalType('string', $this->good_bi->getBuildName()); + } + + public function test_getTheme_empty() + { + $this->assertFalse($this->bi->getTheme()); + } + + public function test_getTheme() + { + $this->assertInternalType('string', $this->good_bi->getTheme()); + } + + public function test_getLicenseType_empty() + { + $this->assertFalse($this->bi->getLicenseType()); + } + + public function test_getLicenseType() + { + $this->assertInternalType('string', $this->good_bi->getLicenseType()); + } + + public function test_getCollectUserData_empty() + { + $this->assertFalse($this->bi->getCollectUserData()); + } + + public function test_getCollectUserData() + { + $this->assertInternalType('string', $this->good_bi->getCollectUserData()); + } + + public function test_getLaunchpadTeams_empty() + { + $this->assertFalse($this->bi->getLaunchpadTeams()); + } + + public function test_getLaunchpadTeams() + { + $this->assertInternalType('string', $this->good_bi->getLaunchpadTeams()); + } + + public function test_getLicenseText_empty() + { + $this->assertFalse($this->bi->getLicenseText()); + } + + public function test_getLicenseText() + { + $this->assertInternalType('string', $this->good_bi->getLicenseText()); + } +} +?> |