コード例 #1
0
ファイル: pagination_test.php プロジェクト: TupambaeNet/phpbb
	public function setUp()
	{
		parent::setUp();

		global $phpbb_dispatcher, $phpbb_root_path, $phpEx;

		$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
		$this->user = $this->getMock('\phpbb\user', array(), array(
			new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
			'\phpbb\datetime'
		));
		$this->user->expects($this->any())
			->method('lang')
			->will($this->returnCallback(array($this, 'return_callback_implode')));

		$filesystem = new \phpbb\filesystem\filesystem();
		$manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array());

		$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
		$router = new phpbb_mock_router(new phpbb_mock_container_builder(), $filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $manager);
		$router->find_routing_files($manager->all_enabled(false));
		$router->find(dirname(__FILE__) . '/');

		$request = new phpbb_mock_request();
		$request->overwrite('SCRIPT_NAME', '/app.php', \phpbb\request\request_interface::SERVER);
		$request->overwrite('SCRIPT_FILENAME', 'app.php', \phpbb\request\request_interface::SERVER);
		$request->overwrite('REQUEST_URI', '/app.php', \phpbb\request\request_interface::SERVER);

		$symfony_request = new \phpbb\symfony_request(
			$request
		);

		$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $router, $symfony_request, $request, $filesystem, '', 'php', dirname(__FILE__) . '/');
		$this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper, $phpbb_dispatcher);
	}
コード例 #2
0
ファイル: controller_test.php プロジェクト: MrAdder/phpbb
 public function test_router_default_loader()
 {
     $container = new phpbb_mock_container_builder();
     $container->setParameter('core.environment', PHPBB_ENVIRONMENT);
     $loader = new \Symfony\Component\Routing\Loader\YamlFileLoader(new \phpbb\routing\file_locator(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/'));
     $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager);
     $router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
     $routes = $router->get_routes();
     // This will need to be updated if any new routes are defined
     $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $routes->get('core_controller'));
     $this->assertEquals('/core_foo', $routes->get('core_controller')->getPath());
     $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $routes->get('controller1'));
     $this->assertEquals('/foo', $routes->get('controller1')->getPath());
     $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $routes->get('controller2'));
     $this->assertEquals('/foo/bar', $routes->get('controller2')->getPath());
     $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $routes->get('controller3'));
     $this->assertEquals('/bar', $routes->get('controller3')->getPath());
     $this->assertNull($routes->get('controller_noroute'));
 }