Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mvkasatkin committed Nov 11, 2017
1 parent 3a4c8a5 commit 5583466
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/view/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace WebComplete\mvc\view;

use WebComplete\core\utils\alias\AliasService;
use WebComplete\mvc\assets\AssetManager;
use WebComplete\mvc\controller\AbstractController;

class View implements ViewInterface
Expand All @@ -18,13 +19,19 @@ class View implements ViewInterface
* @var AliasService|null
*/
private $aliasService;
/**
* @var AssetManager
*/
private $assetManager;

/**
* @param AliasService $aliasService
* @param AssetManager $assetManager
*/
public function __construct(AliasService $aliasService)
public function __construct(AliasService $aliasService, AssetManager $assetManager)
{
$this->aliasService = $aliasService;
$this->assetManager = $assetManager;
}

/**
Expand Down Expand Up @@ -87,6 +94,14 @@ public function setController(AbstractController $controller)
$this->controller = $controller;
}

/**
* @return AssetManager
*/
public function getAssetManager(): AssetManager
{
return $this->assetManager;
}

/**
* @return AbstractController|null
*/
Expand Down
10 changes: 10 additions & 0 deletions tests/include/app/config/config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Symfony\Component\Filesystem\Filesystem;

return [
'aliases' => [
'@app' => \dirname(__DIR__ . '/..', 2),
Expand All @@ -26,5 +28,13 @@
'definitions' => [
'errorController' => \DI\object(\tests\app\controllers\ErrorController::class),
\Psr\SimpleCache\CacheInterface::class => \DI\object(\Symfony\Component\Cache\Simple\NullCache::class),
\WebComplete\mvc\assets\AssetManager::class => function (\DI\Container $di) {
$aliasService = $di->get(\WebComplete\core\utils\alias\AliasService::class);
return new \WebComplete\mvc\assets\AssetManager(
new Filesystem(),
$aliasService->get('@web'),
'assets'
);
}
]
];
9 changes: 9 additions & 0 deletions tests/integration/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
use tests\MvcTestCase;
use WebComplete\core\utils\container\ContainerInterface;
use WebComplete\mvc\Application;
use WebComplete\mvc\assets\AssetManager;
use WebComplete\mvc\front\FrontController;
use WebComplete\mvc\view\View;

class ApplicationTest extends MvcTestCase
{
Expand Down Expand Up @@ -174,6 +176,13 @@ public function testContainer()
$this->assertSame($container, $application->getContainer());
}

public function testViewAssets()
{
$application = $this->createApplication();
$view = $application->getContainer()->get(View::class);
$this->assertInstanceOf(AssetManager::class, $view->getAssetManager());
}

/**
* @return Application
*/
Expand Down

0 comments on commit 5583466

Please sign in to comment.