FieldNamerTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Reflection\Test\Unit;
  7. use Magento\Framework\Reflection\FieldNamer;
  8. /**
  9. * Field namer Test
  10. */
  11. class FieldNamerTest extends \PHPUnit\Framework\TestCase
  12. {
  13. /**
  14. * @var FieldNamer
  15. */
  16. private $model;
  17. /**
  18. * Set up helper.
  19. */
  20. protected function setUp()
  21. {
  22. $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  23. $this->model = $objectManager->getObject(\Magento\Framework\Reflection\FieldNamer::class);
  24. }
  25. /**
  26. * @param string $methodName
  27. * @param string $expectedName
  28. * @dataProvider methodNameProvider
  29. */
  30. public function testGetFieldNameForMethodName($methodName, $expectedName)
  31. {
  32. $value = $this->model->getFieldNameForMethodName($methodName);
  33. $this->assertEquals($value, $expectedName);
  34. }
  35. /**
  36. * @return array
  37. */
  38. public function methodNameProvider()
  39. {
  40. return [
  41. 'isMethod' => ['isValid', 'valid'],
  42. 'getMethod' => ['getValue', 'value'],
  43. 'hasMethod' => ['hasStuff', 'stuff'],
  44. 'randomMethod' => ['randomMethod', null],
  45. ];
  46. }
  47. }