Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 712b7ec

Browse files
committed
Merge pull request zendframework#565 from holtkamp/patch-early-suppress-file-not-found-warnings
Allow early suppressing of file not found warnings in Zend_Application
2 parents 7b0b96c + 63631b6 commit 712b7ec

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

library/Zend/Application.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,17 @@ class Zend_Application
7070
*
7171
* @param string $environment
7272
* @param string|array|Zend_Config $options String path to configuration file, or array/Zend_Config of configuration options
73+
* @param bool $suppressNotFoundWarnings Should warnings be suppressed when a file is not found during autoloading?
7374
* @throws Zend_Application_Exception When invalid options are provided
7475
* @return void
7576
*/
76-
public function __construct($environment, $options = null)
77+
public function __construct($environment, $options = null, $suppressNotFoundWarnings = null)
7778
{
7879
$this->_environment = (string) $environment;
7980

8081
require_once 'Zend/Loader/Autoloader.php';
8182
$this->_autoloader = Zend_Loader_Autoloader::getInstance();
83+
$this->_autoloader->suppressNotFoundWarnings($suppressNotFoundWarnings);
8284

8385
if (null !== $options) {
8486
if (is_string($options)) {

tests/Zend/Application/ApplicationTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,33 @@ public function testConstructorShouldSetOptionsWhenProvided()
108108
$this->assertEquals($options, $application->getOptions());
109109
}
110110

111+
/**
112+
* @group GH-564
113+
* @depends testConstructorInstantiatesAutoloader
114+
*/
115+
public function testConstructorRespectsSuppressFileNotFoundWarningFlag()
116+
{
117+
$application = new Zend_Application('testing');
118+
$this->assertFalse($application->getAutoloader()->suppressNotFoundWarnings()); //Default value
119+
120+
$application = new Zend_Application('testing', null, $suppressNotFoundWarnings = true);
121+
$this->assertTrue($application->getAutoloader()->suppressNotFoundWarnings());
122+
123+
$application = new Zend_Application('testing', null, $suppressNotFoundWarnings = false);
124+
$this->assertFalse($application->getAutoloader()->suppressNotFoundWarnings());
125+
126+
$options = array(
127+
'foo' => 'bar',
128+
'bar' => 'baz',
129+
);
130+
131+
$application = new Zend_Application('testing', $options, $suppressNotFoundWarnings = true);
132+
$this->assertTrue($application->getAutoloader()->suppressNotFoundWarnings());
133+
134+
$application = new Zend_Application('testing', $options, $suppressNotFoundWarnings = false);
135+
$this->assertFalse($application->getAutoloader()->suppressNotFoundWarnings());
136+
}
137+
111138
public function testHasOptionShouldReturnFalseWhenOptionNotPresent()
112139
{
113140
$this->assertFalse($this->application->hasOption('foo'));

0 commit comments

Comments
 (0)