NumberHelperTest.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * NumberHelperTest file
  5. *
  6. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  7. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  8. *
  9. * Licensed under The MIT License
  10. * For full copyright and license information, please see the LICENSE.txt
  11. * Redistributions of files must retain the above copyright notice
  12. *
  13. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  14. * @link https://cakephp.org CakePHP(tm) Project
  15. * @since 1.2.0
  16. * @license https://opensource.org/licenses/mit-license.php MIT License
  17. */
  18. namespace Cake\Test\TestCase\View\Helper;
  19. use Cake\TestSuite\TestCase;
  20. use Cake\View\Helper\NumberHelper;
  21. use Cake\View\View;
  22. /**
  23. * NumberHelperTest class
  24. */
  25. class NumberHelperTest extends TestCase
  26. {
  27. /**
  28. * @var \Cake\View\View
  29. */
  30. protected $View;
  31. /**
  32. * @var string
  33. */
  34. protected $appNamespace;
  35. /**
  36. * setUp method
  37. */
  38. public function setUp(): void
  39. {
  40. parent::setUp();
  41. $this->View = new View();
  42. static::setAppNamespace();
  43. }
  44. /**
  45. * tearDown method
  46. */
  47. public function tearDown(): void
  48. {
  49. parent::tearDown();
  50. $this->clearPlugins();
  51. unset($this->View);
  52. }
  53. /**
  54. * Provider for method proxying.
  55. *
  56. * @return array
  57. */
  58. public function methodProvider(): array
  59. {
  60. return [
  61. ['precision', 1.23],
  62. ['toReadableSize', 1.23],
  63. ['toPercentage', 1.23],
  64. ];
  65. }
  66. /**
  67. * Tests calls are proxied to Number class.
  68. *
  69. * @dataProvider methodProvider
  70. */
  71. public function testMethodProxying(string $method, mixed $arg): void
  72. {
  73. $helper = new NumberHelper($this->View);
  74. $this->assertNotNull($helper->{$method}($arg));
  75. }
  76. }