EnableEavIndexerTest.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\CatalogSearch\Test\Unit\Plugin;
  8. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
  9. /**
  10. * @deprecated
  11. * @see \Magento\ElasticSearch
  12. */
  13. class EnableEavIndexerTest extends \PHPUnit\Framework\TestCase
  14. {
  15. /**
  16. * @var \Magento\CatalogSearch\Plugin\EnableEavIndexer
  17. */
  18. private $model;
  19. /**
  20. * @var \Magento\Config\Model\Config|\PHPUnit_Framework_MockObject_MockObject
  21. */
  22. private $config;
  23. /**
  24. * Set up
  25. *
  26. * @return void
  27. */
  28. protected function setUp()
  29. {
  30. $this->config = $this->getMockBuilder(\Magento\Config\Model\Config::class)
  31. ->disableOriginalConstructor()
  32. ->setMethods(['getData', 'setData'])
  33. ->getMock();
  34. $objectManagerHelper = new ObjectManagerHelper($this);
  35. $this->model = $objectManagerHelper->getObject(
  36. \Magento\CatalogSearch\Plugin\EnableEavIndexer::class
  37. );
  38. }
  39. /**
  40. * Test with other search engine (not MySQL) selected in config
  41. *
  42. * @return void
  43. */
  44. public function testBeforeSave()
  45. {
  46. $this->config->expects($this->once())->method('getData')->willReturn('elasticsearch');
  47. $this->config->expects($this->never())->method('setData')->willReturnSelf();
  48. $this->model->beforeSave($this->config);
  49. }
  50. /**
  51. * Test with MySQL search engine selected in config
  52. *
  53. * @return void
  54. */
  55. public function testBeforeSaveMysqlSearchEngine()
  56. {
  57. $this->config->expects($this->at(0))->method('getData')->willReturn('mysql');
  58. $this->config->expects($this->at(1))->method('getData')->willReturn([]);
  59. $this->config->expects($this->once())->method('setData')->willReturnSelf();
  60. $this->model->beforeSave($this->config);
  61. }
  62. }