DIContainerTest.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * ownCloud - App Framework
  4. *
  5. * @author Bernhard Posselt
  6. * @author Morris Jobke
  7. * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.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 \Test\TestCase {
  27. private $container;
  28. private $api;
  29. protected function setUp(){
  30. parent::setUp();
  31. $this->container = $this->getMock('OC\AppFramework\DependencyInjection\DIContainer',
  32. ['isAdminUser'], ['name']
  33. );
  34. $this->api = $this->getMock('OC\AppFramework\Core\API', array(), array('hi'));
  35. }
  36. public function testProvidesAPI(){
  37. $this->assertTrue(isset($this->container['API']));
  38. }
  39. public function testProvidesRequest(){
  40. $this->assertTrue(isset($this->container['Request']));
  41. }
  42. public function testProvidesSecurityMiddleware(){
  43. $this->assertTrue(isset($this->container['SecurityMiddleware']));
  44. }
  45. public function testProvidesMiddlewareDispatcher(){
  46. $this->assertTrue(isset($this->container['MiddlewareDispatcher']));
  47. }
  48. public function testProvidesAppName(){
  49. $this->assertTrue(isset($this->container['AppName']));
  50. }
  51. public function testAppNameIsSetCorrectly(){
  52. $this->assertEquals('name', $this->container['AppName']);
  53. }
  54. public function testMiddlewareDispatcherIncludesSecurityMiddleware(){
  55. $this->container['Request'] = new Request(
  56. ['method' => 'GET'],
  57. $this->getMock('\OCP\Security\ISecureRandom'),
  58. $this->getMock('\OCP\IConfig')
  59. );
  60. $security = $this->container['SecurityMiddleware'];
  61. $dispatcher = $this->container['MiddlewareDispatcher'];
  62. $this->assertContains($security, $dispatcher->getMiddlewares());
  63. }
  64. }