/** * {@inheritdoc} */ public function unsubscribeFrom($urls) { // Convert to array if (!is_array($urls)) { $urls = array($urls); } // Perform the unsubscriptions $successful = $this->subscriptionAdapter->unsubscribeFrom($urls); // Log the attempt $this->logger->logUnsubscribeAttempt($successful, $urls); return $successful; }
public function testUnsuccessfulUnsubscribeAttemptLogged() { $logger = $this->getMock('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface'); $subscriptionLogger = new SubscriptionLogger($logger); $logger->expects($this->once())->method('warn'); $subscriptionLogger->logUnsubscribeAttempt(false, array('http://www.google.com')); $this->assertEquals(1, $subscriptionLogger->countUnsubscribeAttempts(), 'Incorrect number of attempts logged'); $attempts = $subscriptionLogger->getUnsubscribeAttempts(); $this->assertFalse($attempts[0]->successful, 'Attempt expected to be unsuccessful'); $this->assertEquals(array('http://www.google.com'), $attempts[0]->urls, 'Incorrect URLs stored for attempt'); }