Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing modman file parser #191

Merged
merged 1 commit into from
Apr 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/MagentoHackathon/Composer/Magento/ModmanParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,14 @@ protected function _parseMappings()
continue;
}
$parts = preg_split('/\s+/', $row, 2, PREG_SPLIT_NO_EMPTY);
if (count($parts) != 2) {
throw new \ErrorException(sprintf('Invalid row on line %d has %d parts, expected 2', $line, count($row)));
if (count($parts) === 1) {
$part = reset($parts);
$map[] = array($part, $part);
} elseif (count($parts) === 2) {
$map[] = $parts;
} else {
throw new \ErrorException(sprintf('Invalid row on line %d has %d parts, expected 1 or 2', $line, count($row)));
}
$map[] = $parts;
}
return $map;
}
Expand Down
13 changes: 13 additions & 0 deletions tests/MagentoHackathon/Composer/Magento/ModmanParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,17 @@ public function testGetMappings()
$this->object->setFile($this->modmanFileDir . 'modman');
$this->assertSame($expected, $this->object->getMappings());
}

/**
* @covers MagentoHackathon\Composer\Magento\ModmanParser::getMappings
*/
public function testGetMappingsNew()
{
$expected = array(
array('line/one', 'line/one'),
array('line/two', 'line/two'),
);
$this->object->setFile($this->modmanFileDir . 'modman.new_format');
$this->assertSame($expected, $this->object->getMappings());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

line/one
line/two

#this is a comment which will be ignored

@shell This won't run
@import This/Will/Be/Ignored/Too