NumberHelperTest.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. * setUp method
  33. */
  34. public function setUp(): void
  35. {
  36. parent::setUp();
  37. $this->View = new View();
  38. static::setAppNamespace();
  39. }
  40. /**
  41. * tearDown method
  42. */
  43. public function tearDown(): void
  44. {
  45. parent::tearDown();
  46. $this->clearPlugins();
  47. unset($this->View);
  48. }
  49. /**
  50. * Provider for method proxying.
  51. *
  52. * @return array
  53. */
  54. public function methodProvider(): array
  55. {
  56. return [
  57. ['precision', 1.23],
  58. ['toReadableSize', 1.23],
  59. ['toPercentage', 1.23],
  60. ];
  61. }
  62. /**
  63. * Tests calls are proxied to Number class.
  64. *
  65. * @dataProvider methodProvider
  66. */
  67. public function testMethodProxying(string $method, mixed $arg): void
  68. {
  69. $helper = new NumberHelper($this->View);
  70. $this->assertNotNull($helper->{$method}($arg));
  71. }
  72. }