/** * Sets the Factory pointers * * @return void */ protected function restoreFactoryState() { \JFactory::$application = $this->savedFactoryState['application']; \JFactory::$config = $this->savedFactoryState['config']; \JFactory::$dates = $this->savedFactoryState['dates']; \JFactory::$session = $this->savedFactoryState['session']; \JFactory::$language = $this->savedFactoryState['language']; \JFactory::$document = $this->savedFactoryState['document']; \JFactory::$acl = $this->savedFactoryState['acl']; \JFactory::$database = $this->savedFactoryState['database']; \JFactory::$mailer = $this->savedFactoryState['mailer']; }
/** * Get a mailer object. * * Returns the global {@link JMail} object, only creating it if it doesn't already exist. * * @return JMail object * * @see JMail * @since 11.1 */ public static function getMailer() { if (!self::$mailer) { self::$mailer = self::createMailer(); } $copy = clone self::$mailer; return $copy; }
/** * Get a mailer object * * Returns the global {@link JMail} object, only creating it * if it doesn't already exist * * @return object JMail */ public static function getMailer() { if (!is_object(JFactory::$mailer)) { JFactory::$mailer = JFactory::_createMailer(); } $copy = clone JFactory::$mailer; return $copy; }
/** * Testing sendAdminMail(). * * @param array Arguments for method call * @param array Arguments received by method * @param bool Expected return from call * * @return void * * @dataProvider casesSendAdminMail */ public function testSendAdminMail($args, $expectedArgs, $expResult) { $mockMailer = $this->getMock('JMail', array('sendAdminMail')); $mockMailer->expects($this->once())->method('sendAdminMail')->with($this->equalTo($expectedArgs['adminName']), $this->equalTo($expectedArgs['adminEmail']), $this->equalTo($expectedArgs['email']), $this->equalTo($expectedArgs['type']), $this->equalTo($expectedArgs['title']), $this->equalTo($expectedArgs['author']), $this->equalTo($expectedArgs['url']))->will($this->returnValue($expResult)); JFactory::$mailer = $mockMailer; $this->assertThat(JUtility::sendAdminMail($args['adminName'], $args['adminEmail'], $args['email'], $args['type'], $args['title'], $args['author'], $args['url']), $this->equalTo($expResult)); }