/** * @covers ::check */ public function testCanCallStatically() { // ---------------------------------------------------------------- // setup your test $expectedResult = false; if (file_exists('/etc/redhat-release')) { $expectedResult = true; } // ---------------------------------------------------------------- // perform the change $actualResult = HasEtcRedhatRelease::check(); // ---------------------------------------------------------------- // test the results $this->assertEquals($expectedResult, $actualResult); }
/** * use /etc/redhat-release (if it exists) to work out what flavour of * RedHat Linux we are looking at * * @param string $path * path to the file to parse * @return null|OsType * OsType if we can determine the operating system * null if we cannot */ public static function usingPath($path) { // make sure we have the file! if (!HasEtcRedhatRelease::check($path)) { return null; } // make sure the file is readable RequireReadableFile::check($path); // what do we have? $fileContents = file_get_contents($path); // do we have a match? return self::matchContentsToType($fileContents); }