Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

The actual config file must always have .php extension. #772

Merged
merged 1 commit into from

3 participants

@ADmad
Collaborator

The file lib/Cake/Test/test_app/Config/var_test3 isn't needed right?

You don't need to make new pull requests each time. You can just amend your commit and the PR will be automatically updated.

@bar

Sorry for that one! I'm a git (full time console) user :P

It is necessary to exist and have a $config var inside, but the contents of $config doesn't matter, I just left them there for the people to understand that it is a perfectly valid config file but won't work as it does not end with .php.

If this is good to go, I'll update IniReader accordingly.

@markstory
Owner

I think this one is good to go.

@bar

Nice, should I update IniReader with the same behavior so it understands plugins?

@markstory
Owner

Yeah, having both work the same would be ideal. I can't believe I missed the plugin support for IniReader when it was added for PhpReader :(

@bar

You can't be everywhere Mark! Let some fun for us :P

@markstory markstory merged commit 08e4362 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 14, 2012
  1. @bar
This page is out of date. Refresh to see the latest.
View
9 lib/Cake/Configure/PhpReader.php
@@ -66,22 +66,21 @@ public function read($key) {
$key = substr($key, 0, -4);
}
list($plugin, $key) = pluginSplit($key);
+ $key .= '.php';
if ($plugin) {
$file = App::pluginPath($plugin) . 'Config' . DS . $key;
} else {
$file = $this->_path . $key;
}
- $file .= '.php';
if (!is_file($file)) {
- if (!is_file(substr($file, 0, -4))) {
- throw new ConfigureException(__d('cake_dev', 'Could not load configuration files: %s or %s', $file, substr($file, 0, -4)));
- }
+ throw new ConfigureException(__d('cake_dev', 'Could not load configuration file: %s', $file));
}
+
include $file;
if (!isset($config)) {
throw new ConfigureException(
- sprintf(__d('cake_dev', 'No variable $config found in %s.php'), $file)
+ sprintf(__d('cake_dev', 'No variable $config found in %s'), $file)
);
}
return $config;
View
25 lib/Cake/Test/Case/Configure/PhpReaderTest.php
@@ -41,7 +41,7 @@ class PhpReaderTest extends CakeTestCase {
);
/**
- * setup
+ * Setup.
*
* @return void
*/
@@ -51,7 +51,7 @@ public function setUp() {
}
/**
- * test reading files
+ * Test reading files.
*
* @return void
*/
@@ -66,20 +66,31 @@ public function testRead() {
}
/**
+ * Test an exception is thrown by reading files that exist without .php extension.
+ *
+ * @expectedException ConfigureException
+ * @return void
+ */
+ public function testReadWithExistentFileWithoutExtension() {
+ $reader = new PhpReader($this->path);
+ $reader->read('no_php_extension');
+ }
+
+/**
* Test an exception is thrown by reading files that don't exist.
*
* @expectedException ConfigureException
* @return void
*/
- public function testReadWithNonExistantFile() {
+ public function testReadWithNonExistentFile() {
$reader = new PhpReader($this->path);
$reader->read('fake_values');
}
/**
- * test reading an empty file.
+ * Test reading an empty file.
*
- * @expectedException RuntimeException
+ * @expectedException ConfigureException
* @return void
*/
public function testReadEmptyFile() {
@@ -88,7 +99,7 @@ public function testReadEmptyFile() {
}
/**
- * test reading keys with ../ doesn't work
+ * Test reading keys with ../ doesn't work.
*
* @expectedException ConfigureException
* @return void
@@ -99,7 +110,7 @@ public function testReadWithDots() {
}
/**
- * test reading from plugins
+ * Test reading from plugins.
*
* @return void
*/
View
9 lib/Cake/Test/test_app/Config/no_php_extension
@@ -0,0 +1,9 @@
+<?php
+// Test file for testing config file without .php extension.
+$config = array(
+ 'Deep' => array(
+ 'Third' => array(
+ 'ThirdDeepest' => 'buried3'
+ )
+ )
+);
Something went wrong with that request. Please try again.