You are here

protected function EntityReferenceHandlersTestCase::assertReferencable in Entity reference 7

3 calls to EntityReferenceHandlersTestCase::assertReferencable()
EntityReferenceHandlersTestCase::testCommentHandler in tests/entityreference.handlers.test
Test the comment-specific overrides of the entity handler.
EntityReferenceHandlersTestCase::testNodeHandler in tests/entityreference.handlers.test
Test the node-specific overrides of the entity handler.
EntityReferenceHandlersTestCase::testUserHandler in tests/entityreference.handlers.test
Test the user-specific overrides of the entity handler.

File

tests/entityreference.handlers.test, line 24
Contains EntityReferenceHandlersTestCase

Class

EntityReferenceHandlersTestCase
Test for Entity Reference handlers.

Code

protected function assertReferencable($field, $tests, $handler_name) {
  $handler = entityreference_get_selection_handler($field);
  foreach ($tests as $test) {
    foreach ($test['arguments'] as $arguments) {
      $result = call_user_func_array(array(
        $handler,
        'getReferencableEntities',
      ), $arguments);
      $this
        ->assertEqual($result, $test['result'], format_string('Valid result set returned by @handler.', array(
        '@handler' => $handler_name,
      )));
      $result = call_user_func_array(array(
        $handler,
        'countReferencableEntities',
      ), $arguments);
      if (!empty($test['result'])) {
        $bundle = key($test['result']);
        $count = count($test['result'][$bundle]);
      }
      else {
        $count = 0;
      }
      $this
        ->assertEqual($result, $count, format_string('Valid count returned by @handler.', array(
        '@handler' => $handler_name,
      )));
    }
  }
}