Ejemplo n.º 1
0
 /**
  * @covers EmailLoggerPlugin::existsByAssoc()
  */
 public function testExistsByAssoc()
 {
     import('lib.pkp.classes.log.EmailLogEntry');
     $logEntry = new EmailLogEntry();
     $logEntry->setAssocType(ASSOC_TYPE_SUBMISSION);
     $logEntry->setAssocId(1);
     $logEntry->setRecipients('"Adela Gallego" <*****@*****.**>');
     $logEntry->setFrom('"Ramiro Vaca" <*****@*****.**>');
     $logEntry->setBody('Anything here in body so I can test retrieving the log entry checking the body. This is the part that will match.');
     $logEntry2 = clone $logEntry;
     $logEntry2->setAssocId(2);
     $logEntry2->setRecipients('"Jennifer Brower" <*****@*****.**>');
     $logEntry2->setBody('Anything here in body so I can test retrieving the log entry checking the body.');
     $logEntry3 = clone $logEntry;
     $logEntry3->setBody($logEntry2->getBody());
     $logEntry4 = clone $logEntry;
     $logEntry4->setRecipients($logEntry2->getRecipients());
     $logEntry5 = clone $logEntry;
     $logEntry5->setEventType(1);
     $entries = array($logEntry, $logEntry2, $logEntry3, $logEntry4, $logEntry5);
     $emailLogPlugin = $this->getMock('EmailLoggerPlugin', array('getLogByAssoc'));
     $emailLogPlugin->expects($this->any())->method('getLogByAssoc')->will($this->returnValue($entries));
     $this->assertTrue($emailLogPlugin->existsByAssoc(ASSOC_TYPE_SUBMISSION, 1));
     $this->assertTrue($emailLogPlugin->existsByAssoc(ASSOC_TYPE_SUBMISSION, 1, '*****@*****.**'));
     $this->assertFalse($emailLogPlugin->existsByAssoc(ASSOC_TYPE_SUBMISSION, 1, '*****@*****.**', 1, 'This is the part that will match'));
     $this->assertTrue($emailLogPlugin->existsByAssoc(ASSOC_TYPE_SUBMISSION, 1, null, 1));
     // Non existing event type.
     $this->assertFalse($emailLogPlugin->existsByAssoc(ASSOC_TYPE_SUBMISSION, 1, null, 2));
     // Matches everything but don't use event type.
     $this->assertTrue($emailLogPlugin->existsByAssoc(ASSOC_TYPE_SUBMISSION, 1, '*****@*****.**', null, 'This is the part that will match'));
     // Matches everything except event type.
     $this->assertFalse($emailLogPlugin->existsByAssoc(ASSOC_TYPE_SUBMISSION, 1, '*****@*****.**', 2, 'This is the part that will match'));
     // Matches everything except body.
     $this->assertFalse($emailLogPlugin->existsByAssoc(ASSOC_TYPE_SUBMISSION, 1, '*****@*****.**', 2, 'There is no email with a body like this'));
     // All should match.
     $this->assertTrue($emailLogPlugin->existsByAssoc(ASSOC_TYPE_SUBMISSION, 1, '*****@*****.**', 1, 'This is the part that will match'));
 }