Skip to content

Commit

Permalink
Disable access controll for JQAdm tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Sep 3, 2017
1 parent 20ef0da commit e27fb31
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
28 changes: 22 additions & 6 deletions src/Aimeos/Shop/Base/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
*/
class View
{
/**
* @var \Illuminate\Contracts\Config\Repository
*/
private $config;

/**
* @var \Aimeos\Shop\Base\I18n
*/
Expand All @@ -38,12 +43,15 @@ class View
/**
* Initializes the object
*
* @param \Illuminate\Contracts\Config\Repository $config Configuration object
* @param \Aimeos\Shop\Base\I18n $i18n I18n object
* @param \Aimeos\Shop\Base\Support $support Support object
*/
public function __construct( \Aimeos\Shop\Base\I18n $i18n, \Aimeos\Shop\Base\Support $support )
public function __construct( \Illuminate\Contracts\Config\Repository $config,
\Aimeos\Shop\Base\I18n $i18n, \Aimeos\Shop\Base\Support $support )
{
$this->i18n = $i18n;
$this->config = $config;
$this->support = $support;
}

Expand Down Expand Up @@ -88,13 +96,21 @@ public function create( \Aimeos\MShop\Context\Item\Iface $context, array $templa
*/
protected function addAccess( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Context\Item\Iface $context )
{
$support = $this->support;
if( $this->config->get( 'shop.accessControl', true ) !== false )
{
$support = $this->support;

$fcn = function() use ( $support, $context ) {
return $support->getGroups( $context );
};

$fcn = function() use ( $support, $context ) {
return $support->getGroups( $context );
};
$helper = new \Aimeos\MW\View\Helper\Access\Standard( $view, $fcn );
}
else
{
$helper = new \Aimeos\MW\View\Helper\Access\All( $view );
}

$helper = new \Aimeos\MW\View\Helper\Access\Standard( $view, $fcn );
$view->addHelper( 'access', $helper );

return $view;
Expand Down
2 changes: 1 addition & 1 deletion src/Aimeos/Shop/ShopServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function register()
});

$this->app->singleton('Aimeos\Shop\Base\View', function($app) {
return new \Aimeos\Shop\Base\View($app['Aimeos\Shop\Base\I18n'], $app['Aimeos\Shop\Base\Support']);
return new \Aimeos\Shop\Base\View($app['config'], $app['Aimeos\Shop\Base\I18n'], $app['Aimeos\Shop\Base\Support']);
});


Expand Down
3 changes: 2 additions & 1 deletion tests/AimeosTestAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function getEnvironmentSetUp($app)

$app['config']->set('shop.authorize', false);
$app['config']->set('shop.disableSites', false);
$app['config']->set('shop.routes.login', []);
$app['config']->set('shop.accessControl', false);
$app['config']->set('shop.routes.jqadm', ['prefix' => '{site}/jqadm']);
$app['config']->set('shop.routes.extadm', ['prefix' => '{site}/extadm']);
$app['config']->set('shop.routes.jsonadm', ['prefix' => '{site}/jsonadm']);
Expand All @@ -29,6 +29,7 @@ protected function getEnvironmentSetUp($app)
$app['config']->set('shop.routes.default', ['prefix' => '{site}']);
$app['config']->set('shop.routes.confirm', ['prefix' => '{site}']);
$app['config']->set('shop.routes.update', ['prefix' => '{site}']);
$app['config']->set('shop.routes.login', []);
}


Expand Down
4 changes: 3 additions & 1 deletion tests/Base/ViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class ViewTest extends AimeosTestAbstract
{
public function testCreateNoLocale()
{
$config = $this->getMockBuilder('\Illuminate\Config\Repository')->getMock();

$i18n = $this->getMockBuilder( '\Aimeos\Shop\Base\I18n' )
->disableOriginalConstructor()
->getMock();
Expand All @@ -17,7 +19,7 @@ public function testCreateNoLocale()
$context->setConfig( new \Aimeos\MW\Config\PHPArray() );
$context->setSession( new \Aimeos\MW\Session\None() );

$object = new \Aimeos\Shop\Base\View( $i18n, $support );
$object = new \Aimeos\Shop\Base\View( $config, $i18n, $support );

$this->assertInstanceOf( '\Aimeos\MW\View\Iface', $object->create( $context, array() ) );
}
Expand Down

0 comments on commit e27fb31

Please sign in to comment.