From ac0fb44ee8fc428f278db219050c6cf6263c2684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Brand=C3=A3o?= Date: Thu, 4 Feb 2016 19:36:18 +0000 Subject: [PATCH 1/2] Fix CS issues --- src/App.php | 11 ++++++----- tests/AppTest.php | 17 +++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/App.php b/src/App.php index 8e22b05..aa6e7bb 100644 --- a/src/App.php +++ b/src/App.php @@ -7,6 +7,7 @@ * * @link http://www.ppi.io */ + namespace PPI\Framework; use PPI\Framework\Config\ConfigManager; @@ -389,7 +390,7 @@ public function isDebug() public function getRootDir() { if (null === $this->rootDir) { - $this->rootDir = realpath(getcwd().'/app'); + $this->rootDir = realpath(getcwd() . '/app'); } return $this->rootDir; @@ -478,7 +479,7 @@ public function getStartTime() */ public function getCacheDir() { - return $this->rootDir.'/cache/'.$this->environment; + return $this->rootDir . '/cache/' . $this->environment; } /** @@ -490,7 +491,7 @@ public function getCacheDir() */ public function getLogDir() { - return $this->rootDir.'/logs'; + return $this->rootDir . '/logs'; } /** @@ -513,8 +514,8 @@ public function getCharset() public function getConfigManager() { if (null === $this->configManager) { - $cachePath = $this->getCacheDir().'/application-config-cache.'.$this->getName().'.php'; - $this->configManager = new ConfigManager($cachePath, !$this->debug, $this->rootDir.'/config'); + $cachePath = $this->getCacheDir() . '/application-config-cache.' . $this->getName() . '.php'; + $this->configManager = new ConfigManager($cachePath, !$this->debug, $this->rootDir . '/config'); } return $this->configManager; diff --git a/tests/AppTest.php b/tests/AppTest.php index 36bcce4..ccabfeb 100644 --- a/tests/AppTest.php +++ b/tests/AppTest.php @@ -26,7 +26,6 @@ */ class AppTest extends \PHPUnit_Framework_TestCase { - private $contollerUnderTest; public function setUp() @@ -41,7 +40,7 @@ public function testConstructor() $debug = true; $rootDir = __DIR__; $name = 'testName'; - $app = new AppForTest(array('environment' => $env, 'debug' => $debug, 'rootDir' => $rootDir, 'name' => $name,)); + $app = new AppForTest(array('environment' => $env, 'debug' => $debug, 'rootDir' => $rootDir, 'name' => $name)); $this->assertEquals($env, $app->getEnvironment()); $this->assertEquals($debug, $app->isDebug()); @@ -70,7 +69,7 @@ public function testClone() public function testGetRootDir() { - $app = new AppForTest(array('environment' => 'test', 'debug' => true, 'rootDir' => __DIR__,)); + $app = new AppForTest(array('environment' => 'test', 'debug' => true, 'rootDir' => __DIR__)); $this->assertEquals(__DIR__, realpath($app->getRootDir())); @@ -81,16 +80,16 @@ public function testGetRootDir() public function testGetName() { - $app = new AppForTest(array('environment' => 'test', 'debug' => true, 'rootDir' => __DIR__,)); + $app = new AppForTest(array('environment' => 'test', 'debug' => true, 'rootDir' => __DIR__)); $this->assertEquals(basename(__DIR__), $app->getName()); - $app = new AppForTest(array('environment' => 'test', 'debug' => true, 'rootDir' => __DIR__, 'name' => 'testName',)); + $app = new AppForTest(array('environment' => 'test', 'debug' => true, 'rootDir' => __DIR__, 'name' => 'testName')); $this->assertEquals('testName', $app->getName()); } public function testRunWithControllerIndexAction() { - $app = new AppForDispatchTest(array('environment' => 'test', 'debug' => true, 'rootDir' => __DIR__,)); + $app = new AppForDispatchTest(array('environment' => 'test', 'debug' => true, 'rootDir' => __DIR__)); $this->controllerUnderTest = [new ControllerForAppTest(), 'indexAction']; @@ -105,7 +104,7 @@ public function testRunWithControllerIndexAction() public function testRunWithControllerInvokeAction() { - $app = new AppForDispatchTest(array('environment' => 'test', 'debug' => true, 'rootDir' => __DIR__,)); + $app = new AppForDispatchTest(array('environment' => 'test', 'debug' => true, 'rootDir' => __DIR__)); $this->controllerUnderTest = new ControllerForAppTest(); @@ -120,7 +119,7 @@ public function testRunWithControllerInvokeAction() public function testDispatch() { - $app = new AppForDispatchTest(array('environment' => 'test', 'debug' => true, 'rootDir' => __DIR__,)); + $app = new AppForDispatchTest(array('environment' => 'test', 'debug' => true, 'rootDir' => __DIR__)); $this->controllerUnderTest = [new ControllerForAppTest(), 'indexAction']; @@ -145,7 +144,6 @@ private function setupMockRouter() public function setupMockControllerResolver() { - $mockControllerResolver = $this->getMockBuilder('PPI\Framework\Module\Controller\ControllerResolver')->disableOriginalConstructor()->getMock(); $mockControllerResolver->expects($this->once())->method('getController')->willReturn( @@ -178,5 +176,4 @@ private function runApp($app, $request, $response) return $output; } - } From 8aa2b3d06b17af76298d13b867b0d4cbd1811828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Brand=C3=A3o?= Date: Thu, 4 Feb 2016 20:25:41 +0000 Subject: [PATCH 2/2] 156 Remove App::setOption(), App::getOption(). Fixes #156, #135 --- src/App.php | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) diff --git a/src/App.php b/src/App.php index aa6e7bb..f4df9e4 100644 --- a/src/App.php +++ b/src/App.php @@ -141,53 +141,6 @@ public function __construct(array $options = array()) } } - /** - * Set an App option. - * - * @param $option - * @param $value - * - * @throws \RuntimeException - * - * @return $this - */ - public function setOption($option, $value) - { - if (true === $this->booted) { - throw new \RuntimeException('Setting App options after boot() is now allowed'); - } - - // "root_dir" to "rootDir" - $property = preg_replace('/_(.?)/e', "strtoupper('$1')", $option); - if (!property_exists($this, $property)) { - throw new \RuntimeException(sprintf('App property "%s" (option "%s") does not exist', $property, $option)); - } - - $this->$property = $value; - - return $this; - } - - /** - * Get an App option. - * - * @param $option - * - * @throws \RuntimeException - * - * @return string - */ - public function getOption($option) - { - // "root_dir" to "rootDir" - $property = preg_replace('/_(.?)/e', "strtoupper('$1')", $option); - if (!property_exists($this, $property)) { - throw new \RuntimeException(sprintf('App property "%s" (option "%s") does not exist', $property, $option)); - } - - return $property; - } - public function __clone() { if ($this->debug) {