Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Captcha exceptions #4

Closed
wants to merge 10 commits into from

2 participants

@mikaelkael

Captcha exceptions: converts exception implementation, all tests passed

@adamlundrigan adamlundrigan referenced this pull request from a commit in adamlundrigan/zf2
@adamlundrigan adamlundrigan [ZF-12064] DOCUMENTATION: fix typo in code example #4 of Zend_File_Tr…
…ansfer-Validators.xml (en,fr,de,ja)
f5c0224
@spako spako referenced this pull request from a commit
@spako spako Workaround for PHP 5.3.2
Rename Zend\Stdlib\Glob::glob() to globStatic().

issue #4
9f3b8ff
@ghost Unknown referenced this pull request from a commit
@adamlundrigan adamlundrigan [ZF-12064] DOCUMENTATION: fix typo in code example #4 of Zend_File_Tr…
…ansfer-Validators.xml (en,fr,de,ja)
5bb22f3
@wuethrich44 wuethrich44 referenced this pull request from a commit in wuethrich44/zf2
@wuethrich44 wuethrich44 Bootstrap for Categorytests #4 061d71e
@gianarb gianarb referenced this pull request from a commit in zendframework/zend-config
@DASPRiD DASPRiD Merge pull request zendframework/zf2#4 from juriansluiman/feature/con…
…fig-refactoring

Rename interface methods Zend\Config\Reader and Zend\Config\Writer
89f8c8c
@gianarb gianarb referenced this pull request from a commit in zendframework/zend-cache
@marc-mabe marc-mabe Merge pull request zendframework/zf2#4 from weierophinney/feature/cac…
…he_beta2

Feature/cache beta2
8aa2c35
@isisis isisis referenced this pull request from a commit in isisis/zf2
@isisis isisis Fix for AbstractNavigationFactory.php
I think it's a common use case for the default navigation, to add pages and sub pages across many modules.
There's currently an issue when adding sub pages to another page that you expect to be in configuration already.
The main page could be changed to another name, could be removed or the module could be disabled inside an application architecture that uses ZF2 modules like plug-ins.

What happens in this case?

-------------------------------------------------------------
Fatal error: Uncaught exception 'Zend\Navigation\Exception\InvalidArgumentException' with message 'Invalid argument: Unable to determine class to instantiate' in /var/www/html/ebonikerp/vendor/zendframework/zendframework/library/Zend/Navigation/Page/AbstractPage.php:254 Stack trace: #0 /var/www/html/ebonikerp/vendor/zendframework/zendframework/library/Zend/Navigation/AbstractContainer.php(114): Zend\Navigation\Page\AbstractPage::factory(Array) #1 /var/www/html/ebonikerp/vendor/zendframework/zendframework/library/Zend/Navigation/AbstractContainer.php(165): Zend\Navigation\AbstractContainer->addPage(Array) #2 /var/www/html/ebonikerp/vendor/zendframework/zendframework/library/Zend/Navigation/Navigation.php(35): Zend\Navigation\AbstractContainer->addPages(Array) #3 /var/www/html/ebonikerp/vendor/zendframework/zendframework/library/Zend/Navigation/Service/AbstractNavigationFactory.php(38): Zend\Navigation\Navigation->__construct(Array) #4 [internal function]: Zend\Navigation\Service\AbstractNavigationFactory->createService(Obj in /var/www/html/ebonikerp/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 946
-------------------------------------------------------------

This fix solves the problem, by ignoring a main page, when it's missing uri or mvc values, and could be used as quick fix.

For future I would like to see a validation for the pages configs, before they're being injected to navigation.
Another approach could be to add a separate "navigation-extension" configuration beside the "navigation" configuration. The "navigation-extension" configuration could be used to extend the navigation safely. The NavigationFactory would then use only the configuration parts that already have a valid existing navigation entry inside "navigation" key.
c026176
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 8, 2010
  1. @ralphschindler
  2. @ralphschindler

    Renamed Zend\Authentication exceptions to match SPL in full

    ralphschindler authored
    Altered ZendTest\Authentication to test for new exceptions and messages
Commits on Sep 9, 2010
  1. @ralphschindler
  2. @ralphschindler
Commits on Sep 10, 2010
  1. @mikaelkael

    Merge branch 'milestones/exceptions' of git://git.zendframework.com/z…

    mikaelkael authored
    …f into milestones/exceptions
  2. @mikaelkael
  3. @mikaelkael
Commits on Sep 13, 2010
  1. @ralphschindler

    Added new exception support to Zend\Acl

    ralphschindler authored
    Moved _files in tests/Zend/Acl to TestAsset
Commits on Sep 14, 2010
  1. @mikaelkael
Commits on Sep 18, 2010
  1. @mikaelkael
This page is out of date. Refresh to see the latest.
Showing with 340 additions and 173 deletions.
  1. +22 −21 library/Zend/Acl/Acl.php
  2. +1 −1  library/Zend/Acl/Exception.php
  3. +8 −0 library/Zend/Acl/InvalidArgumentException.php
  4. +10 −9 library/Zend/Acl/Role/Registry.php
  5. +8 −0 library/Zend/Acl/RuntimeException.php
  6. +6 −3 library/Zend/Authentication/Adapter/DbTable.php
  7. +3 −3 library/Zend/Authentication/Adapter/Digest.php
  8. +1 −1  library/Zend/Authentication/Adapter/Exception.php
  9. +22 −19 library/Zend/Authentication/Adapter/Http.php
  10. +1 −1  library/Zend/Authentication/Adapter/Http/Exception.php
  11. +6 −6 library/Zend/Authentication/Adapter/Http/FileResolver.php
  12. +9 −0 library/Zend/Authentication/Adapter/Http/InvalidArgumentException.php
  13. +9 −0 library/Zend/Authentication/Adapter/Http/RuntimeException.php
  14. +9 −0 library/Zend/Authentication/Adapter/InvalidArgumentException.php
  15. +1 −1  library/Zend/Authentication/Adapter/Ldap.php
  16. +10 −0 library/Zend/Authentication/Adapter/RuntimeException.php
  17. +9 −0 library/Zend/Authentication/Adapter/UnexpectedValueException.php
  18. +1 −1  library/Zend/Authentication/Exception.php
  19. +2 −2 library/Zend/Captcha/Exception.php
  20. +41 −0 library/Zend/Captcha/Exception/ExtensionNotLoadedException.php
  21. +41 −0 library/Zend/Captcha/Exception/ImageNotLoadableException.php
  22. +13 −9 library/Zend/{Authentication/Storage/Exception.php → Captcha/Exception/NoFontProvidedException.php}
  23. +11 −7 library/Zend/Captcha/Image.php
  24. +24 −31 tests/Zend/Acl/AclTest.php
  25. +1 −1  tests/Zend/Acl/{_files → TestAsset}/AssertionZF7973.php
  26. +1 −1  tests/Zend/Acl/{_files → TestAsset}/ExtendedAclZF2234.php
  27. +1 −1  tests/Zend/Acl/{_files → TestAsset}/MockAssertion.php
  28. +24 −0 tests/Zend/Acl/TestAsset/UseCase1/Acl.php
  29. +1 −1  tests/Zend/Acl/{_files → TestAsset}/UseCase1/BlogPost.php
  30. +1 −1  tests/Zend/Acl/{_files → TestAsset}/UseCase1/User.php
  31. +1 −1  tests/Zend/Acl/{_files → TestAsset}/UseCase1/UserIsBlogPostOwnerAssertion.php
  32. +0 −28 tests/Zend/Acl/_files/UseCase1/Acl.php
  33. +9 −21 tests/Zend/Authentication/Adapter/DbTableTest.php
  34. +1 −1  tests/Zend/Authentication/Adapter/Ldap/OfflineTest.php
  35. +1 −1  tests/Zend/Authentication/AuthenticationServiceTest.php
  36. +18 −1 tests/Zend/Captcha/ImageTest.php
  37. +13 −0 working/README-exceptions.txt
View
43 library/Zend/Acl/Acl.php
@@ -124,6 +124,7 @@ class Acl
* @param Zend\Acl\Role $role
* @param Zend\Acl\Role|string|array $parents
* @uses Zend\Acl\Role\Registry::add()
+ * @throws Zend\Acl\InvalidArgumentException
* @return Zend\Acl\Acl Provides a fluent interface
*/
public function addRole($role, $parents = null)
@@ -133,7 +134,7 @@ public function addRole($role, $parents = null)
}
if (!$role instanceof Role) {
- throw new Exception('addRole() expects $role to be of type Zend_Acl_Role_Interface');
+ throw new InvalidArgumentException('addRole() expects $role to be of type Zend_Acl_Role_Interface');
}
@@ -257,7 +258,7 @@ public function removeRoleAll()
*
* @param Zend\Acl\Resource|string $resource
* @param Zend\Acl\Resource|string $parent
- * @throws Zend\Acl\Exception
+ * @throws Zend\Acl\InvalidArgumentException
* @return Zend\Acl\Acl Provides a fluent interface
*/
public function addResource($resource, $parent = null)
@@ -267,13 +268,13 @@ public function addResource($resource, $parent = null)
}
if (!$resource instanceof Resource) {
- throw new Exception('addResource() expects $resource to be of type Zend_Acl_Resource_Interface');
+ throw new InvalidArgumentException('addResource() expects $resource to be of type Zend_Acl_Resource_Interface');
}
$resourceId = $resource->getResourceId();
if ($this->hasResource($resourceId)) {
- throw new Exception("Resource id '$resourceId' already exists in the ACL");
+ throw new InvalidArgumentException("Resource id '$resourceId' already exists in the ACL");
}
$resourceParent = null;
@@ -287,7 +288,7 @@ public function addResource($resource, $parent = null)
}
$resourceParent = $this->getResource($resourceParentId);
} catch (Exception $e) {
- throw new Exception("Parent Resource id '$resourceParentId' does not exist", 0, $e);
+ throw new InvalidArgumentException("Parent Resource id '$resourceParentId' does not exist", 0, $e);
}
$this->_resources[$resourceParentId]['children'][$resourceId] = $resource;
}
@@ -307,7 +308,7 @@ public function addResource($resource, $parent = null)
* The $resource parameter can either be a Resource or a Resource identifier.
*
* @param Zend\Acl\Resource|string $resource
- * @throws Zend\Acl\Exception
+ * @throws Zend\Acl\InvalidArgumentException
* @return Zend\Acl\Resource
*/
public function getResource($resource)
@@ -319,7 +320,7 @@ public function getResource($resource)
}
if (!$this->hasResource($resource)) {
- throw new Exception("Resource '$resourceId' not found");
+ throw new InvalidArgumentException("Resource '$resourceId' not found");
}
return $this->_resources[$resourceId]['instance'];
@@ -356,7 +357,7 @@ public function hasResource($resource)
* @param Zend\Acl\Resource|string $resource
* @param Zend\Acl\Resource|string $inherit
* @param boolean $onlyParent
- * @throws Zend_Acl_Resource_Exception
+ * @throws Zend\Acl\InvalidArgumentException
* @return boolean
*/
public function inheritsResource($resource, $inherit, $onlyParent = false)
@@ -365,7 +366,7 @@ public function inheritsResource($resource, $inherit, $onlyParent = false)
$resourceId = $this->getResource($resource)->getResourceId();
$inheritId = $this->getResource($inherit)->getResourceId();
} catch (Exception $e) {
- throw new Exception($e->getMessage(), $e->getCode(), $e);
+ throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
}
if (null !== $this->_resources[$resourceId]['parent']) {
@@ -395,7 +396,7 @@ public function inheritsResource($resource, $inherit, $onlyParent = false)
* The $resource parameter can either be a Resource or a Resource identifier.
*
* @param Zend\Acl\Resource|string $resource
- * @throws Zend\Acl\Exception
+ * @throws Zend\Acl\InvalidArgumentException
* @return Zend\Acl\Acl Provides a fluent interface
*/
public function removeResource($resource)
@@ -403,7 +404,7 @@ public function removeResource($resource)
try {
$resourceId = $this->getResource($resource)->getResourceId();
} catch (Exception $e) {
- throw new Exception($e->getMessage(), $e->getCode(), $e);
+ throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
}
$resourcesRemoved = array($resourceId);
@@ -555,7 +556,7 @@ public function removeDeny($roles = null, $resources = null, $privileges = null)
* @param Zend\Acl\Resource|string|array $resources
* @param string|array $privileges
* @param Zend\Acl\Assertion $assert
- * @throws Zend\Acl\Exception
+ * @throws Zend\Acl\InvalidArgumentException
* @return Zend\Acl\Acl Provides a fluent interface
*/
public function setRule($operation, $type, $roles = null, $resources = null,
@@ -564,7 +565,7 @@ public function setRule($operation, $type, $roles = null, $resources = null,
// ensure that the rule type is valid; normalize input to uppercase
$type = strtoupper($type);
if (self::TYPE_ALLOW !== $type && self::TYPE_DENY !== $type) {
- throw new Exception("Unsupported rule type; must be either '" . self::TYPE_ALLOW . "' or '"
+ throw new InvalidArgumentException("Unsupported rule type; must be either '" . self::TYPE_ALLOW . "' or '"
. self::TYPE_DENY . "'");
}
@@ -673,7 +674,7 @@ public function setRule($operation, $type, $roles = null, $resources = null,
break;
default:
- throw new Exception("Unsupported operation; must be either '" . self::OP_ADD . "' or '"
+ throw new InvalidArgumentException("Unsupported operation; must be either '" . self::OP_ADD . "' or '"
. self::OP_REMOVE . "'");
}
@@ -841,12 +842,12 @@ protected function _roleDFSAllPrivileges(Role $role, Resource $resource = null)
* @param Zend\Acl\Resource $resource
* @param array $dfs
* @return boolean|null
- * @throws \Zend\Acl\Exception
+ * @throws \Zend\Acl\RuntimeException
*/
protected function _roleDFSVisitAllPrivileges(Role $role, Resource $resource = null, &$dfs = null)
{
if (null === $dfs) {
- throw new Exception('$dfs parameter may not be null');
+ throw new RuntimeException('$dfs parameter may not be null');
}
if (null !== ($rules = $this->_getRules($resource, $role))) {
@@ -879,12 +880,12 @@ protected function _roleDFSVisitAllPrivileges(Role $role, Resource $resource = n
* @param Zend\Acl\Resource $resource
* @param string $privilege
* @return boolean|null
- * @throws Zend\Acl\Exception
+ * @throws Zend\Acl\RuntimeException
*/
protected function _roleDFSOnePrivilege(Role $role, Resource $resource = null, $privilege = null)
{
if (null === $privilege) {
- throw new Exception('$privilege parameter may not be null');
+ throw new RuntimeException('$privilege parameter may not be null');
}
$dfs = array(
@@ -920,7 +921,7 @@ protected function _roleDFSOnePrivilege(Role $role, Resource $resource = null, $
* @param string $privilege
* @param array $dfs
* @return boolean|null
- * @throws Zend\Acl\Exception
+ * @throws Zend\Acl\RuntimeException
*/
protected function _roleDFSVisitOnePrivilege(Role $role, Resource $resource = null,
$privilege = null, &$dfs = null
@@ -929,14 +930,14 @@ protected function _roleDFSVisitOnePrivilege(Role $role, Resource $resource = nu
/**
* @see Zend_Acl_Exception
*/
- throw new Exception('$privilege parameter may not be null');
+ throw new RuntimeException('$privilege parameter may not be null');
}
if (null === $dfs) {
/**
* @see Zend_Acl_Exception
*/
- throw new Exception('$dfs parameter may not be null');
+ throw new RuntimeException('$dfs parameter may not be null');
}
if (null !== ($ruleTypeOnePrivilege = $this->_getRuleType($resource, $role, $privilege))) {
View
2  library/Zend/Acl/Exception.php
@@ -31,5 +31,5 @@
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Exception extends \Zend\Exception
+interface Exception
{}
View
8 library/Zend/Acl/InvalidArgumentException.php
@@ -0,0 +1,8 @@
+<?php
+
+namespace Zend\Acl;
+
+class InvalidArgumentException extends \InvalidArgumentException implements Exception
+{
+
+}
View
19 library/Zend/Acl/Role/Registry.php
@@ -25,6 +25,7 @@
namespace Zend\Acl\Role;
use Zend\Acl\Role;
+use Zend\Acl;
/**
* @uses Zend\Acl\Role
@@ -59,7 +60,7 @@ class Registry
*
* @param Zend\Acl\Role $role
* @param Zend\Acl\Role|string|array $parents
- * @throws Zend\Acl\Role\Exception
+ * @throws Zend\Acl\InvalidArgumentException
* @return Zend\Acl\Role\Registry Provides a fluent interface
*/
public function add(Role $role, $parents = null)
@@ -67,7 +68,7 @@ public function add(Role $role, $parents = null)
$roleId = $role->getRoleId();
if ($this->has($roleId)) {
- throw new Exception("Role id '$roleId' already exists in the registry");
+ throw new Acl\InvalidArgumentException("Role id '$roleId' already exists in the registry");
}
$roleParents = array();
@@ -85,7 +86,7 @@ public function add(Role $role, $parents = null)
}
$roleParent = $this->get($roleParentId);
} catch (Exception $e) {
- throw new Exception("Parent Role id '$roleParentId' does not exist", 0, $e);
+ throw new Acl\InvalidArgumentException("Parent Role id '$roleParentId' does not exist", 0, $e);
}
$roleParents[$roleParentId] = $roleParent;
$this->_roles[$roleParentId]['children'][$roleId] = $role;
@@ -107,7 +108,7 @@ public function add(Role $role, $parents = null)
* The $role parameter can either be a Role or a Role identifier.
*
* @param Zend\Acl\Role|string $role
- * @throws Zend\Acl\Role\Exception
+ * @throws Zend\Acl\InvalidArgumentException
* @return Zend\Acl\Role
*/
public function get($role)
@@ -119,7 +120,7 @@ public function get($role)
}
if (!$this->has($role)) {
- throw new Exception("Role '$roleId' not found");
+ throw new Acl\InvalidArgumentException("Role '$roleId' not found");
}
return $this->_roles[$roleId]['instance'];
@@ -177,7 +178,7 @@ public function getParents($role)
* @param Zend\Acl\Role|string $role
* @param Zend\Acl\Role|string $inherit
* @param boolean $onlyParents
- * @throws Zend\Acl\Role\Exception
+ * @throws Zend\Acl\InvalidArgumentException
* @return boolean
*/
public function inherits($role, $inherit, $onlyParents = false)
@@ -186,7 +187,7 @@ public function inherits($role, $inherit, $onlyParents = false)
$roleId = $this->get($role)->getRoleId();
$inheritId = $this->get($inherit)->getRoleId();
} catch (Exception $e) {
- throw new Exception($e->getMessage(), $e->getCode(), $e);
+ throw new Acl\InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
}
$inherits = isset($this->_roles[$roleId]['parents'][$inheritId]);
@@ -210,7 +211,7 @@ public function inherits($role, $inherit, $onlyParents = false)
* The $role parameter can either be a Role or a Role identifier.
*
* @param Zend\Acl\Role|string $role
- * @throws Zend\Acl\Role\Exception
+ * @throws Zend\Acl\InvalidArgumentException
* @return Zend\Acl\Role\Registry Provides a fluent interface
*/
public function remove($role)
@@ -218,7 +219,7 @@ public function remove($role)
try {
$roleId = $this->get($role)->getRoleId();
} catch (Exception $e) {
- throw new Exception($e->getMessage(), $e->getCode(), $e);
+ throw new Acl\InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
}
foreach ($this->_roles[$roleId]['children'] as $childId => $child) {
View
8 library/Zend/Acl/RuntimeException.php
@@ -0,0 +1,8 @@
+<?php
+
+namespace Zend\Acl;
+
+class RuntimeException extends \RuntimeException implements Exception
+{
+
+}
View
9 library/Zend/Authentication/Adapter/DbTable.php
@@ -172,7 +172,10 @@ protected function _setDbAdapter(AbstractDBAdapter $zendDb = null)
if(null === $this->_zendDb) {
$this->_zendDb = AbstractTable::getDefaultAdapter();
if (null === $this->_zendDb) {
- throw new Exception('No database adapter present');
+ throw new RuntimeException(
+ 'Null was provided for the adapter but there is no default'
+ . ' adatper registered with Zend\Db\Table to utilize.'
+ );
}
}
@@ -409,7 +412,7 @@ protected function _authenticateSetup()
}
if (null !== $exception) {
- throw new Exception($exception);
+ throw new RuntimeException($exception);
}
$this->_authenticateResultInfo = array(
@@ -476,7 +479,7 @@ protected function _authenticateQuerySelect(DBSelect $dbSelect)
unset($origDbFetchMode);
}
} catch (\Exception $e) {
- throw new Exception('The supplied parameters to Zend\\Authentication\\Adapter\\DbTable failed to '
+ throw new RuntimeException('The supplied parameters to Zend\Authentication\Adapter\DbTable failed to '
. 'produce a valid sql statement, please check table and column names '
. 'for validity.', 0, $e);
}
View
6 library/Zend/Authentication/Adapter/Digest.php
@@ -177,7 +177,7 @@ public function setPassword($password)
/**
* Defined by Zend_Auth_Adapter_Interface
*
- * @throws Zend\Authentication\Adapter\Exception
+ * @throws Zend\Authentication\Adapter\RuntimeException
* @return Zend\Authentication\Result
*/
public function authenticate()
@@ -185,12 +185,12 @@ public function authenticate()
$optionsRequired = array('filename', 'realm', 'username', 'password');
foreach ($optionsRequired as $optionRequired) {
if (null === $this->{"_$optionRequired"}) {
- throw new Exception("Option '$optionRequired' must be set before authentication");
+ throw new RuntimeException("Option '$optionRequired' must be set before authentication");
}
}
if (false === ($fileHandle = @fopen($this->_filename, 'r'))) {
- throw new Exception("Cannot open '$this->_filename' for reading");
+ throw new UnexpectedValueException("Cannot open '$this->_filename' for reading");
}
$id = "$this->_username:$this->_realm";
View
2  library/Zend/Authentication/Adapter/Exception.php
@@ -33,5 +33,5 @@
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Exception extends \Zend\Authentication\Exception
+interface Exception extends \Zend\Authentication\Exception
{}
View
41 library/Zend/Authentication/Adapter/Http.php
@@ -167,13 +167,13 @@ class Http implements AuthenticationAdapter
* 'use_opaque' => <bool> Whether to send the opaque value in the header
* 'alogrithm' => <string> See $_supportedAlgos. Default: MD5
* 'proxy_auth' => <bool> Whether to do authentication as a Proxy
- * @throws Zend\Authentication\Exception
+ * @throws Zend\Authentication\Adapter\InvalidArgumentException
* @return void
*/
public function __construct(array $config)
{
if (!extension_loaded('hash')) {
- throw new Exception(__CLASS__ . ' requires the \'hash\' extension');
+ throw new InvalidArgumentException(__CLASS__ . ' requires the \'hash\' extension to be availabe in PHP');
}
$this->_request = null;
@@ -182,13 +182,13 @@ public function __construct(array $config)
if (empty($config['accept_schemes'])) {
- throw new Exception('Config key \'accept_schemes\' is required');
+ throw new InvalidArgumentException('Config key \'accept_schemes\' is required');
}
$schemes = explode(' ', $config['accept_schemes']);
$this->_acceptSchemes = array_intersect($schemes, $this->_supportedSchemes);
if (empty($this->_acceptSchemes)) {
- throw new Exception('No supported schemes given in \'accept_schemes\'. Valid values: '
+ throw new InvalidArgumentException('No supported schemes given in \'accept_schemes\'. Valid values: '
. implode(', ', $this->_supportedSchemes));
}
@@ -198,7 +198,7 @@ public function __construct(array $config)
!ctype_print($config['realm']) ||
strpos($config['realm'], ':') !== false ||
strpos($config['realm'], '"') !== false) {
- throw new Exception('Config key \'realm\' is required, and must contain only printable '
+ throw new InvalidArgumentException('Config key \'realm\' is required, and must contain only printable '
. 'characters, excluding quotation marks and colons');
} else {
$this->_realm = $config['realm'];
@@ -208,7 +208,7 @@ public function __construct(array $config)
if (empty($config['digest_domains']) ||
!ctype_print($config['digest_domains']) ||
strpos($config['digest_domains'], '"') !== false) {
- throw new Exception('Config key \'digest_domains\' is required, and must contain '
+ throw new InvalidArgumentException('Config key \'digest_domains\' is required, and must contain '
. 'only printable characters, excluding quotation marks');
} else {
$this->_domains = $config['digest_domains'];
@@ -216,7 +216,7 @@ public function __construct(array $config)
if (empty($config['nonce_timeout']) ||
!is_numeric($config['nonce_timeout'])) {
- throw new Exception('Config key \'nonce_timeout\' is required, and must be an '
+ throw new InvalidArgumentException('Config key \'nonce_timeout\' is required, and must be an '
. 'integer');
} else {
$this->_nonceTimeout = (int) $config['nonce_timeout'];
@@ -339,14 +339,14 @@ public function getResponse()
/**
* Authenticate
*
- * @throws Zend\Authentication\Exception
+ * @throws Zend\Authentication\Adapter\RuntimeException
* @return Zend\Authentication\Result
*/
public function authenticate()
{
if (empty($this->_request) ||
empty($this->_response)) {
- throw new Exception('Request and Response objects must be set before calling '
+ throw new RuntimeException('Request and Response objects must be set before calling '
. 'authenticate()');
}
@@ -389,7 +389,7 @@ public function authenticate()
$result = $this->_digestAuth($authHeader);
break;
default:
- throw new Exception('Unsupported authentication scheme');
+ throw new RuntimeException('Unsupported authentication scheme: ' . $clientScheme);
}
return $result;
@@ -466,24 +466,25 @@ protected function _digestHeader()
* Basic Authentication
*
* @param string $header Client's Authorization header
- * @throws Zend\Authentication\Exception
+ * @throws Zend\Authentication\UnexpectedValueException
* @return Zend\Authentication\Result
*/
protected function _basicAuth($header)
{
if (empty($header)) {
- throw new Exception('The value of the client Authorization header is required');
+ throw new RuntimeException('The value of the client Authorization header is required');
}
if (empty($this->_basicResolver)) {
- throw new Exception('A basicResolver object must be set before doing Basic '
- . 'authentication');
+ throw new RuntimeException(
+ 'A basicResolver object must be set before doing Basic '
+ . 'authentication');
}
// Decode the Authorization header
$auth = substr($header, strlen('Basic '));
$auth = base64_decode($auth);
if (!$auth) {
- throw new Exception('Unable to base64_decode Authorization header value');
+ throw new RuntimeException('Unable to base64_decode Authorization header value');
}
// See ZF-1253. Validate the credentials the same way the digest
@@ -511,16 +512,18 @@ protected function _basicAuth($header)
* Digest Authentication
*
* @param string $header Client's Authorization header
- * @throws Zend\Authentication\Exception
+ * @throws Zend\Authentication\Adapter\UnexpectedValueException
+ * @throws Zend\Authentication\Adapter\MissingDependencyException
+ * @throws Zend\Authentication\Adapter\UnsupportedRequestException
* @return Zend\Authentication\Result Valid auth result only on successful auth
*/
protected function _digestAuth($header)
{
if (empty($header)) {
- throw new Exception('The value of the client Authorization header is required');
+ throw new RuntimeException('The value of the client Authorization header is required');
}
if (empty($this->_digestResolver)) {
- throw new Exception('A digestResolver object must be set before doing Digest authentication');
+ throw new RuntimeException('A digestResolver object must be set before doing Digest authentication');
}
$data = $this->_parseDigestAuth($header);
@@ -575,7 +578,7 @@ protected function _digestAuth($header)
// Should be REQUEST_METHOD . ':' . uri . ':' . hash(entity-body),
// but this isn't supported yet, so fall through to default case
default:
- throw new Exception('Client requested an unsupported qop option');
+ throw new RuntimeException('Client requested an unsupported qop option');
}
// Using hash() should make parameterizing the hash algorithm
// easier
View
2  library/Zend/Authentication/Adapter/Http/Exception.php
@@ -35,5 +35,5 @@
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Exception extends \Zend\Authentication\Exception
+interface Exception extends \Zend\Authentication\Adapter\Exception
{}
View
12 library/Zend/Authentication/Adapter/Http/FileResolver.php
@@ -68,7 +68,7 @@ public function __construct($path = '')
public function setFile($path)
{
if (empty($path) || !is_readable($path)) {
- throw new Exception('Path not readable: ' . $path);
+ throw new InvalidArgumentException('Path not readable: ' . $path);
}
$this->_file = $path;
@@ -109,22 +109,22 @@ public function getFile()
public function resolve($username, $realm)
{
if (empty($username)) {
- throw new Exception('Username is required');
+ throw new InvalidArgumentException('Username is required');
} else if (!ctype_print($username) || strpos($username, ':') !== false) {
- throw new Exception('Username must consist only of printable characters, '
+ throw new InvalidArgumentException('Username must consist only of printable characters, '
. 'excluding the colon');
}
if (empty($realm)) {
- throw new Exception('Realm is required');
+ throw new InvalidArgumentException('Realm is required');
} else if (!ctype_print($realm) || strpos($realm, ':') !== false) {
- throw new Exception('Realm must consist only of printable characters, '
+ throw new InvalidArgumentException('Realm must consist only of printable characters, '
. 'excluding the colon.');
}
// Open file, read through looking for matching credentials
$fp = @fopen($this->_file, 'r');
if (!$fp) {
- throw new Exception('Unable to open password file: ' . $this->_file);
+ throw new RuntimeException('Unable to open password file: ' . $this->_file);
}
// No real validation is done on the contents of the password file. The
View
9 library/Zend/Authentication/Adapter/Http/InvalidArgumentException.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace Zend\Authentication\Adapter\Http;
+
+class InvalidArgumentException
+ extends \InvalidArgumentException
+ implements Exception
+{
+}
View
9 library/Zend/Authentication/Adapter/Http/RuntimeException.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace Zend\Authentication\Adapter\Http;
+
+class RuntimeException
+ extends \RuntimeException
+ implements Exception
+{
+}
View
9 library/Zend/Authentication/Adapter/InvalidArgumentException.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace Zend\Authentication\Adapter;
+
+class InvalidArgumentException
+ extends \InvalidArgumentException
+ implements Exception
+{
+}
View
2  library/Zend/Authentication/Adapter/Ldap.php
@@ -281,7 +281,7 @@ public function authenticate()
foreach ($this->_options as $name => $options) {
if (!is_array($options)) {
- throw new Exception('Adapter options array not an array');
+ throw new InvalidArgumentException('Adapter options array not an array');
}
$adapterOptions = $this->_prepareOptions($ldap, $options);
$dname = '';
View
10 library/Zend/Authentication/Adapter/RuntimeException.php
@@ -0,0 +1,10 @@
+<?php
+
+namespace Zend\Authentication\Adapter;
+
+class RuntimeException
+ extends \RuntimeException
+ implements Exception
+{
+
+}
View
9 library/Zend/Authentication/Adapter/UnexpectedValueException.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace Zend\Authentication\Adapter;
+
+class UnexpectedValueException
+ extends \UnexpectedValueException
+ implements Exception
+{
+}
View
2  library/Zend/Authentication/Exception.php
@@ -31,5 +31,5 @@
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Exception extends \Zend\Exception
+interface Exception
{}
View
4 library/Zend/Captcha/Exception.php
@@ -27,12 +27,12 @@
/**
* Exception for Zend_Form component.
*
- * @uses \Zend\Exception
+ * @uses Zend\Exception
* @category Zend
* @package Zend_Captcha
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Exception extends \Zend\Exception
+interface Exception
{
}
View
41 library/Zend/Captcha/Exception/ExtensionNotLoadedException.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Captcha
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @version $Id$
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+/**
+ * @namespace
+ */
+namespace Zend\Captcha\Exception;
+use Zend\Captcha\Exception;
+
+/**
+ * Exception for Zend_Form component.
+ *
+ * @uses Zend\Exception
+ * @category Zend
+ * @package Zend_Captcha
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ExtensionNotLoadedException
+ extends \Exception
+ implements Exception
+{
+}
View
41 library/Zend/Captcha/Exception/ImageNotLoadableException.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Captcha
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @version $Id$
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+/**
+ * @namespace
+ */
+namespace Zend\Captcha\Exception;
+use Zend\Captcha\Exception;
+
+/**
+ * Exception for Zend_Form component.
+ *
+ * @uses Zend\Exception
+ * @category Zend
+ * @package Zend_Captcha
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ImageNotLoadableException
+ extends \Exception
+ implements Exception
+{
+}
View
22 library/Zend/Authentication/Storage/Exception.php → ...end/Captcha/Exception/NoFontProvidedException.php
@@ -13,25 +13,29 @@
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
- * @package Zend_Authentication
- * @subpackage Storage
+ * @package Zend_Captcha
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
+ * @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* @namespace
*/
-namespace Zend\Authentication\Storage;
+namespace Zend\Captcha\Exception;
+use Zend\Captcha\Exception;
/**
- * @uses Zend\Authentication\Exception
+ * Exception for Zend_Form component.
+ *
+ * @uses Zend\Exception
* @category Zend
- * @package Zend_Authentication
- * @subpackage Storage
+ * @package Zend_Captcha
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Exception extends \Zend\Authentication\Exception
-{}
+class NoFontProvidedException
+ extends \Exception
+ implements Exception
+{
+}
View
18 library/Zend/Captcha/Image.php
@@ -24,6 +24,9 @@
* @namespace
*/
namespace Zend\Captcha;
+use Zend\Captcha\Exception\NoFontProvidedException,
+ Zend\Captcha\Exception\ExtensionNotLoadedException,
+ Zend\Captcha\Exception\ImageNotLoadableException;
/**
* Image-based captcha element
@@ -450,21 +453,21 @@ public function generate()
protected function _generateImage($id, $word)
{
if (!extension_loaded("gd")) {
- throw new Exception("Image CAPTCHA requires GD extension");
+ throw new ExtensionNotLoadedException("Image CAPTCHA requires GD extension");
}
if (!function_exists("imagepng")) {
- throw new Exception("Image CAPTCHA requires PNG support");
+ throw new ExtensionNotLoadedException("Image CAPTCHA requires PNG support");
}
if (!function_exists("imageftbbox")) {
- throw new Exception("Image CAPTCHA requires FT fonts support");
+ throw new ExtensionNotLoadedException("Image CAPTCHA requires FT fonts support");
}
$font = $this->getFont();
if (empty($font)) {
- throw new Exception("Image CAPTCHA requires font");
+ throw new NoFontProvidedException("Image CAPTCHA requires font");
}
$w = $this->getWidth();
@@ -473,11 +476,12 @@ protected function _generateImage($id, $word)
$img_file = $this->getImgDir() . $id . $this->getSuffix();
if(empty($this->_startImage)) {
- $img = imagecreatetruecolor($w, $h);
+ $img = imagecreatetruecolor($w, $h);
} else {
- $img = imagecreatefrompng($this->_startImage);
+ // Potential error is change to exception
+ $img = @imagecreatefrompng($this->_startImage);
if(!$img) {
- throw new Exception("Can not load start image");
+ throw new ImageNotLoadableException("Can not load start image");
}
$w = imagesx($img);
$h = imagesy($img);
View
55 tests/Zend/Acl/AclTest.php
@@ -29,13 +29,6 @@
Zend\Acl\Role,
Zend\Acl\Resource;
-require_once __DIR__ . '/_files/MockAssertion.php';
-require_once __DIR__ . '/_files/ExtendedAclZF2234.php';
-require_once __DIR__ . '/_files/UseCase1/User.php';
-require_once __DIR__ . '/_files/UseCase1/BlogPost.php';
-require_once __DIR__ . '/_files/UseCase1/Acl.php';
-require_once __DIR__ . '/_files/AssertionZF7973.php';
-
/**
* @category Zend
* @package Zend_Acl
@@ -110,7 +103,7 @@ public function testRoleRegistryRemoveOne()
*/
public function testRoleRegistryRemoveOneNonExistent()
{
- $this->setExpectedException('Zend\Acl\Role\Exception', 'not found');
+ $this->setExpectedException('\Zend\Acl\InvalidArgumentException', 'not found');
$this->_acl->removeRole('nonexistent');
}
@@ -134,7 +127,7 @@ public function testRoleRegistryRemoveAll()
*/
public function testRoleRegistryAddInheritsNonExistent()
{
- $this->setExpectedException('Zend\Acl\Role\Exception', 'does not exist');
+ $this->setExpectedException('Zend\Acl\InvalidArgumentException', 'not found');
$this->_acl->addRole(new Role\GenericRole('guest'), 'nonexistent');
}
@@ -150,13 +143,13 @@ public function testRoleRegistryInheritsNonExistent()
try {
$this->_acl->inheritsRole('nonexistent', $roleGuest);
$this->fail('Expected Zend\Acl\Role\Exception not thrown upon specifying a non-existent child Role');
- } catch (Role\Exception $e) {
+ } catch (Acl\InvalidArgumentException $e) {
$this->assertContains('not found', $e->getMessage());
}
try {
$this->_acl->inheritsRole($roleGuest, 'nonexistent');
$this->fail('Expected Zend\Acl\Role\Exception not thrown upon specifying a non-existent child Role');
- } catch (Role\Exception $e) {
+ } catch (Acl\InvalidArgumentException $e) {
$this->assertContains('not found', $e->getMessage());
}
}
@@ -232,7 +225,7 @@ public function testRoleRegistryDuplicate()
{
$roleGuest = new Role\GenericRole('guest');
$roleRegistry = new Role\Registry();
- $this->setExpectedException('Zend\Acl\Role\Exception', 'already exists');
+ $this->setExpectedException('Zend\Acl\InvalidArgumentException', 'already exists');
$roleRegistry->add($roleGuest)
->add($roleGuest);
}
@@ -247,7 +240,7 @@ public function testRoleRegistryDuplicateId()
$roleGuest1 = new Role\GenericRole('guest');
$roleGuest2 = new Role\GenericRole('guest');
$roleRegistry = new Role\Registry();
- $this->setExpectedException('Zend\Acl\Role\Exception', 'already exists');
+ $this->setExpectedException('Zend\Acl\InvalidArgumentException', 'already exists');
$roleRegistry->add($roleGuest1)
->add($roleGuest2);
}
@@ -337,7 +330,7 @@ public function testResourceRemoveAll()
*/
public function testResourceAddInheritsNonExistent()
{
- $this->setExpectedException('Zend\Acl\Exception', 'does not exist');
+ $this->setExpectedException('Zend\Acl\InvalidArgumentException', 'does not exist');
$this->_acl->addResource(new Resource\GenericResource('area'), 'nonexistent');
}
@@ -424,13 +417,13 @@ public function testIsAllowedNonExistent()
try {
$this->_acl->isAllowed('nonexistent');
$this->fail('Expected Zend\Acl\Role\Exception not thrown upon non-existent Role');
- } catch (Role\Exception $e) {
+ } catch (Acl\InvalidArgumentException $e) {
$this->assertContains('not found', $e->getMessage());
}
try {
$this->_acl->isAllowed(null, 'nonexistent');
$this->fail('Expected Zend\Acl\Exception not thrown upon non-existent Resource');
- } catch (Acl\Exception $e) {
+ } catch (Acl\InvalidArgumentException $e) {
$this->assertContains('not found', $e->getMessage());
}
}
@@ -452,7 +445,7 @@ public function testDefaultDeny()
*/
public function testDefaultAssert()
{
- $this->_acl->deny(null, null, null, new MockAssertion(false));
+ $this->_acl->deny(null, null, null, new TestAsset\MockAssertion(false));
$this->assertTrue($this->_acl->isAllowed());
$this->assertTrue($this->_acl->isAllowed(null, null, 'somePrivilege'));
}
@@ -542,9 +535,9 @@ public function testPrivileges()
*/
public function testPrivilegeAssert()
{
- $this->_acl->allow(null, null, 'somePrivilege', new MockAssertion(true));
+ $this->_acl->allow(null, null, 'somePrivilege', new TestAsset\MockAssertion(true));
$this->assertTrue($this->_acl->isAllowed(null, null, 'somePrivilege'));
- $this->_acl->allow(null, null, 'somePrivilege', new MockAssertion(false));
+ $this->_acl->allow(null, null, 'somePrivilege', new TestAsset\MockAssertion(false));
$this->assertFalse($this->_acl->isAllowed(null, null, 'somePrivilege'));
}
@@ -659,9 +652,9 @@ public function testRolePrivilegeAssert()
{
$roleGuest = new Role\GenericRole('guest');
$this->_acl->addRole($roleGuest)
- ->allow($roleGuest, null, 'somePrivilege', new MockAssertion(true));
+ ->allow($roleGuest, null, 'somePrivilege', new TestAsset\MockAssertion(true));
$this->assertTrue($this->_acl->isAllowed($roleGuest, null, 'somePrivilege'));
- $this->_acl->allow($roleGuest, null, 'somePrivilege', new MockAssertion(false));
+ $this->_acl->allow($roleGuest, null, 'somePrivilege', new TestAsset\MockAssertion(false));
$this->assertFalse($this->_acl->isAllowed($roleGuest, null, 'somePrivilege'));
}
@@ -684,7 +677,7 @@ public function testRemoveDefaultDeny()
*/
public function testRemoveDefaultDenyAssert()
{
- $this->_acl->deny(null, null, null, new MockAssertion(false));
+ $this->_acl->deny(null, null, null, new TestAsset\MockAssertion(false));
$this->assertTrue($this->_acl->isAllowed());
$this->_acl->removeDeny();
$this->assertFalse($this->_acl->isAllowed());
@@ -790,7 +783,7 @@ public function testRuleRoleRemove()
try {
$this->_acl->isAllowed('guest');
$this->fail('Expected Zend\Acl\Role\Exception not thrown upon isAllowed() on non-existent Role');
- } catch (Role\Exception $e) {
+ } catch (Acl\InvalidArgumentException $e) {
$this->assertContains('not found', $e->getMessage());
}
$this->_acl->addRole(new Role\GenericRole('guest'));
@@ -811,7 +804,7 @@ public function testRuleRoleRemoveAll()
try {
$this->_acl->isAllowed('guest');
$this->fail('Expected Zend\Acl\Role\Exception not thrown upon isAllowed() on non-existent Role');
- } catch (Role\Exception $e) {
+ } catch (Acl\InvalidArgumentException $e) {
$this->assertContains('not found', $e->getMessage());
}
$this->_acl->addRole(new Role\GenericRole('guest'));
@@ -1049,7 +1042,7 @@ public function testRoleInheritanceSupportsCheckingOnlyParents()
*/
public function testAclInternalDFSMethodsBehaveProperly()
{
- $acl = new ExtendedAclZF2234();
+ $acl = new TestAsset\ExtendedAclZF2234();
$someResource = new Resource\GenericResource('someResource');
$someRole = new Role\GenericRole('someRole');
@@ -1119,8 +1112,8 @@ public function testAclAssertionsGetOriginalIsAllowedObjects()
{
$acl = $this->_loadUseCase1();
- $user = new UseCase1\User();
- $blogPost = new UseCase1\BlogPost();
+ $user = new TestAsset\UseCase1\User();
+ $blogPost = new TestAsset\UseCase1\BlogPost();
$this->assertTrue($acl->isAllowed($user, $blogPost, 'view'));
@@ -1136,8 +1129,8 @@ public function testAclAssertionsGetOriginalIsAllowedObjects()
$this->assertFalse($acl->isAllowed($user, $blogPost, 'modify'), 'Assertion should return false');
// check to see if the last assertion has the proper objets
- $this->assertType('ZendTest\Acl\UseCase1\User', $assertion->lastAssertRole, 'Assertion did not recieve proper role object');
- $this->assertType('ZendTest\Acl\UseCase1\BlogPost', $assertion->lastAssertResource, 'Assertion did not recieve proper resource object');
+ $this->assertType('ZendTest\Acl\TestAsset\UseCase1\User', $assertion->lastAssertRole, 'Assertion did not recieve proper role object');
+ $this->assertType('ZendTest\Acl\TestAsset\UseCase1\BlogPost', $assertion->lastAssertResource, 'Assertion did not recieve proper resource object');
}
@@ -1147,7 +1140,7 @@ public function testAclAssertionsGetOriginalIsAllowedObjects()
*/
protected function _loadUseCase1()
{
- return new UseCase1\Acl();
+ return new TestAsset\UseCase1\Acl();
}
/**
@@ -1205,7 +1198,7 @@ public function testResourceObjectImplementsToString()
*/
public function testAclPassesPrivilegeToAssertClass()
{
- $assertion = new AssertionZF7973();
+ $assertion = new TestAsset\AssertionZF7973();
$acl = new Acl\Acl();
$acl->addRole('role');
View
2  tests/Zend/Acl/_files/AssertionZF7973.php → tests/Zend/Acl/TestAsset/AssertionZF7973.php
@@ -1,6 +1,6 @@
<?php
-namespace ZendTest\Acl;
+namespace ZendTest\Acl\TestAsset;
use Zend\Acl\Assertion,
Zend\Acl;
View
2  tests/Zend/Acl/_files/ExtendedAclZF2234.php → tests/Zend/Acl/TestAsset/ExtendedAclZF2234.php
@@ -1,6 +1,6 @@
<?php
-namespace ZendTest\Acl;
+namespace ZendTest\Acl\TestAsset;
use Zend\Acl;
class ExtendedAclZF2234 extends Acl\Acl
View
2  tests/Zend/Acl/_files/MockAssertion.php → tests/Zend/Acl/TestAsset/MockAssertion.php
@@ -1,6 +1,6 @@
<?php
-namespace ZendTest\Acl;
+namespace ZendTest\Acl\TestAsset;
use Zend\Acl;
View
24 tests/Zend/Acl/TestAsset/UseCase1/Acl.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace ZendTest\Acl\TestAsset\UseCase1;
+
+class Acl extends \Zend\Acl\Acl
+{
+
+ public $customAssertion = null;
+
+ public function __construct()
+ {
+ $this->customAssertion = new UserIsBlogPostOwnerAssertion();
+
+ $this->addRole(new \Zend\Acl\Role\GenericRole('guest')); // $acl->addRole('guest');
+ $this->addRole(new \Zend\Acl\Role\GenericRole('contributor'), 'guest'); // $acl->addRole('contributor', 'guest');
+ $this->addRole(new \Zend\Acl\Role\GenericRole('publisher'), 'contributor'); // $acl->addRole('publisher', 'contributor');
+ $this->addRole(new \Zend\Acl\Role\GenericRole('admin')); // $acl->addRole('admin');
+ $this->addResource(new \Zend\Acl\Resource\GenericResource('blogPost')); // $acl->addResource('blogPost');
+ $this->allow('guest', 'blogPost', 'view');
+ $this->allow('contributor', 'blogPost', 'contribute');
+ $this->allow('contributor', 'blogPost', 'modify', $this->customAssertion);
+ $this->allow('publisher', 'blogPost', 'publish');
+ }
+}
View
2  tests/Zend/Acl/_files/UseCase1/BlogPost.php → tests/Zend/Acl/TestAsset/UseCase1/BlogPost.php
@@ -1,6 +1,6 @@
<?php
-namespace ZendTest\Acl\UseCase1;
+namespace ZendTest\Acl\TestAsset\UseCase1;
use Zend\Acl\Resource;
View
2  tests/Zend/Acl/_files/UseCase1/User.php → tests/Zend/Acl/TestAsset/UseCase1/User.php
@@ -1,6 +1,6 @@
<?php
-namespace ZendTest\Acl\UseCase1;
+namespace ZendTest\Acl\TestAsset\UseCase1;
use Zend\Acl\Role;
View
2  .../_files/UseCase1/UserIsBlogPostOwnerAssertion.php → ...stAsset/UseCase1/UserIsBlogPostOwnerAssertion.php
@@ -1,6 +1,6 @@
<?php
-namespace ZendTest\Acl\UseCase1;
+namespace ZendTest\Acl\TestAsset\UseCase1;
use Zend\Acl\Assertion,
Zend\Acl as ZendAcl;
View
28 tests/Zend/Acl/_files/UseCase1/Acl.php
@@ -1,28 +0,0 @@
-<?php
-
-namespace ZendTest\Acl\UseCase1;
-
-use Zend;
-
-require_once __DIR__ . '/UserIsBlogPostOwnerAssertion.php';
-
-class Acl extends Zend\Acl\Acl
-{
-
- public $customAssertion = null;
-
- public function __construct()
- {
- $this->customAssertion = new UserIsBlogPostOwnerAssertion();
-
- $this->addRole(new Zend\Acl\Role\GenericRole('guest')); // $acl->addRole('guest');
- $this->addRole(new Zend\Acl\Role\GenericRole('contributor'), 'guest'); // $acl->addRole('contributor', 'guest');
- $this->addRole(new Zend\Acl\Role\GenericRole('publisher'), 'contributor'); // $acl->addRole('publisher', 'contributor');
- $this->addRole(new Zend\Acl\Role\GenericRole('admin')); // $acl->addRole('admin');
- $this->addResource(new Zend\Acl\Resource\GenericResource('blogPost')); // $acl->addResource('blogPost');
- $this->allow('guest', 'blogPost', 'view');
- $this->allow('contributor', 'blogPost', 'contribute');
- $this->allow('contributor', 'blogPost', 'modify', $this->customAssertion);
- $this->allow('publisher', 'blogPost', 'publish');
- }
-}
View
30 tests/Zend/Authentication/Adapter/DbTableTest.php
@@ -129,7 +129,7 @@ public function testAuthenticateFailureIdentityNotFound()
try {
$result = $this->_adapter->authenticate();
$this->assertEquals(Authentication\Result::FAILURE_IDENTITY_NOT_FOUND, $result->getCode());
- } catch (Authentication\Exception $e) {
+ } catch (Adapter\RuntimeException $e) {
$this->fail('Exception should have been thrown');
}
}
@@ -150,7 +150,7 @@ public function testAuthenticateFailureIdentityAmbigious()
try {
$result = $this->_adapter->authenticate();
$this->assertEquals(Authentication\Result::FAILURE_IDENTITY_AMBIGUOUS, $result->getCode());
- } catch (Authentication\Exception $e) {
+ } catch (Adapter\RuntimeException $e) {
$this->fail('Exception should have been thrown');
}
}
@@ -252,75 +252,63 @@ public function testAdapterReturnsASelectObjectWithoutAuthTimeModificationsAfter
/**
* Ensure that exceptions are caught
- *
- * @expectedException Zend\Authentication\Exception
*/
public function testCatchExceptionNoTable()
{
+ $this->setExpectedException('Zend\Authentication\Adapter\RuntimeException', 'A table must be supplied for');
$adapter = new Adapter\DbTable($this->_db);
$result = $adapter->authenticate();
- // $this->assertEquals($e->getMessage(), 'A table must be supplied for the Zend_Auth_Adapter_DbTable authentication adapter.');
}
/**
* Ensure that exceptions are caught
- *
- * @expectedException Zend\Authentication\Exception
*/
public function testCatchExceptionNoIdentityColumn()
{
+ $this->setExpectedException('Zend\Authentication\Adapter\RuntimeException', 'An identity column must be supplied for the');
$adapter = new Adapter\DbTable($this->_db, 'users');
$result = $adapter->authenticate();
- // $this->assertEquals($e->getMessage(), 'An identity column must be supplied for the Zend_Auth_Adapter_DbTable authentication adapter.');
}
/**
* Ensure that exceptions are caught
- *
- * @expectedException Zend\Authentication\Exception
*/
public function testCatchExceptionNoCredentialColumn()
{
+ $this->setExpectedException('Zend\Authentication\Adapter\RuntimeException', 'A credential column must be supplied');
$adapter = new Adapter\DbTable($this->_db, 'users', 'username');
$result = $adapter->authenticate();
- // $this->assertEquals($e->getMessage(), 'A credential column must be supplied for the Zend_Auth_Adapter_DbTable authentication adapter.');
}
/**
* Ensure that exceptions are caught
- *
- * @expectedException Zend\Authentication\Exception
*/
public function testCatchExceptionNoIdentity()
{
+ $this->setExpectedException('Zend\Authentication\Adapter\RuntimeException', 'A value for the identity was not provided prior');
$result = $this->_adapter->authenticate();
- // $this->assertEquals($e->getMessage(), 'A value for the identity was not provided prior to authentication with Zend_Auth_Adapter_DbTable.');
}
/**
* Ensure that exceptions are caught
- *
- * @expectedException Zend\Authentication\Exception
*/
public function testCatchExceptionNoCredential()
{
+ $this->setExpectedException('Zend\Authentication\Adapter\RuntimeException', 'A credential value was not provided prior');
$this->_adapter->setIdentity('my_username');
$result = $this->_adapter->authenticate();
- // $this->assertEquals($e->getMessage(), 'A credential value was not provided prior to authentication with Zend_Auth_Adapter_DbTable.');
}
/**
* Ensure that exceptions are caught
- *
- * @expectedException Zend\Authentication\Exception
*/
public function testCatchExceptionBadSql()
{
+ $this->setExpectedException('Zend\Authentication\Adapter\RuntimeException', 'The supplied parameters to');
$this->_adapter->setTableName('bad_table_name');
$this->_adapter->setIdentity('value');
$this->_adapter->setCredential('value');
$result = $this->_adapter->authenticate();
- // $this->assertEquals($e->getMessage(), 'The supplied parameters to Zend_Auth_Adapter_DbTable failed to produce a valid sql statement, please check table and column names for validity.');
}
/**
@@ -347,7 +335,7 @@ public function testDbTableAdapterUsesCaseFolding()
*/
public function testAuthenticateWithDefaultDbAdapterNoAdapterException()
{
- $this->setExpectedException('Zend\Authentication\Adapter\Exception', "No database adapter present");
+ $this->setExpectedException('Zend\Authentication\Adapter\RuntimeException', 'Null was provided');
// make sure that no default adapter exists
\Zend\Db\Table\AbstractTable::setDefaultAdapter(null);
View
2  tests/Zend/Authentication/Adapter/Ldap/OfflineTest.php
@@ -60,7 +60,7 @@ public function testGetSetLdap()
$this->markTestSkipped('LDAP is not enabled');
}
$this->_adapter->setLdap(new \Zend\Ldap\Ldap());
- $this->assertType('Zend_Ldap', $this->_adapter->getLdap());
+ $this->assertType('Zend\Ldap\Ldap', $this->_adapter->getLdap());
}
public function testUsernameIsNullIfNotSet()
View
2  tests/Zend/Authentication/AuthenticationServiceTest.php
@@ -36,7 +36,7 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
* @group Zend_Auth
*/
-class AuthTest extends \PHPUnit_Framework_TestCase
+class AuthenticationServiceTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
View
19 tests/Zend/Captcha/ImageTest.php
@@ -24,7 +24,8 @@
* @namespace
*/
namespace ZendTest\Captcha;
-use Zend\View\View;
+use Zend\View\View,
+ Zend\Captcha\Image;
/**
* @category Zend
@@ -311,5 +312,21 @@ public function testIsValidShouldNotRequireValueToBeNestedArray()
$input = array("id" => $this->captcha->getId(), "input" => $this->captcha->getWord());
$this->assertTrue($this->element->isValid($input));
}
+
+ public function testNoFontProvidedWillThrowException()
+ {
+ $this->setExpectedException('Zend\Captcha\Exception\NoFontProvidedException');
+ $captcha = new Image();
+ $captcha->generate();
+ }
+
+ public function testImageProvidedNotLoadableWillThrowException()
+ {
+ $this->setExpectedException('Zend\Captcha\Exception\ImageNotLoadableException');
+ $captcha = new Image(array('font' => __DIR__. '/../Pdf/_fonts/Vera.ttf',
+ 'startImage' => 'file_not_found.png'));
+ $captcha->generate();
+ }
+
}
View
13 working/README-exceptions.txt
@@ -0,0 +1,13 @@
+Converting To Exceptions
+
+Since this is a community effort, this list will serve as a place where the community
+can keep track of which components are complete, currently being worked on, or available
+to be worked on.
+
+
+In alphabetical order:
+
+Zend\Authentication COMPLETE Ralph Schindler (ralph)
+Zend\AccessControl IN PROGRESS Ralph Schindler (ralph)
+Zend\Paginator IN PROGRESS Wil Moore (wilmoore)
+Zend\Tool IN PROGRESS Ralph Schindler (ralph)
Something went wrong with that request. Please try again.