DryRunTest.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Setup;
  7. use Magento\Framework\Setup\Declaration\Schema\DryRunLogger;
  8. use Magento\TestFramework\Deploy\CliCommand;
  9. use Magento\TestFramework\Deploy\TestModuleManager;
  10. use Magento\TestFramework\Helper\Bootstrap;
  11. use Magento\TestFramework\TestCase\SetupTestCase;
  12. /**
  13. * The purpose of this test is verifying declarative installation works.
  14. */
  15. class DryRunTest extends SetupTestCase
  16. {
  17. /**
  18. * @var TestModuleManager
  19. */
  20. private $moduleManager;
  21. /**
  22. * @var CliCommand
  23. */
  24. private $cliCommad;
  25. public function setUp()
  26. {
  27. $objectManager = Bootstrap::getObjectManager();
  28. $this->moduleManager = $objectManager->get(TestModuleManager::class);
  29. $this->cliCommad = $objectManager->get(CliCommand::class);
  30. }
  31. /**
  32. * @moduleName Magento_TestSetupDeclarationModule1
  33. * @dataProviderFromFile Magento/TestSetupDeclarationModule1/fixture/dry_run_log.php
  34. */
  35. public function testDryRunOnCleanDatabase()
  36. {
  37. $logFileName = TESTS_TEMP_DIR . '/var/log/' . DryRunLogger::FILE_NAME;
  38. $this->cliCommad->install(
  39. ['Magento_TestSetupDeclarationModule1'],
  40. ['dry-run' => true]
  41. );
  42. self::assertFileExists($logFileName);
  43. $data = file_get_contents($logFileName);
  44. self::assertEquals($data, $this->getData()[0]);
  45. }
  46. /**
  47. * @moduleName Magento_TestSetupDeclarationModule1
  48. * @dataProviderFromFile Magento/TestSetupDeclarationModule1/fixture/dry_run_log_on_upgrade.php
  49. */
  50. public function testDryRunOnUpgrade()
  51. {
  52. $logFileName = TESTS_TEMP_DIR . '/var/log/' . DryRunLogger::FILE_NAME;
  53. $this->cliCommad->install(['Magento_TestSetupDeclarationModule1']);
  54. $this->moduleManager->updateRevision(
  55. 'Magento_TestSetupDeclarationModule1',
  56. 'column_modifications',
  57. 'db_schema.xml',
  58. 'etc'
  59. );
  60. $this->cliCommad->upgrade(['dry-run' => true]);
  61. self::assertFileExists($logFileName);
  62. $data = file_get_contents($logFileName);
  63. self::assertEquals($data, $this->getData()[0]);
  64. }
  65. }