Skip to content

Commit

Permalink
The directory method should have a trailing slash. Closes statamic/se…
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Oct 29, 2020
1 parent d1983a2 commit bf01afd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Extend/Addon.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ public function __call($method, $args)
}

/**
* The directory the package is located within. eg. "/path/to/vendor/statamic/bloodhound".
* The directory the package is located within. eg. "/path/to/vendor/statamic/bloodhound/".
*
* @return string
*/
Expand All @@ -420,7 +420,7 @@ public function directory()

$dir = Str::removeRight(dirname($reflector->getFileName()), rtrim($this->autoload, '/'));

return $this->directory = Str::removeRight($dir, '/');
return $this->directory = Str::ensureRight($dir, '/');
}

public function existsOnMarketplace()
Expand Down
10 changes: 5 additions & 5 deletions tests/Extend/AddonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AddonTest extends TestCase
public function setUp(): void
{
parent::setUp();
$this->addonFixtureDir = realpath(__DIR__.'/../Fixtures/Addon');
$this->addonFixtureDir = realpath(__DIR__.'/../Fixtures/Addon').'/';
}

/** @test */
Expand Down Expand Up @@ -123,8 +123,8 @@ public function it_checks_if_a_file_exists()
{
$addon = $this->makeFromPackage();

File::shouldReceive('exists')->with($this->addonFixtureDir.'/test.txt')->andReturnTrue();
File::shouldReceive('exists')->with($this->addonFixtureDir.'/notfound.txt')->andReturnFalse();
File::shouldReceive('exists')->with($this->addonFixtureDir.'test.txt')->andReturnTrue();
File::shouldReceive('exists')->with($this->addonFixtureDir.'notfound.txt')->andReturnFalse();

$this->assertTrue($addon->hasFile('test.txt'));
$this->assertFalse($addon->hasFile('notfound.txt'));
Expand All @@ -135,7 +135,7 @@ public function it_gets_file_contents()
{
$addon = $this->makeFromPackage();

File::shouldReceive('get')->with($this->addonFixtureDir.'/test.txt')->andReturn('the file contents');
File::shouldReceive('get')->with($this->addonFixtureDir.'test.txt')->andReturn('the file contents');

$this->assertEquals('the file contents', $addon->getFile('test.txt'));
}
Expand All @@ -145,7 +145,7 @@ public function it_writes_file_contents()
{
$addon = $this->makeFromPackage();

File::shouldReceive('put')->with($this->addonFixtureDir.'/test.txt', 'the file contents');
File::shouldReceive('put')->with($this->addonFixtureDir.'test.txt', 'the file contents');

$addon->putFile('test.txt', 'the file contents');
}
Expand Down

0 comments on commit bf01afd

Please sign in to comment.