41 public function __construct($title, $parameters = array())
43 parent::__construct($title, $parameters);
45 $this->
response = Response::create();
52 protected function handle(Request $request)
54 $this->request = $request;
56 return $this->response;
64 return $this->request;
72 return $this->response;
78 private $name =
"<name>";
84 private $twigEnvironment;
101 protected function setUp()
103 $this->session = M::mock(
'Symfony\Component\HttpFoundation\Session\SessionInterface');
106 $container = M::mock(
'Container');
108 $this->
menu = M::mock(Menu::class);
109 $this->twigEnvironment = M::mock(
'\Twig_Environment');
110 $this->logger = M::mock(
'Monolog\Logger');
112 $container->shouldReceive(
'get')->with(
'ui.component.menu')->andReturn($this->
menu);
113 $container->shouldReceive(
'get')->with(
'ui.component.micromenu')->andReturn($this->microMenu);
114 $container->shouldReceive(
'get')->with(
'twig.environment')->andReturn($this->twigEnvironment);
115 $container->shouldReceive(
'get')->with(
'logger')->andReturn($this->logger);
116 $container->shouldReceive(
'get')->with(
'session')->andReturn($this->session);
117 $this->container = $container;
118 $GLOBALS[
'container'] = $container;
123 protected function tearDown()
128 public function testGetName()
130 assertThat($this->plugin->getName(), is($this->name));
133 public function testGetTitle()
135 assertThat($this->plugin->getTitle(), is(nullValue()));
138 $this->plugin =
new TestPlugin($this->name, array(TestPlugin::TITLE => $title));
140 assertThat($this->plugin->getTitle(), is($title));
143 public function testGetPermission()
152 public function testIsRequiresLogin()
154 $this->assertTrue($this->plugin->isRequiresLogin());
156 $this->plugin =
new TestPlugin($this->name, array(TestPlugin::REQUIRES_LOGIN =>
false));
158 $this->assertFalse($this->plugin->isRequiresLogin());
161 public function testGetPluginLevel()
163 assertThat($this->plugin->getPluginLevel(), is(10));
165 $this->plugin =
new TestPlugin($this->name, array(TestPlugin::LEVEL => 5));
167 assertThat($this->plugin->getPluginLevel(), is(5));
170 public function testGetDependencies()
172 assertThat($this->plugin->getDependency(), is(emptyArray()));
174 $dependencies = array(
'foo',
'bar');
175 $this->plugin =
new TestPlugin($this->name, array(TestPlugin::DEPENDENCIES => $dependencies));
177 assertThat($this->plugin->getDependency(), is($dependencies));
180 public function testGetInitOrder()
182 assertThat($this->plugin->getInitOrder(), is(0));
184 $this->plugin =
new TestPlugin($this->name, array(TestPlugin::INIT_ORDER => 15));
186 assertThat($this->plugin->getInitOrder(), is(15));
195 $this->plugin->getResponse();
198 public function testSessionIsWrappedInRequest()
200 $this->logger->shouldReceive(
"debug")->once()->with(startsWith(
"handle request in"));
202 $this->plugin =
new TestPlugin($this->name, array(TestPlugin::REQUIRES_LOGIN =>
false));
204 $this->plugin->getResponse();
206 $request = $this->plugin->getTestRequest();
208 assertThat($request->getSession(), is($this->session));
211 public function testIsLoggedIn()
214 unset($_SESSION[
'User']);
215 assertThat($this->plugin->isLoggedIn(), is(equalTo(
false)));
216 $_SESSION[
'User'] =
'Default User';
217 assertThat($this->plugin->isLoggedIn(), is(equalTo(
false)));
218 $_SESSION[
'User'] =
'resU tlaufeD';
219 assertThat($this->plugin->isLoggedIn(), is(equalTo(
true)));
220 $this->addToAssertionCount(3);
testExceptionWhenLoginIsRequired()
int response
Is a response expected from the scheduler.