Skip to content

Commit

Permalink
Allow setting of the resource store on dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
bajb committed Jun 3, 2019
1 parent 3a70053 commit 0f81f6b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Dispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ public function store()
return $this->_resourceStore;
}

public function setResourceStore(ResourceStore $store)
{
$this->_resourceStore = $store;
return $this;
}

public function calculateRelativePath($filePath)
{
return ltrim(str_replace($this->_projectRoot, '', $filePath), '/\\');
Expand Down
16 changes: 16 additions & 0 deletions tests/DispatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,20 @@ public function testHashing()
$this->assertNotEquals($uri, ResourceManager::public()->getResourceUri('css/placeholder.css'));
$this->assertEquals(substr($dispatch->generateHash('abc'), 0, 8), $dispatch->generateHash('abc', 8));
}

public function testSetResourceStore()
{
$store1 = new ResourceStore();
$store2 = new ResourceStore();

$dispatch = new Dispatch(__DIR__);

$dispatch->setResourceStore($store1);
$this->assertSame($store1, $dispatch->store());
$this->assertNotSame($store2, $dispatch->store());

$dispatch->setResourceStore($store2);
$this->assertSame($store2, $dispatch->store());
$this->assertNotSame($store1, $dispatch->store());
}
}

0 comments on commit 0f81f6b

Please sign in to comment.