DIContainerTest.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * ownCloud - App Framework
  4. *
  5. * @author Bernhard Posselt
  6. * @author Morris Jobke
  7. * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
  8. * @copyright 2013 Morris Jobke morris.jobke@gmail.com
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  12. * License as published by the Free Software Foundation; either
  13. * version 3 of the License, or any later version.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public
  21. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OC\AppFramework\DependencyInjection;
  25. use \OC\AppFramework\Http\Request;
  26. class DIContainerTest extends \PHPUnit_Framework_TestCase {
  27. private $container;
  28. private $api;
  29. protected function setUp(){
  30. $this->container = new DIContainer('name');
  31. $this->api = $this->getMock('OC\AppFramework\Core\API', array(), array('hi'));
  32. }
  33. public function testProvidesAPI(){
  34. $this->assertTrue(isset($this->container['API']));
  35. }
  36. public function testProvidesRequest(){
  37. $this->assertTrue(isset($this->container['Request']));
  38. }
  39. public function testProvidesSecurityMiddleware(){
  40. $this->assertTrue(isset($this->container['SecurityMiddleware']));
  41. }
  42. public function testProvidesMiddlewareDispatcher(){
  43. $this->assertTrue(isset($this->container['MiddlewareDispatcher']));
  44. }
  45. public function testProvidesAppName(){
  46. $this->assertTrue(isset($this->container['AppName']));
  47. }
  48. public function testAppNameIsSetCorrectly(){
  49. $this->assertEquals('name', $this->container['AppName']);
  50. }
  51. public function testMiddlewareDispatcherIncludesSecurityMiddleware(){
  52. $this->container['Request'] = new Request();
  53. $security = $this->container['SecurityMiddleware'];
  54. $dispatcher = $this->container['MiddlewareDispatcher'];
  55. $this->assertContains($security, $dispatcher->getMiddlewares());
  56. }
  57. }