ValidationTest.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Theme data validation
  8. */
  9. namespace Magento\Theme\Test\Unit\Model\Theme;
  10. class ValidationTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @param array $data
  14. * @param bool $result
  15. * @param array $messages
  16. *
  17. * @covers \Magento\Framework\View\Design\Theme\Validator::validate
  18. * @dataProvider dataProviderValidate
  19. */
  20. public function testValidate(array $data, $result, array $messages)
  21. {
  22. /** @var $themeMock \Magento\Framework\DataObject */
  23. $themeMock = new \Magento\Framework\DataObject();
  24. $themeMock->setData($data);
  25. $validator = new \Magento\Framework\View\Design\Theme\Validator();
  26. $this->assertEquals($result, $validator->validate($themeMock));
  27. $this->assertEquals($messages, $validator->getErrorMessages());
  28. }
  29. /**
  30. * @return array
  31. */
  32. public function dataProviderValidate()
  33. {
  34. return [
  35. [
  36. [
  37. 'theme_code' => 'Magento/iphone',
  38. 'theme_title' => 'Iphone',
  39. 'parent_theme' => ['default', 'default'],
  40. 'theme_path' => 'Magento/iphone',
  41. 'preview_image' => 'images/preview.png',
  42. ],
  43. true,
  44. [],
  45. ],
  46. [
  47. [
  48. 'theme_code' => 'iphone#theme!!!!',
  49. 'theme_title' => '',
  50. 'parent_theme' => ['default', 'default'],
  51. 'theme_path' => 'magento_iphone',
  52. 'preview_image' => 'images/preview.png',
  53. ],
  54. false,
  55. [
  56. 'theme_title' => ['Field title can\'t be empty']
  57. ],
  58. ],
  59. ];
  60. }
  61. }