You are here

function ActivityAPITest::testActivityGetInfo in Activity 5.3

Same name and namespace in other branches
  1. 5.4 tests/ActivityAPITests.test \ActivityAPITest::testActivityGetInfo()
  2. 5.2 tests/ActivityAPITests.test \ActivityAPITest::testActivityGetInfo()
  3. 6 tests/ActivityAPITests.test \ActivityAPITest::testActivityGetInfo()

File

tests/ActivityAPITests.test, line 31

Class

ActivityAPITest

Code

function testActivityGetInfo() {
  $this
    ->drupalModuleEnable('nodeactivity');

  // Assert that the api function activity_get_info exists
  if ($this
    ->assertTrue(function_exists('activity_get_info'), '%s ' . t('Asserting that activity_get_info exists'))) {

    // It exists. Let's call it.
    $info = activity_get_info();

    // The API's contract is to return an array.
    $this
      ->assertTrue(is_array($info), '%s ' . t('Asserting that return value is an array.'));

    // Assert that all of the modules we're looking for are in the array.
    $this
      ->assertTrue(in_array('nodeactivity', array_keys($info)), '%s ' . t('Asserting that nodeactivity is one of the returned values.'));

    // Assert that all three parts of the array are present and the right type.
    // Expecting ops, types, roles all to be arrays
    $this
      ->assertTrue(is_array($info['nodeactivity']['ops']), '%s ' . t('Expecting ops, types, roles all to be arrays'));
    $this
      ->assertTrue(is_array($info['nodeactivity']['types']), '%s ' . t('Expecting ops, types, roles all to be arrays'));
    $this
      ->assertTrue(is_array($info['nodeactivity']['roles']), '%s ' . t('Expecting ops, types, roles all to be arrays'));
  }
}