FunctionsGlobalTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  5. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  6. *
  7. * Licensed under The MIT License
  8. * For full copyright and license information, please see the LICENSE.txt
  9. * Redistributions of files must retain the above copyright notice
  10. *
  11. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  12. * @link https://cakephp.org CakePHP(tm) Project
  13. * @since 4.5.0
  14. * @license https://opensource.org/licenses/mit-license.php MIT License
  15. */
  16. namespace Cake\Test\TestCase\Routing;
  17. use Cake\Routing\Router;
  18. use Cake\TestSuite\TestCase;
  19. require_once CAKE . 'Routing/functions_global.php';
  20. class FunctionsGlobalTest extends TestCase
  21. {
  22. /**
  23. * Tests that the url() method is a shortcut Router::url()
  24. */
  25. public function testUrl(): void
  26. {
  27. $routes = Router::createRouteBuilder('/');
  28. $routes->fallbacks();
  29. $routerResult = Router::url(['controller' => 'Articles']);
  30. $globalResult = url(['controller' => 'Articles']);
  31. $this->assertSame($routerResult, $globalResult);
  32. }
  33. /**
  34. * Tests that the urlArray() method is a shortcut Router::parseRoutePath()
  35. */
  36. public function testUrlArray(): void
  37. {
  38. $routes = Router::createRouteBuilder('/');
  39. $routes->fallbacks();
  40. $routerResult = Router::parseRoutePath('Controller::articles');
  41. $globalResult = urlArray('Controller::articles');
  42. $this->assertSame($globalResult, $routerResult + ['plugin' => false, 'prefix' => false]);
  43. }
  44. }