/** @test **/ public function theGitPathIsUsedInAMergeRule() { // Arrange $calculator = new \ShopFitter\Plan\Theme\ThemeActionPlanner(); file_put_contents(vfs\vfsStream::url("root/theme/config/another_file.json"), ""); $this->simpleShopfile->addMergeRule(new MergeRule("config/another_file.json", "path/in/git")); // Act $actual = $calculator->generatePlan(vfs\vfsStream::url("root/theme"), $this->simpleShopfile); // Assert $this->assertEquals("path/in/git", $actual["vfs://root/theme/config/another_file.json"]["git_path"]); }
/** * @param string $rootDirectory * @param Shopfile $shopfile * @return array */ public function generatePlan($rootDirectory, Shopfile $shopfile) { $actions = []; foreach ($shopfile->getMergeRules() as $mergeRule) { $actions = array_merge($actions, $this->actionsForMergeRule($rootDirectory, $mergeRule)); } foreach ($shopfile->getProtectRules() as $protectRule) { $actions = array_merge($actions, $this->actionsForProtectRule($rootDirectory, $protectRule)); } foreach ($shopfile->getReplaceRules() as $replaceRule) { $actions = array_merge($actions, $this->actionsForReplaceRule($rootDirectory, $replaceRule)); } return $actions; }