Skip to content

Commit

Permalink
Merge branch 'hotfix/3085' of git://github.com/weierophinney/zf2 into…
Browse files Browse the repository at this point in the history
… weierophinney-hotfix/3085
  • Loading branch information
ralphschindler committed Feb 15, 2013
2 parents 8ed4e3a + bb2e97b commit 4b3bc3b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions library/Zend/Mvc/Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ public function getPluginManager()
$this->setPluginManager(new PluginManager());
}

$this->plugins->setController($this);
return $this->plugins;
}

Expand Down
51 changes: 51 additions & 0 deletions tests/ZendTest/Mvc/Controller/IntegrationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Mvc
*/

namespace ZendTest\Mvc\Controller;

use PHPUnit_Framework_TestCase as TestCase;
use Zend\EventManager\SharedEventManager;
use Zend\Mvc\Controller\ControllerManager;
use Zend\Mvc\Controller\PluginManager;
use Zend\ServiceManager\ServiceManager;

class IntegrationTest extends TestCase
{
public function setUp()
{
$this->plugins = new PluginManager();
$this->sharedEvents = new SharedEventManager();
$this->services = new ServiceManager();
$this->services->setService('ControllerPluginManager', $this->plugins);
$this->services->setService('SharedEventManager', $this->sharedEvents);
$this->services->setService('Zend\ServiceManager\ServiceLocatorInterface', $this->services);

$this->controllers = new ControllerManager();
$this->controllers->setServiceLocator($this->services);
}

public function testPluginReceivesCurrentController()
{
$this->controllers->setInvokableClass('first', 'ZendTest\Mvc\Controller\TestAsset\SampleController');
$this->controllers->setInvokableClass('second', 'ZendTest\Mvc\Controller\TestAsset\SampleController');

$first = $this->controllers->get('first');
$second = $this->controllers->get('second');
$this->assertNotSame($first, $second);

$plugin1 = $first->plugin('url');
$this->assertSame($first, $plugin1->getController());

$plugin2 = $second->plugin('url');
$this->assertSame($second, $plugin2->getController());

$this->assertSame($plugin1, $plugin2);
}
}

0 comments on commit 4b3bc3b

Please sign in to comment.