Пример #1
0
 /**
  * Test that calling the mollom action function triggers the unpublish of
  * nodes and marking as spam.
  */
 function testNodeActions()
 {
     $node_storage = \Drupal::entityManager()->getStorage('node');
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('admin/content');
     $this->assertOption('edit-action', 'mollom_node_unpublish_action');
     $contentIds = [];
     $nodes = $node_storage->loadMultiple();
     $i = 0;
     $edit = ['action' => 'mollom_node_unpublish_action'];
     /* @var $node \Drupal\node\NodeInterface */
     foreach ($nodes as $node) {
         $edit['node_bulk_form[' . $i . ']'] = TRUE;
         $this->assertTrue($node->isPublished(), 'Initial node is published.');
         $data = ResponseDataStorage::loadByEntity('node', $node->id());
         $contentIds[] = $data->contentId;
         $i++;
     }
     $this->drupalPostForm(NULL, $edit, t('Apply'));
     // Verify that all nodes are now unpublished.
     $node_storage->resetCache();
     $nodes = $node_storage->loadMultiple();
     foreach ($nodes as $node) {
         $this->assertFalse($node->isPublished(), 'Node is now unpublished.');
         $server = $this->getServerRecord('feedback');
         $this->assertTrue(in_array($server['contentId'], $contentIds));
         $this->assertEqual($server['source'], 'mollom_action_unpublish_node');
         $this->assertEqual($server['reason'], 'spam');
         $this->assertEqual($server['type'], 'moderate');
     }
 }
Пример #2
0
 /**
  * Assert that no Mollom session data exists for a certain entity.
  */
 protected function assertNoMollomData($entity, $id)
 {
     $data = ResponseDataStorage::loadByEntity($entity, $id);
     $this->assertFalse($data, t('No Mollom session data exists for %entity @id.', array('%entity' => $entity, '@id' => $id)));
 }
Пример #3
0
 /**
  * Sends feedback for multiple Mollom session data records.
  *
  * @param $entity
  *   The entity type to send feedback for.
  * @param $ids
  *   An array of entity ids to send feedback for.
  * @param $feedback
  *   The feedback reason for reporting content.
  * @param $type
  *   The type of feedback, one of 'moderate' or 'flag'.
  * @param $source
  *   An optional single word string identifier for the user interface source.
  *   This is tracked along with the feedback to provide a more complete picture
  *   of how feedback is used and submitted on the site.
  */
 public static function sendFeedbackMultiple($entity, array $ids, $feedback, $type = 'moderate', $source = 'mollom_data_report_multiple')
 {
     $return = TRUE;
     foreach ($ids as $id) {
         // Load the Mollom session data.
         $data = ResponseDataStorage::loadByEntity($entity, $id);
         if (empty($data)) {
             continue;
         }
         // Send feedback, if we have session data.
         if (!empty($data->contentId) || !empty($data->captchaId)) {
             $result = self::sendFeedbackToMollom($data, $feedback, $type, $source);
             $return = $return && $result;
         }
         $data->moderate = 0;
         ResponseDataStorage::save($data);
     }
     return $return;
 }