Skip to content

Commit

Permalink
Merge pull request #64 from spiral/bugfix/scaffolder-path
Browse files Browse the repository at this point in the history
Remove the root directory from the filename generated by Scaffolder
  • Loading branch information
butschster committed Oct 18, 2023
2 parents fdbe8f0 + de652cf commit 59e5600
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
30 changes: 15 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@
"nyholm/psr7": "^1.5",
"mockery/mockery": "^1.5",
"phpunit/phpunit": "^9.6 || ^10.0",
"spiral/auth": "^3.7",
"spiral/auth-http": "^3.7",
"spiral/boot": "^3.7",
"spiral/events": "^3.7",
"spiral/console": "^3.7",
"spiral/http": "^3.7",
"spiral/mailer": "^3.7",
"spiral/queue": "^3.7",
"spiral/session": "^3.7",
"spiral/security": "^3.7",
"spiral/tokenizer": "^3.7",
"spiral/storage": "^3.7",
"spiral/views": "^3.7",
"spiral/translator": "^3.7",
"spiral/scaffolder": "^3.7",
"spiral/auth": "^3.8.4",
"spiral/auth-http": "^3.8.4",
"spiral/boot": "^3.8.4",
"spiral/events": "^3.8.4",
"spiral/console": "^3.8.4",
"spiral/http": "^3.8.4",
"spiral/mailer": "^3.8.4",
"spiral/queue": "^3.8.4",
"spiral/session": "^3.8.4",
"spiral/security": "^3.8.4",
"spiral/tokenizer": "^3.8.4",
"spiral/storage": "^3.8.4",
"spiral/views": "^3.8.4",
"spiral/translator": "^3.8.4",
"spiral/scaffolder": "^3.8.4",
"symfony/mime": "^6.0"
},
"suggest": {
Expand Down
17 changes: 10 additions & 7 deletions src/Traits/InteractsWithScaffolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ public function assertScaffolderCommandSame(
$this->assertSame($expected, $data, 'Generated code is not the same with expected.');

if ($expectedFilename) {
$this->assertSame($expectedFilename, $filename, 'Generated filename is not the same with expected.');
$root = $this->getDirectoryByAlias('root');
$this->assertSame(
\str_replace($root, '', $expectedFilename),
\str_replace($root, '', $filename), 'Generated filename is not the same with expected.'
);
}

return true;
Expand All @@ -51,7 +55,11 @@ public function assertScaffolderCommandContains(
}

if ($expectedFilename) {
$this->assertSame($expectedFilename, $filename, 'Generated filename is not the same with expected.');
$root = $this->getDirectoryByAlias('root');
$this->assertSame(
\str_replace($root, '', $expectedFilename),
\str_replace($root, '', $filename), 'Generated filename is not the same with expected.'
);
}

return true;
Expand All @@ -69,11 +77,6 @@ public function mockScaffolder(string $command, array $args, \Closure $expected)
: null;

$files = $this->mockContainer(FilesInterface::class);
$files->shouldReceive('normalizePath')->andReturnUsing(function (string $filename) {
$root = $this->getDirectoryByAlias('root');

return \str_replace($root, '', $filename);
});
$files->shouldReceive('exists')->andReturnFalse();
$files->shouldReceive('write')->withArgs($expected);

Expand Down

0 comments on commit 59e5600

Please sign in to comment.