/** * Send a text message to the specified provider. * * @param string $provider The provider ID to send to * @param string $to The phone number at the provider * @param string $from The email address to use as sender * @param string $message The message to send * * @throws \VuFind\Exception\Mail * @return void */ public function text($provider, $to, $from, $message) { $knownCarriers = array_keys($this->carriers); if (empty($provider) || !in_array($provider, $knownCarriers)) { throw new MailException('Unknown Carrier'); } $to = $this->filterPhoneNumber($to) . '@' . $this->carriers[$provider]['domain']; $from = empty($from) ? $this->defaultFrom : $from; $subject = ''; return $this->mailer->send($to, $from, $subject, $message); }
/** * Test sendRecord * * @return void */ public function testSendRecord() { $driver = $this->getMock('VuFind\\RecordDriver\\AbstractBase'); $driver->expects($this->once())->method('getBreadcrumb')->will($this->returnValue('breadcrumb')); $viewCallback = function ($in) use($driver) { return $in['driver'] == $driver && $in['to'] == '*****@*****.**' && $in['from'] == '*****@*****.**' && $in['message'] == 'message'; }; $view = $this->getMock('Zend\\View\\Renderer\\PhpRenderer', ['partial']); $view->expects($this->once())->method('partial')->with($this->equalTo('Email/record.phtml'), $this->callback($viewCallback))->will($this->returnValue('body')); $callback = function ($message) { return '<*****@*****.**>' == $message->getTo()->current()->toString() && '<*****@*****.**>' == $message->getFrom()->current()->toString() && 'body' == $message->getBody() && 'Library Catalog Record: breadcrumb' == $message->getSubject(); }; $transport = $this->getMock('Zend\\Mail\\Transport\\TransportInterface'); $transport->expects($this->once())->method('send')->with($this->callback($callback)); $mailer = new Mailer($transport); $mailer->sendRecord('*****@*****.**', '*****@*****.**', 'message', $driver, $view); }