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

What's a ResourceManager? #6441

Merged
merged 5 commits into from
Mar 2, 2017
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
1 change: 0 additions & 1 deletion src/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Bolt\Filesystem\Exception\IOException;
use Bolt\Filesystem\Handler\DirectoryInterface;
use Bolt\Filesystem\Handler\HandlerInterface;
use Bolt\Legacy\Deprecation;
use Doctrine\Common\Cache\FilesystemCache;

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Provider/UploadServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ function () use ($app) {
);

// This allows multiple upload locations, all prefixed with a namespace. The default is /files
// Note, if you want to provide an alternative namespace, you must set a path on the $app['resources']
// service
// Note, this must be a name of a mounted filesystem (see FilesystemServiceProvider)
$app['upload.namespace'] = 'files';

// This gets prepended to all file saves, can be reset to "" or add your own closure for more complex ones.
Expand Down
23 changes: 4 additions & 19 deletions tests/phpunit/unit/BoltUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
use Bolt\AccessControl\Permissions;
use Bolt\AccessControl\Token;
use Bolt\Application;
use Bolt\Cache;
use Bolt\Configuration as Config;
use Bolt\Legacy\Storage;
use Bolt\Logger\FlashLogger;
use Bolt\Logger\Manager;
use Bolt\Storage\Entity;
use Bolt\Tests\Mocks\LoripsumMock;
use Bolt\Users;
use Doctrine\Common\Cache\VoidCache;
use GuzzleHttp\Client;
use Monolog\Logger;
use PHPUnit_Framework_MockObject_MockObject;
Expand Down Expand Up @@ -334,27 +334,12 @@ protected function getMockAccessChecker($app, $methods = ['isValidSession'])
}

/**
* @param null $path
*
* @return Cache|PHPUnit_Framework_MockObject_MockObject
* @return VoidCache|PHPUnit_Framework_MockObject_MockObject
*/
protected function getMockCache($path = null)
protected function getMockCache()
{
$app = $this->getApp();
if ($path === null) {
$path = $app['resources']->getPath('cache');
}

$params = [
$path,
Cache::EXTENSION,
0002,
$app['filesystem'],
];

return $this->getMockBuilder(Cache::class)
return $this->getMockBuilder(VoidCache::class)
->setMethods(['flushAll'])
->setConstructorArgs($params)
->getMock()
;
}
Expand Down
6 changes: 2 additions & 4 deletions tests/phpunit/unit/Composer/Action/DumpAutoloadTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php
namespace Bolt\Tests\Composer\Action;

use Bolt\Composer\Action\DumpAutoload;

/**
* Class to test src/Composer/Action/DumpAutoload.
*
Expand All @@ -13,9 +11,9 @@ class DumpAutoloadTest extends ActionUnitTest
public function testConstruct()
{
$app = $this->getApp();
$autoload = $app['resources']->getPath('extensionspath/vendor/autoload.php');
$autoload = $app['path_resolver']->resolve('%extensions%/vendor/autoload.php');
@unlink($autoload);
$app['extend.action']['autoload']->execute();
$this->assertTrue(is_readable($app['resources']->getPath('extensionspath/vendor/autoload.php')));
$this->assertTrue(is_readable($autoload));
}
}
2 changes: 1 addition & 1 deletion tests/phpunit/unit/Controller/Backend/GeneralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function testTranslation()
$this->assertTrue($response instanceof RedirectResponse);
$this->assertTrue($response->isRedirect('/bolt/tr/contenttypes/en_CY'));

$this->rmdir($this->getService('resources')->getPath('app/resources/translations/en_CY'));
$this->rmdir($this->getService('path_resolver')->resolve('%app%/resources/translations/en_CY'));

// Check that YML parse errors get caught
$this->setRequest(Request::create(
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/unit/Nut/CacheClearTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testSuccessfulClear()
public function testWithFailures()
{
$app = $this->getApp();
$app['cache'] = $this->getMockCache(null, false);
$app['cache'] = $this->getMockCache(false);
$command = new CacheClear($app);
$tester = new CommandTester($command);

Expand All @@ -36,9 +36,9 @@ public function testWithFailures()
$this->assertRegExp('/Failed to clear cache/', $result);
}

protected function getMockCache($path = null, $flushResult = true)
protected function getMockCache($flushResult = true)
{
$cache = parent::getMockCache($path);
$cache = parent::getMockCache();
$cache->expects($this->once())
->method('flushAll')
->will($this->returnValue($flushResult))
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/unit/Nut/ConfigGetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public function testDefaultFile()

$command = new ConfigGet($app);
$tester = new CommandTester($command);
$app['resources']->setPath('config', PHPUNIT_ROOT . '/resources');
$tester->execute(['key' => 'sitename']);
$this->assertEquals("sitename: A sample site\n", $tester->getDisplay());
}
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/unit/Nut/ConfigSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public function testDefaultFile()

$command = new ConfigSet($app);
$tester = new CommandTester($command);
$app['resources']->setPath('config', PHPUNIT_ROOT . '/resources');
$tester->execute(['key' => 'nonexistent', 'value' => 'test']);
$this->assertEquals("The key 'nonexistent' was not found in config.yml.\n", $tester->getDisplay());
}
Expand Down