Skip to content

Commit

Permalink
#4292: Ability to switch to default mode[forwardport].
Browse files Browse the repository at this point in the history
  • Loading branch information
nmalevanec committed Jan 10, 2018
1 parent e150a7e commit 3967190
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/code/Magento/Deploy/Console/Command/SetModeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
$modeController->enableProductionMode();
}
break;
case State::MODE_DEFAULT:
$modeController->enableDefaultMode();
break;
default:
throw new LocalizedException(__('Cannot switch into given mode "%1"', $toMode));
}
Expand Down
19 changes: 19 additions & 0 deletions app/code/Magento/Deploy/Model/Mode.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,25 @@ public function enableDeveloperMode()
$this->setStoreMode(State::MODE_DEVELOPER);
}

/**
* Enable Default mode.
*
* @return void
*/
public function enableDefaultMode()
{
$this->filesystem->cleanupFilesystem(
[
DirectoryList::CACHE,
DirectoryList::GENERATED_CODE,
DirectoryList::GENERATED_METADATA,
DirectoryList::TMP_MATERIALIZATION_DIR,
DirectoryList::STATIC_VIEW,
]
);
$this->setStoreMode(State::MODE_DEFAULT);
}

/**
* Get current mode information
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

use Magento\Deploy\Console\Command\SetModeCommand;
use Symfony\Component\Console\Tester\CommandTester;
use Magento\Framework\App\State;

/**
* @package Magento\Deploy\Test\Unit\Console\Command
Expand Down Expand Up @@ -67,6 +66,18 @@ public function testSetDeveloperMode()
);
}

public function testSetDefaultMode()
{
$this->modeMock->expects($this->once())->method('enableDefaultMode');

$tester = new CommandTester($this->command);
$tester->execute(['mode' => 'default']);
$this->assertContains(
"default mode",
$tester->getDisplay()
);
}

public function testSetProductionSkipCompilation()
{
$this->modeMock->expects($this->once())->method('enableProductionModeMinimal');
Expand Down

0 comments on commit 3967190

Please sign in to comment.