/** * Tests the JApplicationWeb::initialise method with dependancy injection. * * @return void * * @since 11.3 */ public function testInitialiseWithInjection() { $mockSession = $this->getMock('JSession', array('test'), array(), '', false); $mockSession ->expects($this->any()) ->method('test') ->will( $this->returnValue('JSession') ); $mockDocument = $this->getMock('JDocument', array('test'), array(), '', false); $mockDocument ->expects($this->any()) ->method('test') ->will( $this->returnValue('JDocument') ); $mockLanguage = $this->getMock('JLanguage', array('test'), array(), '', false); $mockLanguage ->expects($this->any()) ->method('test') ->will( $this->returnValue('JLanguage') ); $mockDispatcher = $this->getMock('JEventDispatcher', array('test'), array(), '', false); $mockDispatcher ->expects($this->any()) ->method('test') ->will( $this->returnValue('JEventDispatcher') ); $this->class->initialise($mockSession, $mockDocument, $mockLanguage, $mockDispatcher); $this->assertThat( TestReflection::getValue($this->class, 'session')->test(), $this->equalTo('JSession'), 'Tests session injection.' ); $this->assertThat( TestReflection::getValue($this->class, 'document')->test(), $this->equalTo('JDocument'), 'Tests document injection.' ); $this->assertThat( TestReflection::getValue($this->class, 'language')->test(), $this->equalTo('JLanguage'), 'Tests language injection.' ); $this->assertThat( TestReflection::getValue($this->class, 'dispatcher')->test(), $this->equalTo('JEventDispatcher'), 'Tests dispatcher injection.' ); }
/** * Tests the JApplicationWeb::initialise method with dependancy injection. * * @return void * * @since 11.3 */ public function testInitialiseWithInjection() { $mockSession = $this->getMock('JSession', array('test'), array(), '', false); $mockSession->expects($this->any())->method('test')->willReturnSelf(); $mockDocument = $this->getMock('JDocument', array('test'), array(), '', false); $mockDocument->expects($this->any())->method('test')->willReturnSelf(); $mockLanguage = $this->getMock('JLanguage', array('test'), array(), '', false); $mockLanguage->expects($this->any())->method('test')->willReturnSelf(); $mockDispatcher = $this->getMock('JEventDispatcher', array('test'), array(), '', false); $mockDispatcher->expects($this->any())->method('test')->willReturnSelf(); $this->class->initialise($mockSession, $mockDocument, $mockLanguage, $mockDispatcher); $this->assertSame($mockSession, $this->class->getSession()->test()); $this->assertSame($mockDocument, $this->class->getDocument()->test()); $this->assertSame($mockLanguage, $this->class->getLanguage()->test()); $this->assertSame($mockDispatcher, TestReflection::getValue($this->class, 'dispatcher')->test()); }
/** * Tests the JApplicationWeb::initialise method with dependancy injection. * * @return void * * @since 11.3 */ public function testInitialiseWithInjection() { $mockSession = $this->getMock('JSession', array('test'), array(), '', false); $mockSession->expects($this->any())->method('test')->willReturnSelf(); $mockDocument = $this->getMock('JDocument', array('test'), array(), '', false); $mockDocument->expects($this->any())->method('test')->willReturnSelf(); $mockLanguage = $this->getMock('JLanguage', array('test'), array(), '', false); $mockLanguage->expects($this->any())->method('test')->willReturnSelf(); $mockDispatcher = $this->getMock('\\Joomla\\Event\\DispatcherInterface', array('addListener', 'dispatch', 'removeListener'), array(), '', false); $mockDispatcher->expects($this->any())->method('dispatch')->willReturnSelf(); $this->class->initialise($mockSession, $mockDocument, $mockLanguage, $mockDispatcher); $this->assertSame($mockSession, $this->class->getSession()->test()); $this->assertSame($mockDocument, $this->class->getDocument()->test()); $this->assertSame($mockLanguage, $this->class->getLanguage()->test()); $this->assertSame($mockDispatcher, $this->class->getDispatcher()->dispatch('foo')); }