1
0
Fork 0

Merge pull request #1830 from simensen/validate-autoload-options

Validate autoload options are of a supported type
pull/1833/head
Jordi Boggiano 2013-04-26 01:52:23 -07:00
commit c3ddeae01e
2 changed files with 31 additions and 1 deletions

View File

@ -179,7 +179,15 @@ class ValidatingArrayLoader implements LoaderInterface
} }
} }
// TODO validate autoload if ($this->validateArray('autoload') && !empty($this->config['autoload'])) {
$types = array('psr-0', 'classmap', 'files');
foreach ($this->config['autoload'] as $type => $typeConfig) {
if (!in_array($type, $types)) {
$this->errors[] = 'autoload : invalid value ('.$type.'), must be one of '.implode(', ', $types);
unset($this->config['autoload'][$type]);
}
}
}
// TODO validate dist // TODO validate dist
// TODO validate source // TODO validate source

View File

@ -234,6 +234,28 @@ class ValidatingArrayLoaderTest extends \PHPUnit_Framework_TestCase
'support.source : invalid value, must be a string', 'support.source : invalid value, must be a string',
) )
), ),
array(
array(
'name' => 'foo/bar',
'autoload' => 'strings',
),
array(
'autoload : should be an array, string given'
)
),
array(
array(
'name' => 'foo/bar',
'autoload' => array(
'psr0' => array(
'foo' => 'src',
),
),
),
array(
'autoload : invalid value (psr0), must be one of psr-0, classmap, files'
)
),
); );
} }