2
0

AclTest.php 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Acl
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * Test helper
  24. */
  25. require_once dirname(__FILE__) . '/../TestHelper.php';
  26. /**
  27. * Zend_Acl
  28. */
  29. require_once 'Zend/Acl.php';
  30. /**
  31. * Zend_Acl_Resource
  32. */
  33. require_once 'Zend/Acl/Resource.php';
  34. /**
  35. * Zend_Acl_Role
  36. */
  37. require_once 'Zend/Acl/Role.php';
  38. /**
  39. * @category Zend
  40. * @package Zend_Acl
  41. * @subpackage UnitTests
  42. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  43. * @license http://framework.zend.com/license/new-bsd New BSD License
  44. */
  45. class Zend_AclTest extends PHPUnit_Framework_TestCase
  46. {
  47. /**
  48. * ACL object for each test method
  49. *
  50. * @var Zend_Acl
  51. */
  52. protected $_acl;
  53. /**
  54. * Instantiates a new ACL object and creates internal reference to it for each test method
  55. *
  56. * @return void
  57. */
  58. public function setUp()
  59. {
  60. $this->_acl = new Zend_Acl();
  61. }
  62. /**
  63. * Ensures that basic addition and retrieval of a single Role works
  64. *
  65. * @return void
  66. */
  67. public function testRoleRegistryAddAndGetOne()
  68. {
  69. $roleGuest = new Zend_Acl_Role('guest');
  70. $role = $this->_acl->addRole($roleGuest)
  71. ->getRole($roleGuest->getRoleId());
  72. $this->assertTrue($roleGuest === $role);
  73. $role = $this->_acl->getRole($roleGuest);
  74. $this->assertTrue($roleGuest === $role);
  75. }
  76. /**
  77. * Ensures that basic removal of a single Role works
  78. *
  79. * @return void
  80. */
  81. public function testRoleRegistryRemoveOne()
  82. {
  83. $roleGuest = new Zend_Acl_Role('guest');
  84. $this->_acl->addRole($roleGuest)
  85. ->removeRole($roleGuest);
  86. $this->assertFalse($this->_acl->hasRole($roleGuest));
  87. }
  88. /**
  89. * Ensures that an exception is thrown when a non-existent Role is specified for removal
  90. *
  91. * @return void
  92. */
  93. public function testRoleRegistryRemoveOneNonExistent()
  94. {
  95. try {
  96. $this->_acl->removeRole('nonexistent');
  97. $this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon removing a non-existent Role');
  98. } catch (Zend_Acl_Role_Registry_Exception $e) {
  99. $this->assertContains('not found', $e->getMessage());
  100. }
  101. }
  102. /**
  103. * Ensures that removal of all Roles works
  104. *
  105. * @return void
  106. */
  107. public function testRoleRegistryRemoveAll()
  108. {
  109. $roleGuest = new Zend_Acl_Role('guest');
  110. $this->_acl->addRole($roleGuest)
  111. ->removeRoleAll();
  112. $this->assertFalse($this->_acl->hasRole($roleGuest));
  113. }
  114. /**
  115. * Ensures that an exception is thrown when a non-existent Role is specified as a parent upon Role addition
  116. *
  117. * @return void
  118. */
  119. public function testRoleRegistryAddInheritsNonExistent()
  120. {
  121. try {
  122. $this->_acl->addRole(new Zend_Acl_Role('guest'), 'nonexistent');
  123. $this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon specifying a non-existent parent');
  124. } catch (Zend_Acl_Role_Registry_Exception $e) {
  125. $this->assertContains('does not exist', $e->getMessage());
  126. }
  127. }
  128. /**
  129. * Ensures that an exception is thrown when a non-existent Role is specified to each parameter of inherits()
  130. *
  131. * @return void
  132. */
  133. public function testRoleRegistryInheritsNonExistent()
  134. {
  135. $roleGuest = new Zend_Acl_Role('guest');
  136. $this->_acl->addRole($roleGuest);
  137. try {
  138. $this->_acl->inheritsRole('nonexistent', $roleGuest);
  139. $this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon specifying a non-existent child Role');
  140. } catch (Zend_Acl_Role_Registry_Exception $e) {
  141. $this->assertContains('not found', $e->getMessage());
  142. }
  143. try {
  144. $this->_acl->inheritsRole($roleGuest, 'nonexistent');
  145. $this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon specifying a non-existent parent Role');
  146. } catch (Zend_Acl_Role_Registry_Exception $e) {
  147. $this->assertContains('not found', $e->getMessage());
  148. }
  149. }
  150. /**
  151. * Tests basic Role inheritance
  152. *
  153. * @return void
  154. */
  155. public function testRoleRegistryInherits()
  156. {
  157. $roleGuest = new Zend_Acl_Role('guest');
  158. $roleMember = new Zend_Acl_Role('member');
  159. $roleEditor = new Zend_Acl_Role('editor');
  160. $roleRegistry = new Zend_Acl_Role_Registry();
  161. $roleRegistry->add($roleGuest)
  162. ->add($roleMember, $roleGuest->getRoleId())
  163. ->add($roleEditor, $roleMember);
  164. $this->assertTrue(0 === count($roleRegistry->getParents($roleGuest)));
  165. $roleMemberParents = $roleRegistry->getParents($roleMember);
  166. $this->assertTrue(1 === count($roleMemberParents));
  167. $this->assertTrue(isset($roleMemberParents['guest']));
  168. $roleEditorParents = $roleRegistry->getParents($roleEditor);
  169. $this->assertTrue(1 === count($roleEditorParents));
  170. $this->assertTrue(isset($roleEditorParents['member']));
  171. $this->assertTrue($roleRegistry->inherits($roleMember, $roleGuest, true));
  172. $this->assertTrue($roleRegistry->inherits($roleEditor, $roleMember, true));
  173. $this->assertTrue($roleRegistry->inherits($roleEditor, $roleGuest));
  174. $this->assertFalse($roleRegistry->inherits($roleGuest, $roleMember));
  175. $this->assertFalse($roleRegistry->inherits($roleMember, $roleEditor));
  176. $this->assertFalse($roleRegistry->inherits($roleGuest, $roleEditor));
  177. $roleRegistry->remove($roleMember);
  178. $this->assertTrue(0 === count($roleRegistry->getParents($roleEditor)));
  179. $this->assertFalse($roleRegistry->inherits($roleEditor, $roleGuest));
  180. }
  181. /**
  182. * Tests basic Role multiple inheritance
  183. *
  184. * @return void
  185. */
  186. public function testRoleRegistryInheritsMultiple()
  187. {
  188. $roleParent1 = new Zend_Acl_Role('parent1');
  189. $roleParent2 = new Zend_Acl_Role('parent2');
  190. $roleChild = new Zend_Acl_Role('child');
  191. $roleRegistry = new Zend_Acl_Role_Registry();
  192. $roleRegistry->add($roleParent1)
  193. ->add($roleParent2)
  194. ->add($roleChild, array($roleParent1, $roleParent2));
  195. $roleChildParents = $roleRegistry->getParents($roleChild);
  196. $this->assertTrue(2 === count($roleChildParents));
  197. $i = 1;
  198. foreach ($roleChildParents as $roleParentId => $roleParent) {
  199. $this->assertTrue("parent$i" === $roleParentId);
  200. $i++;
  201. }
  202. $this->assertTrue($roleRegistry->inherits($roleChild, $roleParent1));
  203. $this->assertTrue($roleRegistry->inherits($roleChild, $roleParent2));
  204. $roleRegistry->remove($roleParent1);
  205. $roleChildParents = $roleRegistry->getParents($roleChild);
  206. $this->assertTrue(1 === count($roleChildParents));
  207. $this->assertTrue(isset($roleChildParents['parent2']));
  208. $this->assertTrue($roleRegistry->inherits($roleChild, $roleParent2));
  209. }
  210. /**
  211. * Ensures that the same Role cannot be registered more than once to the registry
  212. *
  213. * @return void
  214. */
  215. public function testRoleRegistryDuplicate()
  216. {
  217. $roleGuest = new Zend_Acl_Role('guest');
  218. $roleRegistry = new Zend_Acl_Role_Registry();
  219. try {
  220. $roleRegistry->add($roleGuest)
  221. ->add($roleGuest);
  222. $this->fail('Expected exception not thrown upon adding same Role twice');
  223. } catch (Zend_Acl_Role_Registry_Exception $e) {
  224. $this->assertContains('already exists', $e->getMessage());
  225. }
  226. }
  227. /**
  228. * Ensures that two Roles having the same ID cannot be registered
  229. *
  230. * @return void
  231. */
  232. public function testRoleRegistryDuplicateId()
  233. {
  234. $roleGuest1 = new Zend_Acl_Role('guest');
  235. $roleGuest2 = new Zend_Acl_Role('guest');
  236. $roleRegistry = new Zend_Acl_Role_Registry();
  237. try {
  238. $roleRegistry->add($roleGuest1)
  239. ->add($roleGuest2);
  240. $this->fail('Expected exception not thrown upon adding two Roles with same ID');
  241. } catch (Zend_Acl_Role_Registry_Exception $e) {
  242. $this->assertContains('already exists', $e->getMessage());
  243. }
  244. }
  245. /**
  246. * Ensures that basic addition and retrieval of a single Resource works
  247. *
  248. * @return void
  249. */
  250. public function testResourceAddAndGetOne()
  251. {
  252. $resourceArea = new Zend_Acl_Resource('area');
  253. $resource = $this->_acl->add($resourceArea)
  254. ->get($resourceArea->getResourceId());
  255. $this->assertTrue($resourceArea === $resource);
  256. $resource = $this->_acl->get($resourceArea);
  257. $this->assertTrue($resourceArea === $resource);
  258. }
  259. /**
  260. * Ensures that basic removal of a single Resource works
  261. *
  262. * @return void
  263. */
  264. public function testResourceRemoveOne()
  265. {
  266. $resourceArea = new Zend_Acl_Resource('area');
  267. $this->_acl->add($resourceArea)
  268. ->remove($resourceArea);
  269. $this->assertFalse($this->_acl->has($resourceArea));
  270. }
  271. /**
  272. * Ensures that an exception is thrown when a non-existent Resource is specified for removal
  273. *
  274. * @return void
  275. */
  276. public function testResourceRemoveOneNonExistent()
  277. {
  278. try {
  279. $this->_acl->remove('nonexistent');
  280. $this->fail('Expected Zend_Acl_Exception not thrown upon removing a non-existent Resource');
  281. } catch (Zend_Acl_Exception $e) {
  282. $this->assertContains('not found', $e->getMessage());
  283. }
  284. }
  285. /**
  286. * Ensures that removal of all Resources works
  287. *
  288. * @return void
  289. */
  290. public function testResourceRemoveAll()
  291. {
  292. $resourceArea = new Zend_Acl_Resource('area');
  293. $this->_acl->add($resourceArea)
  294. ->removeAll();
  295. $this->assertFalse($this->_acl->has($resourceArea));
  296. }
  297. /**
  298. * Ensures that an exception is thrown when a non-existent Resource is specified as a parent upon Resource addition
  299. *
  300. * @return void
  301. */
  302. public function testResourceAddInheritsNonExistent()
  303. {
  304. try {
  305. $this->_acl->add(new Zend_Acl_Resource('area'), 'nonexistent');
  306. $this->fail('Expected Zend_Acl_Exception not thrown upon specifying a non-existent parent');
  307. } catch (Zend_Acl_Exception $e) {
  308. $this->assertContains('does not exist', $e->getMessage());
  309. }
  310. }
  311. /**
  312. * Ensures that an exception is thrown when a non-existent Resource is specified to each parameter of inherits()
  313. *
  314. * @return void
  315. */
  316. public function testResourceInheritsNonExistent()
  317. {
  318. $resourceArea = new Zend_Acl_Resource('area');
  319. $this->_acl->add($resourceArea);
  320. try {
  321. $this->_acl->inherits('nonexistent', $resourceArea);
  322. $this->fail('Expected Zend_Acl_Exception not thrown upon specifying a non-existent child Resource');
  323. } catch (Zend_Acl_Exception $e) {
  324. $this->assertContains('not found', $e->getMessage());
  325. }
  326. try {
  327. $this->_acl->inherits($resourceArea, 'nonexistent');
  328. $this->fail('Expected Zend_Acl_Exception not thrown upon specifying a non-existent parent Resource');
  329. } catch (Zend_Acl_Exception $e) {
  330. $this->assertContains('not found', $e->getMessage());
  331. }
  332. }
  333. /**
  334. * Tests basic Resource inheritance
  335. *
  336. * @return void
  337. */
  338. public function testResourceInherits()
  339. {
  340. $resourceCity = new Zend_Acl_Resource('city');
  341. $resourceBuilding = new Zend_Acl_Resource('building');
  342. $resourceRoom = new Zend_Acl_Resource('room');
  343. $this->_acl->add($resourceCity)
  344. ->add($resourceBuilding, $resourceCity->getResourceId())
  345. ->add($resourceRoom, $resourceBuilding);
  346. $this->assertTrue($this->_acl->inherits($resourceBuilding, $resourceCity, true));
  347. $this->assertTrue($this->_acl->inherits($resourceRoom, $resourceBuilding, true));
  348. $this->assertTrue($this->_acl->inherits($resourceRoom, $resourceCity));
  349. $this->assertFalse($this->_acl->inherits($resourceCity, $resourceBuilding));
  350. $this->assertFalse($this->_acl->inherits($resourceBuilding, $resourceRoom));
  351. $this->assertFalse($this->_acl->inherits($resourceCity, $resourceRoom));
  352. $this->_acl->remove($resourceBuilding);
  353. $this->assertFalse($this->_acl->has($resourceRoom));
  354. }
  355. /**
  356. * Ensures that the same Resource cannot be added more than once
  357. *
  358. * @return void
  359. */
  360. public function testResourceDuplicate()
  361. {
  362. try {
  363. $resourceArea = new Zend_Acl_Resource('area');
  364. $this->_acl->add($resourceArea)
  365. ->add($resourceArea);
  366. $this->fail('Expected exception not thrown upon adding same Resource twice');
  367. } catch (Zend_Acl_Exception $e) {
  368. $this->assertContains('already exists', $e->getMessage());
  369. }
  370. }
  371. /**
  372. * Ensures that two Resources having the same ID cannot be added
  373. *
  374. * @return void
  375. */
  376. public function testResourceDuplicateId()
  377. {
  378. try {
  379. $resourceArea1 = new Zend_Acl_Resource('area');
  380. $resourceArea2 = new Zend_Acl_Resource('area');
  381. $this->_acl->add($resourceArea1)
  382. ->add($resourceArea2);
  383. $this->fail('Expected exception not thrown upon adding two Resources with same ID');
  384. } catch (Zend_Acl_Exception $e) {
  385. $this->assertContains('already exists', $e->getMessage());
  386. }
  387. }
  388. /**
  389. * Ensures that an exception is thrown when a non-existent Role and Resource parameters are specified to isAllowed()
  390. *
  391. * @return void
  392. */
  393. public function testIsAllowedNonExistent()
  394. {
  395. try {
  396. $this->_acl->isAllowed('nonexistent');
  397. $this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon non-existent Role');
  398. } catch (Zend_Acl_Role_Registry_Exception $e) {
  399. $this->assertContains('not found', $e->getMessage());
  400. }
  401. try {
  402. $this->_acl->isAllowed(null, 'nonexistent');
  403. $this->fail('Expected Zend_Acl_Exception not thrown upon non-existent Resource');
  404. } catch (Zend_Acl_Exception $e) {
  405. $this->assertContains('not found', $e->getMessage());
  406. }
  407. }
  408. /**
  409. * Ensures that by default, Zend_Acl denies access to everything by all
  410. *
  411. * @return void
  412. */
  413. public function testDefaultDeny()
  414. {
  415. $this->assertFalse($this->_acl->isAllowed());
  416. }
  417. /**
  418. * Ensures that the default rule obeys its assertion
  419. *
  420. * @return void
  421. */
  422. public function testDefaultAssert()
  423. {
  424. $this->_acl->deny(null, null, null, new Zend_AclTest_AssertFalse());
  425. $this->assertTrue($this->_acl->isAllowed());
  426. $this->assertTrue($this->_acl->isAllowed(null, null, 'somePrivilege'));
  427. }
  428. /**
  429. * Ensures that ACL-wide rules (all Roles, Resources, and privileges) work properly
  430. *
  431. * @return void
  432. */
  433. public function testDefaultRuleSet()
  434. {
  435. $this->_acl->allow();
  436. $this->assertTrue($this->_acl->isAllowed());
  437. $this->_acl->deny();
  438. $this->assertFalse($this->_acl->isAllowed());
  439. }
  440. /**
  441. * Ensures that by default, Zend_Acl denies access to a privilege on anything by all
  442. *
  443. * @return void
  444. */
  445. public function testDefaultPrivilegeDeny()
  446. {
  447. $this->assertFalse($this->_acl->isAllowed(null, null, 'somePrivilege'));
  448. }
  449. /**
  450. * Ensures that ACL-wide rules apply to privileges
  451. *
  452. * @return void
  453. */
  454. public function testDefaultRuleSetPrivilege()
  455. {
  456. $this->_acl->allow();
  457. $this->assertTrue($this->_acl->isAllowed(null, null, 'somePrivilege'));
  458. $this->_acl->deny();
  459. $this->assertFalse($this->_acl->isAllowed(null, null, 'somePrivilege'));
  460. }
  461. /**
  462. * Ensures that a privilege allowed for all Roles upon all Resources works properly
  463. *
  464. * @return void
  465. */
  466. public function testPrivilegeAllow()
  467. {
  468. $this->_acl->allow(null, null, 'somePrivilege');
  469. $this->assertTrue($this->_acl->isAllowed(null, null, 'somePrivilege'));
  470. }
  471. /**
  472. * Ensures that a privilege denied for all Roles upon all Resources works properly
  473. *
  474. * @return void
  475. */
  476. public function testPrivilegeDeny()
  477. {
  478. $this->_acl->allow();
  479. $this->_acl->deny(null, null, 'somePrivilege');
  480. $this->assertFalse($this->_acl->isAllowed(null, null, 'somePrivilege'));
  481. }
  482. /**
  483. * Ensures that multiple privileges work properly
  484. *
  485. * @return void
  486. */
  487. public function testPrivileges()
  488. {
  489. $this->_acl->allow(null, null, array('p1', 'p2', 'p3'));
  490. $this->assertTrue($this->_acl->isAllowed(null, null, 'p1'));
  491. $this->assertTrue($this->_acl->isAllowed(null, null, 'p2'));
  492. $this->assertTrue($this->_acl->isAllowed(null, null, 'p3'));
  493. $this->assertFalse($this->_acl->isAllowed(null, null, 'p4'));
  494. $this->_acl->deny(null, null, 'p1');
  495. $this->assertFalse($this->_acl->isAllowed(null, null, 'p1'));
  496. $this->_acl->deny(null, null, array('p2', 'p3'));
  497. $this->assertFalse($this->_acl->isAllowed(null, null, 'p2'));
  498. $this->assertFalse($this->_acl->isAllowed(null, null, 'p3'));
  499. }
  500. /**
  501. * Ensures that assertions on privileges work properly
  502. *
  503. * @return void
  504. */
  505. public function testPrivilegeAssert()
  506. {
  507. $this->_acl->allow(null, null, 'somePrivilege', new Zend_AclTest_AssertTrue());
  508. $this->assertTrue($this->_acl->isAllowed(null, null, 'somePrivilege'));
  509. $this->_acl->allow(null, null, 'somePrivilege', new Zend_AclTest_AssertFalse());
  510. $this->assertFalse($this->_acl->isAllowed(null, null, 'somePrivilege'));
  511. }
  512. /**
  513. * Ensures that by default, Zend_Acl denies access to everything for a particular Role
  514. *
  515. * @return void
  516. */
  517. public function testRoleDefaultDeny()
  518. {
  519. $roleGuest = new Zend_Acl_Role('guest');
  520. $this->_acl->addRole($roleGuest);
  521. $this->assertFalse($this->_acl->isAllowed($roleGuest));
  522. }
  523. /**
  524. * Ensures that ACL-wide rules (all Resources and privileges) work properly for a particular Role
  525. *
  526. * @return void
  527. */
  528. public function testRoleDefaultRuleSet()
  529. {
  530. $roleGuest = new Zend_Acl_Role('guest');
  531. $this->_acl->addRole($roleGuest)
  532. ->allow($roleGuest);
  533. $this->assertTrue($this->_acl->isAllowed($roleGuest));
  534. $this->_acl->deny($roleGuest);
  535. $this->assertFalse($this->_acl->isAllowed($roleGuest));
  536. }
  537. /**
  538. * Ensures that by default, Zend_Acl denies access to a privilege on anything for a particular Role
  539. *
  540. * @return void
  541. */
  542. public function testRoleDefaultPrivilegeDeny()
  543. {
  544. $roleGuest = new Zend_Acl_Role('guest');
  545. $this->_acl->addRole($roleGuest);
  546. $this->assertFalse($this->_acl->isAllowed($roleGuest, null, 'somePrivilege'));
  547. }
  548. /**
  549. * Ensures that ACL-wide rules apply to privileges for a particular Role
  550. *
  551. * @return void
  552. */
  553. public function testRoleDefaultRuleSetPrivilege()
  554. {
  555. $roleGuest = new Zend_Acl_Role('guest');
  556. $this->_acl->addRole($roleGuest)
  557. ->allow($roleGuest);
  558. $this->assertTrue($this->_acl->isAllowed($roleGuest, null, 'somePrivilege'));
  559. $this->_acl->deny($roleGuest);
  560. $this->assertFalse($this->_acl->isAllowed($roleGuest, null, 'somePrivilege'));
  561. }
  562. /**
  563. * Ensures that a privilege allowed for a particular Role upon all Resources works properly
  564. *
  565. * @return void
  566. */
  567. public function testRolePrivilegeAllow()
  568. {
  569. $roleGuest = new Zend_Acl_Role('guest');
  570. $this->_acl->addRole($roleGuest)
  571. ->allow($roleGuest, null, 'somePrivilege');
  572. $this->assertTrue($this->_acl->isAllowed($roleGuest, null, 'somePrivilege'));
  573. }
  574. /**
  575. * Ensures that a privilege denied for a particular Role upon all Resources works properly
  576. *
  577. * @return void
  578. */
  579. public function testRolePrivilegeDeny()
  580. {
  581. $roleGuest = new Zend_Acl_Role('guest');
  582. $this->_acl->addRole($roleGuest)
  583. ->allow($roleGuest)
  584. ->deny($roleGuest, null, 'somePrivilege');
  585. $this->assertFalse($this->_acl->isAllowed($roleGuest, null, 'somePrivilege'));
  586. }
  587. /**
  588. * Ensures that multiple privileges work properly for a particular Role
  589. *
  590. * @return void
  591. */
  592. public function testRolePrivileges()
  593. {
  594. $roleGuest = new Zend_Acl_Role('guest');
  595. $this->_acl->addRole($roleGuest)
  596. ->allow($roleGuest, null, array('p1', 'p2', 'p3'));
  597. $this->assertTrue($this->_acl->isAllowed($roleGuest, null, 'p1'));
  598. $this->assertTrue($this->_acl->isAllowed($roleGuest, null, 'p2'));
  599. $this->assertTrue($this->_acl->isAllowed($roleGuest, null, 'p3'));
  600. $this->assertFalse($this->_acl->isAllowed($roleGuest, null, 'p4'));
  601. $this->_acl->deny($roleGuest, null, 'p1');
  602. $this->assertFalse($this->_acl->isAllowed($roleGuest, null, 'p1'));
  603. $this->_acl->deny($roleGuest, null, array('p2', 'p3'));
  604. $this->assertFalse($this->_acl->isAllowed($roleGuest, null, 'p2'));
  605. $this->assertFalse($this->_acl->isAllowed($roleGuest, null, 'p3'));
  606. }
  607. /**
  608. * Ensures that assertions on privileges work properly for a particular Role
  609. *
  610. * @return void
  611. */
  612. public function testRolePrivilegeAssert()
  613. {
  614. $roleGuest = new Zend_Acl_Role('guest');
  615. $this->_acl->addRole($roleGuest)
  616. ->allow($roleGuest, null, 'somePrivilege', new Zend_AclTest_AssertTrue());
  617. $this->assertTrue($this->_acl->isAllowed($roleGuest, null, 'somePrivilege'));
  618. $this->_acl->allow($roleGuest, null, 'somePrivilege', new Zend_AclTest_AssertFalse());
  619. $this->assertFalse($this->_acl->isAllowed($roleGuest, null, 'somePrivilege'));
  620. }
  621. /**
  622. * Ensures that removing the default deny rule results in default deny rule
  623. *
  624. * @return void
  625. */
  626. public function testRemoveDefaultDeny()
  627. {
  628. $this->assertFalse($this->_acl->isAllowed());
  629. $this->_acl->removeDeny();
  630. $this->assertFalse($this->_acl->isAllowed());
  631. }
  632. /**
  633. * Ensures that removing the default deny rule results in assertion method being removed
  634. *
  635. * @return void
  636. */
  637. public function testRemoveDefaultDenyAssert()
  638. {
  639. $this->_acl->deny(null, null, null, new Zend_AclTest_AssertFalse());
  640. $this->assertTrue($this->_acl->isAllowed());
  641. $this->_acl->removeDeny();
  642. $this->assertFalse($this->_acl->isAllowed());
  643. }
  644. /**
  645. * Ensures that removing the default allow rule results in default deny rule being assigned
  646. *
  647. * @return void
  648. */
  649. public function testRemoveDefaultAllow()
  650. {
  651. $this->_acl->allow();
  652. $this->assertTrue($this->_acl->isAllowed());
  653. $this->_acl->removeAllow();
  654. $this->assertFalse($this->_acl->isAllowed());
  655. }
  656. /**
  657. * Ensures that removing non-existent default allow rule does nothing
  658. *
  659. * @return void
  660. */
  661. public function testRemoveDefaultAllowNonExistent()
  662. {
  663. $this->_acl->removeAllow();
  664. $this->assertFalse($this->_acl->isAllowed());
  665. }
  666. /**
  667. * Ensures that removing non-existent default deny rule does nothing
  668. *
  669. * @return void
  670. */
  671. public function testRemoveDefaultDenyNonExistent()
  672. {
  673. $this->_acl->allow()
  674. ->removeDeny();
  675. $this->assertTrue($this->_acl->isAllowed());
  676. }
  677. /**
  678. * Ensures that for a particular Role, a deny rule on a specific Resource is honored before an allow rule
  679. * on the entire ACL
  680. *
  681. * @return void
  682. */
  683. public function testRoleDefaultAllowRuleWithResourceDenyRule()
  684. {
  685. $this->_acl->addRole(new Zend_Acl_Role('guest'))
  686. ->addRole(new Zend_Acl_Role('staff'), 'guest')
  687. ->add(new Zend_Acl_Resource('area1'))
  688. ->add(new Zend_Acl_Resource('area2'))
  689. ->deny()
  690. ->allow('staff')
  691. ->deny('staff', array('area1', 'area2'));
  692. $this->assertFalse($this->_acl->isAllowed('staff', 'area1'));
  693. }
  694. /**
  695. * Ensures that for a particular Role, a deny rule on a specific privilege is honored before an allow
  696. * rule on the entire ACL
  697. *
  698. * @return void
  699. */
  700. public function testRoleDefaultAllowRuleWithPrivilegeDenyRule()
  701. {
  702. $this->_acl->addRole(new Zend_Acl_Role('guest'))
  703. ->addRole(new Zend_Acl_Role('staff'), 'guest')
  704. ->deny()
  705. ->allow('staff')
  706. ->deny('staff', null, array('privilege1', 'privilege2'));
  707. $this->assertFalse($this->_acl->isAllowed('staff', null, 'privilege1'));
  708. }
  709. /**
  710. * Ensure that basic rule removal works
  711. *
  712. * @return void
  713. */
  714. public function testRulesRemove()
  715. {
  716. $this->_acl->allow(null, null, array('privilege1', 'privilege2'));
  717. $this->assertFalse($this->_acl->isAllowed());
  718. $this->assertTrue($this->_acl->isAllowed(null, null, 'privilege1'));
  719. $this->assertTrue($this->_acl->isAllowed(null, null, 'privilege2'));
  720. $this->_acl->removeAllow(null, null, 'privilege1');
  721. $this->assertFalse($this->_acl->isAllowed(null, null, 'privilege1'));
  722. $this->assertTrue($this->_acl->isAllowed(null, null, 'privilege2'));
  723. }
  724. /**
  725. * Ensures that removal of a Role results in its rules being removed
  726. *
  727. * @return void
  728. */
  729. public function testRuleRoleRemove()
  730. {
  731. $this->_acl->addRole(new Zend_Acl_Role('guest'))
  732. ->allow('guest');
  733. $this->assertTrue($this->_acl->isAllowed('guest'));
  734. $this->_acl->removeRole('guest');
  735. try {
  736. $this->_acl->isAllowed('guest');
  737. $this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon isAllowed() on non-existent Role');
  738. } catch (Zend_Acl_Role_Registry_Exception $e) {
  739. $this->assertContains('not found', $e->getMessage());
  740. }
  741. $this->_acl->addRole(new Zend_Acl_Role('guest'));
  742. $this->assertFalse($this->_acl->isAllowed('guest'));
  743. }
  744. /**
  745. * Ensures that removal of all Roles results in Role-specific rules being removed
  746. *
  747. * @return void
  748. */
  749. public function testRuleRoleRemoveAll()
  750. {
  751. $this->_acl->addRole(new Zend_Acl_Role('guest'))
  752. ->allow('guest');
  753. $this->assertTrue($this->_acl->isAllowed('guest'));
  754. $this->_acl->removeRoleAll();
  755. try {
  756. $this->_acl->isAllowed('guest');
  757. $this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon isAllowed() on non-existent Role');
  758. } catch (Zend_Acl_Role_Registry_Exception $e) {
  759. $this->assertContains('not found', $e->getMessage());
  760. }
  761. $this->_acl->addRole(new Zend_Acl_Role('guest'));
  762. $this->assertFalse($this->_acl->isAllowed('guest'));
  763. }
  764. /**
  765. * Ensures that removal of a Resource results in its rules being removed
  766. *
  767. * @return void
  768. */
  769. public function testRulesResourceRemove()
  770. {
  771. $this->_acl->add(new Zend_Acl_Resource('area'))
  772. ->allow(null, 'area');
  773. $this->assertTrue($this->_acl->isAllowed(null, 'area'));
  774. $this->_acl->remove('area');
  775. try {
  776. $this->_acl->isAllowed(null, 'area');
  777. $this->fail('Expected Zend_Acl_Exception not thrown upon isAllowed() on non-existent Resource');
  778. } catch (Zend_Acl_Exception $e) {
  779. $this->assertContains('not found', $e->getMessage());
  780. }
  781. $this->_acl->add(new Zend_Acl_Resource('area'));
  782. $this->assertFalse($this->_acl->isAllowed(null, 'area'));
  783. }
  784. /**
  785. * Ensures that removal of all Resources results in Resource-specific rules being removed
  786. *
  787. * @return void
  788. */
  789. public function testRulesResourceRemoveAll()
  790. {
  791. $this->_acl->add(new Zend_Acl_Resource('area'))
  792. ->allow(null, 'area');
  793. $this->assertTrue($this->_acl->isAllowed(null, 'area'));
  794. $this->_acl->removeAll();
  795. try {
  796. $this->_acl->isAllowed(null, 'area');
  797. $this->fail('Expected Zend_Acl_Exception not thrown upon isAllowed() on non-existent Resource');
  798. } catch (Zend_Acl_Exception $e) {
  799. $this->assertContains('not found', $e->getMessage());
  800. }
  801. $this->_acl->add(new Zend_Acl_Resource('area'));
  802. $this->assertFalse($this->_acl->isAllowed(null, 'area'));
  803. }
  804. /**
  805. * Ensures that an example for a content management system is operable
  806. *
  807. * @return void
  808. */
  809. public function testCMSExample()
  810. {
  811. // Add some roles to the Role registry
  812. $this->_acl->addRole(new Zend_Acl_Role('guest'))
  813. ->addRole(new Zend_Acl_Role('staff'), 'guest') // staff inherits permissions from guest
  814. ->addRole(new Zend_Acl_Role('editor'), 'staff') // editor inherits permissions from staff
  815. ->addRole(new Zend_Acl_Role('administrator'));
  816. // Guest may only view content
  817. $this->_acl->allow('guest', null, 'view');
  818. // Staff inherits view privilege from guest, but also needs additional privileges
  819. $this->_acl->allow('staff', null, array('edit', 'submit', 'revise'));
  820. // Editor inherits view, edit, submit, and revise privileges, but also needs additional privileges
  821. $this->_acl->allow('editor', null, array('publish', 'archive', 'delete'));
  822. // Administrator inherits nothing but is allowed all privileges
  823. $this->_acl->allow('administrator');
  824. // Access control checks based on above permission sets
  825. $this->assertTrue($this->_acl->isAllowed('guest', null, 'view'));
  826. $this->assertFalse($this->_acl->isAllowed('guest', null, 'edit'));
  827. $this->assertFalse($this->_acl->isAllowed('guest', null, 'submit'));
  828. $this->assertFalse($this->_acl->isAllowed('guest', null, 'revise'));
  829. $this->assertFalse($this->_acl->isAllowed('guest', null, 'publish'));
  830. $this->assertFalse($this->_acl->isAllowed('guest', null, 'archive'));
  831. $this->assertFalse($this->_acl->isAllowed('guest', null, 'delete'));
  832. $this->assertFalse($this->_acl->isAllowed('guest', null, 'unknown'));
  833. $this->assertFalse($this->_acl->isAllowed('guest'));
  834. $this->assertTrue($this->_acl->isAllowed('staff', null, 'view'));
  835. $this->assertTrue($this->_acl->isAllowed('staff', null, 'edit'));
  836. $this->assertTrue($this->_acl->isAllowed('staff', null, 'submit'));
  837. $this->assertTrue($this->_acl->isAllowed('staff', null, 'revise'));
  838. $this->assertFalse($this->_acl->isAllowed('staff', null, 'publish'));
  839. $this->assertFalse($this->_acl->isAllowed('staff', null, 'archive'));
  840. $this->assertFalse($this->_acl->isAllowed('staff', null, 'delete'));
  841. $this->assertFalse($this->_acl->isAllowed('staff', null, 'unknown'));
  842. $this->assertFalse($this->_acl->isAllowed('staff'));
  843. $this->assertTrue($this->_acl->isAllowed('editor', null, 'view'));
  844. $this->assertTrue($this->_acl->isAllowed('editor', null, 'edit'));
  845. $this->assertTrue($this->_acl->isAllowed('editor', null, 'submit'));
  846. $this->assertTrue($this->_acl->isAllowed('editor', null, 'revise'));
  847. $this->assertTrue($this->_acl->isAllowed('editor', null, 'publish'));
  848. $this->assertTrue($this->_acl->isAllowed('editor', null, 'archive'));
  849. $this->assertTrue($this->_acl->isAllowed('editor', null, 'delete'));
  850. $this->assertFalse($this->_acl->isAllowed('editor', null, 'unknown'));
  851. $this->assertFalse($this->_acl->isAllowed('editor'));
  852. $this->assertTrue($this->_acl->isAllowed('administrator', null, 'view'));
  853. $this->assertTrue($this->_acl->isAllowed('administrator', null, 'edit'));
  854. $this->assertTrue($this->_acl->isAllowed('administrator', null, 'submit'));
  855. $this->assertTrue($this->_acl->isAllowed('administrator', null, 'revise'));
  856. $this->assertTrue($this->_acl->isAllowed('administrator', null, 'publish'));
  857. $this->assertTrue($this->_acl->isAllowed('administrator', null, 'archive'));
  858. $this->assertTrue($this->_acl->isAllowed('administrator', null, 'delete'));
  859. $this->assertTrue($this->_acl->isAllowed('administrator', null, 'unknown'));
  860. $this->assertTrue($this->_acl->isAllowed('administrator'));
  861. // Some checks on specific areas, which inherit access controls from the root ACL node
  862. $this->_acl->add(new Zend_Acl_Resource('newsletter'))
  863. ->add(new Zend_Acl_Resource('pending'), 'newsletter')
  864. ->add(new Zend_Acl_Resource('gallery'))
  865. ->add(new Zend_Acl_Resource('profiles', 'gallery'))
  866. ->add(new Zend_Acl_Resource('config'))
  867. ->add(new Zend_Acl_Resource('hosts'), 'config');
  868. $this->assertTrue($this->_acl->isAllowed('guest', 'pending', 'view'));
  869. $this->assertTrue($this->_acl->isAllowed('staff', 'profiles', 'revise'));
  870. $this->assertTrue($this->_acl->isAllowed('staff', 'pending', 'view'));
  871. $this->assertTrue($this->_acl->isAllowed('staff', 'pending', 'edit'));
  872. $this->assertFalse($this->_acl->isAllowed('staff', 'pending', 'publish'));
  873. $this->assertFalse($this->_acl->isAllowed('staff', 'pending'));
  874. $this->assertFalse($this->_acl->isAllowed('editor', 'hosts', 'unknown'));
  875. $this->assertTrue($this->_acl->isAllowed('administrator', 'pending'));
  876. // Add a new group, marketing, which bases its permissions on staff
  877. $this->_acl->addRole(new Zend_Acl_Role('marketing'), 'staff');
  878. // Refine the privilege sets for more specific needs
  879. // Allow marketing to publish and archive newsletters
  880. $this->_acl->allow('marketing', 'newsletter', array('publish', 'archive'));
  881. // Allow marketing to publish and archive latest news
  882. $this->_acl->add(new Zend_Acl_Resource('news'))
  883. ->add(new Zend_Acl_Resource('latest'), 'news');
  884. $this->_acl->allow('marketing', 'latest', array('publish', 'archive'));
  885. // Deny staff (and marketing, by inheritance) rights to revise latest news
  886. $this->_acl->deny('staff', 'latest', 'revise');
  887. // Deny everyone access to archive news announcements
  888. $this->_acl->add(new Zend_Acl_Resource('announcement'), 'news');
  889. $this->_acl->deny(null, 'announcement', 'archive');
  890. // Access control checks for the above refined permission sets
  891. $this->assertTrue($this->_acl->isAllowed('marketing', null, 'view'));
  892. $this->assertTrue($this->_acl->isAllowed('marketing', null, 'edit'));
  893. $this->assertTrue($this->_acl->isAllowed('marketing', null, 'submit'));
  894. $this->assertTrue($this->_acl->isAllowed('marketing', null, 'revise'));
  895. $this->assertFalse($this->_acl->isAllowed('marketing', null, 'publish'));
  896. $this->assertFalse($this->_acl->isAllowed('marketing', null, 'archive'));
  897. $this->assertFalse($this->_acl->isAllowed('marketing', null, 'delete'));
  898. $this->assertFalse($this->_acl->isAllowed('marketing', null, 'unknown'));
  899. $this->assertFalse($this->_acl->isAllowed('marketing'));
  900. $this->assertTrue($this->_acl->isAllowed('marketing', 'newsletter', 'publish'));
  901. $this->assertFalse($this->_acl->isAllowed('staff', 'pending', 'publish'));
  902. $this->assertTrue($this->_acl->isAllowed('marketing', 'pending', 'publish'));
  903. $this->assertTrue($this->_acl->isAllowed('marketing', 'newsletter', 'archive'));
  904. $this->assertFalse($this->_acl->isAllowed('marketing', 'newsletter', 'delete'));
  905. $this->assertFalse($this->_acl->isAllowed('marketing', 'newsletter'));
  906. $this->assertTrue($this->_acl->isAllowed('marketing', 'latest', 'publish'));
  907. $this->assertTrue($this->_acl->isAllowed('marketing', 'latest', 'archive'));
  908. $this->assertFalse($this->_acl->isAllowed('marketing', 'latest', 'delete'));
  909. $this->assertFalse($this->_acl->isAllowed('marketing', 'latest', 'revise'));
  910. $this->assertFalse($this->_acl->isAllowed('marketing', 'latest'));
  911. $this->assertFalse($this->_acl->isAllowed('marketing', 'announcement', 'archive'));
  912. $this->assertFalse($this->_acl->isAllowed('staff', 'announcement', 'archive'));
  913. $this->assertFalse($this->_acl->isAllowed('administrator', 'announcement', 'archive'));
  914. $this->assertFalse($this->_acl->isAllowed('staff', 'latest', 'publish'));
  915. $this->assertFalse($this->_acl->isAllowed('editor', 'announcement', 'archive'));
  916. // Remove some previous permission specifications
  917. // Marketing can no longer publish and archive newsletters
  918. $this->_acl->removeAllow('marketing', 'newsletter', array('publish', 'archive'));
  919. // Marketing can no longer archive the latest news
  920. $this->_acl->removeAllow('marketing', 'latest', 'archive');
  921. // Now staff (and marketing, by inheritance) may revise latest news
  922. $this->_acl->removeDeny('staff', 'latest', 'revise');
  923. // Access control checks for the above refinements
  924. $this->assertFalse($this->_acl->isAllowed('marketing', 'newsletter', 'publish'));
  925. $this->assertFalse($this->_acl->isAllowed('marketing', 'newsletter', 'archive'));
  926. $this->assertFalse($this->_acl->isAllowed('marketing', 'latest', 'archive'));
  927. $this->assertTrue($this->_acl->isAllowed('staff', 'latest', 'revise'));
  928. $this->assertTrue($this->_acl->isAllowed('marketing', 'latest', 'revise'));
  929. // Grant marketing all permissions on the latest news
  930. $this->_acl->allow('marketing', 'latest');
  931. // Access control checks for the above refinement
  932. $this->assertTrue($this->_acl->isAllowed('marketing', 'latest', 'archive'));
  933. $this->assertTrue($this->_acl->isAllowed('marketing', 'latest', 'publish'));
  934. $this->assertTrue($this->_acl->isAllowed('marketing', 'latest', 'edit'));
  935. $this->assertTrue($this->_acl->isAllowed('marketing', 'latest'));
  936. }
  937. /**
  938. * Ensures that the $onlyParents argument to inheritsRole() works
  939. *
  940. * @return void
  941. * @see http://framework.zend.com/issues/browse/ZF-2502
  942. */
  943. public function testRoleInheritanceSupportsCheckingOnlyParents()
  944. {
  945. $this->_acl->addRole(new Zend_Acl_Role('grandparent'))
  946. ->addRole(new Zend_Acl_Role('parent'), 'grandparent')
  947. ->addRole(new Zend_Acl_Role('child'), 'parent');
  948. $this->assertFalse($this->_acl->inheritsRole('child', 'grandparent', true));
  949. }
  950. /**
  951. * Ensures that the solution for ZF-2234 works as expected
  952. *
  953. * @return void
  954. * @see http://framework.zend.com/issues/browse/ZF-2234
  955. */
  956. public function testZf2234()
  957. {
  958. $acl = new Zend_AclTest_ExtensionForZf2234();
  959. $someResource = new Zend_Acl_Resource('someResource');
  960. $someRole = new Zend_Acl_Role('someRole');
  961. $acl->add($someResource)
  962. ->addRole($someRole);
  963. $nullValue = null;
  964. $nullReference =& $nullValue;
  965. try {
  966. $acl->roleDFSVisitAllPrivileges($someRole, $someResource, $nullReference);
  967. $this->fail('Expected Zend_Acl_Exception not thrown');
  968. } catch (Zend_Acl_Exception $e) {
  969. $this->assertEquals('$dfs parameter may not be null', $e->getMessage());
  970. }
  971. try {
  972. $acl->roleDFSOnePrivilege($someRole, $someResource, null);
  973. $this->fail('Expected Zend_Acl_Exception not thrown');
  974. } catch (Zend_Acl_Exception $e) {
  975. $this->assertEquals('$privilege parameter may not be null', $e->getMessage());
  976. }
  977. try {
  978. $acl->roleDFSVisitOnePrivilege($someRole, $someResource, null);
  979. $this->fail('Expected Zend_Acl_Exception not thrown');
  980. } catch (Zend_Acl_Exception $e) {
  981. $this->assertEquals('$privilege parameter may not be null', $e->getMessage());
  982. }
  983. try {
  984. $acl->roleDFSVisitOnePrivilege($someRole, $someResource, 'somePrivilege', $nullReference);
  985. $this->fail('Expected Zend_Acl_Exception not thrown');
  986. } catch (Zend_Acl_Exception $e) {
  987. $this->assertEquals('$dfs parameter may not be null', $e->getMessage());
  988. }
  989. }
  990. }
  991. class Zend_AclTest_AssertFalse implements Zend_Acl_Assert_Interface
  992. {
  993. public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null,
  994. $privilege = null)
  995. {
  996. return false;
  997. }
  998. }
  999. class Zend_AclTest_AssertTrue implements Zend_Acl_Assert_Interface
  1000. {
  1001. public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null,
  1002. $privilege = null)
  1003. {
  1004. return true;
  1005. }
  1006. }
  1007. class Zend_AclTest_ExtensionForZf2234 extends Zend_Acl
  1008. {
  1009. public function roleDFSVisitAllPrivileges(Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource = null,
  1010. &$dfs = null)
  1011. {
  1012. return $this->_roleDFSVisitAllPrivileges($role, $resource, $dfs);
  1013. }
  1014. public function roleDFSOnePrivilege(Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource = null,
  1015. $privilege = null)
  1016. {
  1017. return $this->_roleDFSOnePrivilege($role, $resource, $privilege);
  1018. }
  1019. public function roleDFSVisitOnePrivilege(Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource = null,
  1020. $privilege = null, &$dfs = null)
  1021. {
  1022. return $this->_roleDFSVisitOnePrivilege($role, $resource, $privilege, $dfs);
  1023. }
  1024. }