update v 1.0.7.5

This commit is contained in:
Sujit Prasad
2016-06-13 20:41:55 +05:30
parent aa9786d829
commit 283d97e3ea
5078 changed files with 339851 additions and 175995 deletions

View File

@@ -1,9 +1,9 @@
<?php
/*
* This file is part of Psy Shell
* This file is part of Psy Shell.
*
* (c) 2012-2014 Justin Hileman
* (c) 2012-2015 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -28,6 +28,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(function_exists('pcntl_signal'), $config->hasPcntl());
$this->assertEquals(function_exists('pcntl_signal'), $config->usePcntl());
$this->assertFalse($config->requireSemicolons());
$this->assertSame(Configuration::COLOR_MODE_AUTO, $config->colorMode());
}
public function testGettersAndSetters()
@@ -99,6 +100,8 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
'pager' => $pager,
'loop' => $loop,
'requireSemicolons' => true,
'errorLoggingLevel' => E_ERROR | E_WARNING,
'colorMode' => Configuration::COLOR_MODE_FORCED,
));
$this->assertFalse($config->useReadline());
@@ -107,6 +110,8 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
$this->assertSame($pager, $config->getPager());
$this->assertSame($loop, $config->getLoop());
$this->assertTrue($config->requireSemicolons());
$this->assertEquals(E_ERROR | E_WARNING, $config->errorLoggingLevel());
$this->assertSame(Configuration::COLOR_MODE_FORCED, $config->colorMode());
}
public function testLoadConfigFile()
@@ -117,38 +122,35 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
$this->assertStringStartsWith($runtimeDir, realpath($config->getTempFile('foo', 123)));
$this->assertStringStartsWith($runtimeDir, realpath(dirname($config->getPipe('pipe', 123))));
// This will be deprecated, but we want to actually test the value.
$was = error_reporting(error_reporting() & ~E_USER_DEPRECATED);
$this->assertStringStartsWith($runtimeDir, realpath($config->getTempDir()));
error_reporting($was);
$this->assertStringStartsWith($runtimeDir, realpath($config->getRuntimeDir()));
$this->assertEquals(function_exists('readline'), $config->useReadline());
$this->assertFalse($config->usePcntl());
$this->assertEquals(E_ALL & ~E_NOTICE, $config->errorLoggingLevel());
}
/**
* @expectedException PHPUnit_Framework_Error_Deprecated
*/
public function testSetTempDirIsDeprecated()
public function testLoadLocalConfigFile()
{
$oldPwd = getenv('PWD');
putenv('PWD=' . realpath(__DIR__ . '/../../fixtures/project/'));
$config = new Configuration();
$config->setTempDir('fake');
// When no configuration file is specified local project config is merged
$this->assertFalse($config->useReadline());
$this->assertTrue($config->usePcntl());
$config = new Configuration(array('configFile' => __DIR__ . '/../../fixtures/config.php'));
// Defining a configuration file skips loading local project config
$this->assertTrue($config->useReadline());
$this->assertFalse($config->usePcntl());
putenv("PWD=$oldPwd");
}
/**
* @expectedException PHPUnit_Framework_Error_Deprecated
*/
public function testGetTempDirIsDeprecated()
{
$config = new Configuration();
$config->getTempDir();
}
/**
* @expectedException PHPUnit_Framework_Error_Deprecated
* @expectedException Psy\Exception\DeprecatedException
*/
public function testBaseDirConfigIsDeprecated()
{
@@ -171,4 +173,69 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
$this->assertCount(1, $includes);
$this->assertEquals('/file.php', $includes[0]);
}
public function testGetOutput()
{
$config = new Configuration();
$output = $config->getOutput();
$this->assertInstanceOf('\Psy\Output\ShellOutput', $output);
}
public function getOutputDecoratedProvider()
{
return array(
'auto' => array(
null,
Configuration::COLOR_MODE_AUTO,
),
'forced' => array(
true,
Configuration::COLOR_MODE_FORCED,
),
'disabled' => array(
false,
Configuration::COLOR_MODE_DISABLED,
),
);
}
/** @dataProvider getOutputDecoratedProvider */
public function testGetOutputDecorated($expectation, $colorMode)
{
$config = new Configuration();
$config->setColorMode($colorMode);
$this->assertSame($expectation, $config->getOutputDecorated());
}
public function setColorModeValidProvider()
{
return array(
'auto' => array(Configuration::COLOR_MODE_AUTO),
'forced' => array(Configuration::COLOR_MODE_FORCED),
'disabled' => array(Configuration::COLOR_MODE_DISABLED),
);
}
/** @dataProvider setColorModeValidProvider */
public function testSetColorModeValid($colorMode)
{
$config = new Configuration();
$config->setColorMode($colorMode);
$this->assertEquals($colorMode, $config->colorMode());
}
public function testSetColorModeInvalid()
{
$config = new Configuration();
$colorMode = 'some invalid mode';
$this->setExpectedException(
'\InvalidArgumentException',
'invalid color mode: some invalid mode'
);
$config->setColorMode($colorMode);
}
}