This repository has been archived on 2026-07-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
espocrm-base/tests/Espo/Core/Utils/SystemTest.php
T
2014-11-07 11:48:33 +02:00

69 lines
1.7 KiB
PHP

<?php
namespace tests\Espo\Core\Utils;
use Espo\Core\Utils\Util;
class SystemTest extends \PHPUnit_Framework_TestCase
{
protected $object;
protected $reflection;
protected function setUp()
{
$this->object = new \Espo\Core\Utils\System();
}
protected function tearDown()
{
$this->object = NULL;
}
public function testGetServerType()
{
$_SERVER['SERVER_SOFTWARE'] = 'Apache/2.2.17 (Ubuntu)';
$this->assertEquals( 'apache', $this->object->getServerType());
$_SERVER['SERVER_SOFTWARE'] = 'Apache';
$this->assertEquals( 'apache', $this->object->getServerType());
$_SERVER['SERVER_SOFTWARE'] = 'nginx/1.5.12';
$this->assertEquals( 'nginx', $this->object->getServerType());
$_SERVER['SERVER_SOFTWARE'] = 'Microsoft-IIS/8.0';
$this->assertEquals( 'microsoft-iis', $this->object->getServerType());
$_SERVER['SERVER_SOFTWARE'] = 'apache/2.4.10 (win32) openssl/1.0.1i php';
$this->assertEquals( 'apache', $this->object->getServerType());
}
public function testGetOS()
{
$possibleValues = array(
'windows',
'mac',
'linux',
);
$this->assertTrue( in_array($this->object->getOS(), $possibleValues));
}
public function testGetRootDir()
{
$rootDir = dirname(__FILE__);
$rootDir = str_replace(Util::fixPath('/tests/Espo/Core/Utils'),'',$rootDir);
$this->assertEquals($rootDir, $this->object->getRootDir());
}
public function testGetPhpBin()
{
$phpBin = @exec('which php');
if (isset($phpBin)) {
$this->assertEquals($phpBin, $this->object->getPhpBin());
}
}
}