You are here

public function PMPAPIPullWebTestCase::testPmpAPIEmbargoedThenValid in Public Media Platform API Integration 7

Checks that node is published when it becomes valid.

File

pmpapi_pull/tests/pmpapi_pull.test, line 182

Class

PMPAPIPullWebTestCase
Tests the functionality of the PMPAPI pull module.

Code

public function testPmpAPIEmbargoedThenValid() {
  variable_set('pmpapi_pull_last_validity_check', time() - 100);
  $this
    ->createContentType();

  // Send up a doc (but not a node)
  $valid = new stdClass();
  $now = time();
  $valid->from = pmpapi_convert_timestamp(strtotime('+30 seconds', $now), $now);
  $values = array(
    'profile' => 'story',
    'attributes' => array(
      'valid' => $valid,
      'title' => $this
        ->randomName(20),
    ),
  );
  $doc = pmpapi_send($values);
  $this
    ->assertTrue(is_object($doc), 'Successfully pushed a doc to the PMP.');
  sleep(self::SLEEP_TIME);

  // Pull that (embargoed) doc
  $guid = $doc->attributes->guid;
  pmpapi_pull_pull_doc($guid);
  $node = node_load(1);
  $this
    ->assertTrue(is_object($node), 'Pulled doc and created node.');
  $this
    ->assertFalse($node->status, 'Embargoed node is unpublished.');

  // Wait until doc is valid, and run check function
  sleep(45);
  pmpapi_pull_check_valid_dates();
  $valid_node = node_load(1, NULL, TRUE);
  $this
    ->assertTrue($valid_node->status, 'Now-valid node is published.');
  pmpapi_remove($doc->attributes->guid);
}