Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

Commit

Permalink
4.3.2 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
lcharette authored Nov 10, 2019
2 parents bff67c8 + 9e9943b commit 72bd843
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [4.3.2]
- Added `ResourceLocator::registerSharedStream` method

## [4.3.1]
- Added `__tostring` to ResourceInterface
- Added `__invoke` to ResourceLocatorInterface
- Added `__invoke` to ResourceLocatorInterface
- `ResourceLocationInterface::setPath` don't accept a `null` value anymore (produced an error anyway)
- Added proper PHP7 type hints
- Misc code quality and docblock fix
- Misc code quality and docblock fix

## [4.3.0]
- Dropping support for PHP 5.6 & 7.0
Expand Down Expand Up @@ -46,6 +49,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
### Security
-->

[4.3.2]: https://github.com/userfrosting/uniformresourcelocator/compare/4.3.1...4.3.2
[4.3.1]: https://github.com/userfrosting/uniformresourcelocator/compare/4.3.0...4.3.1
[4.3.0]: https://github.com/userfrosting/uniformresourcelocator/compare/4.2.3...4.3.0
[4.2.3]: https://github.com/userfrosting/uniformresourcelocator/compare/4.2.2...4.2.3
Expand Down
15 changes: 15 additions & 0 deletions src/ResourceLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,21 @@ public function registerStream(string $scheme, string $prefix = '', $paths = nul
return $this;
}

/**
* Register a new shared stream.
* Shortcut for registerStream with $shared flag set to true.
*
* @param string $scheme
* @param string $prefix (default '')
* @param string|array|null $paths (default null). When using null path, the scheme will be used as a path
*
* @return static
*/
public function registerSharedStream(string $scheme, string $prefix = '', $paths = null)
{
return $this->registerStream($scheme, $prefix, $paths, true);
}

/**
* AddPath function. Used to preserve compatibility with RocketTheme/Toolbox.
*
Expand Down
2 changes: 1 addition & 1 deletion tests/BuildingLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function setUp()
self::$locator->registerStream('files', 'data', 'upload/data/files', true); // Search path -> Building/upload/data/files/ (Stream with prefix + shared)
self::$locator->registerStream('conf', '', 'config'); // Search path -> Building/Floors/{floorX}/config (stream where scheme != path)
self::$locator->registerStream('cars', '', 'Garage/cars/', true); // Search path -> Building/Garage/cars (Stream shared, no prefix)
self::$locator->registerStream('absCars', '', $this->getBasePath().'Garage/cars/', true); // Search path -> Building/Garage/cars (Stream shared, no prefix, using absolute path)
self::$locator->registerSharedStream('absCars', '', $this->getBasePath().'Garage/cars/'); // Search path -> Building/Garage/cars (Stream shared, no prefix, using absolute path)
}

/**
Expand Down
38 changes: 38 additions & 0 deletions tests/ResourceLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,44 @@ public function testRegisterStream()
$this->assertEquals('foo', $barStream[''][0]->getPath());
}

/**
* @depends testRegisterStream
*/
public function testRegisterSharedStream()
{
$locator = new ResourceLocator();
$this->assertFalse($locator->schemeExists('bar'));

$locator->registerStream('bar', '', 'foo', true);

$this->assertTrue($locator->schemeExists('bar'));

$barStream = $locator->getStream('bar');
$this->assertInternalType('array', $barStream);
$this->assertInstanceOf(ResourceStreamInterface::class, $barStream[''][0]);
$this->assertEquals('foo', $barStream[''][0]->getPath());
$this->assertTrue($barStream[''][0]->isShared());
}

/**
* @depends testRegisterSharedStream
*/
public function testRegisterSharedStreamShort()
{
$locator = new ResourceLocator();
$this->assertFalse($locator->schemeExists('bar'));

$locator->registerSharedStream('bar', '', 'foo');

$this->assertTrue($locator->schemeExists('bar'));

$barStream = $locator->getStream('bar');
$this->assertInternalType('array', $barStream);
$this->assertInstanceOf(ResourceStreamInterface::class, $barStream[''][0]);
$this->assertEquals('foo', $barStream[''][0]->getPath());
$this->assertTrue($barStream[''][0]->isShared());
}

/**
* @depends testRegisterStream
*/
Expand Down

0 comments on commit 72bd843

Please sign in to comment.