You are here

public function RestfulDbQueryTestCase::testColumnForQuery in RESTful 7

Test using joins and filters for the DB query data provider.

File

tests/RestfulDbQueryTestCase.test, line 222
Contains RestfulDbQueryTestCase.

Class

RestfulDbQueryTestCase
@file Contains RestfulDbQueryTestCase.

Code

public function testColumnForQuery() {
  $user1 = $this
    ->drupalCreateUser();
  $user2 = $this
    ->drupalCreateUser();
  $settings = array(
    'type' => 'article',
    'uid' => $user1->uid,
  );
  $node1 = $this
    ->drupalCreateNode($settings);
  $settings['uid'] = $user2->uid;
  $node2 = $this
    ->drupalCreateNode($settings);
  $handler = restful_get_restful_handler('node_user');
  $request = array(
    'filter' => array(
      'author' => $user1->name,
    ),
  );
  $result = $handler
    ->get('', $request);
  $this
    ->assertEqual(count($result), 1, 'Filter on a joined table returned correct items.');
  $this
    ->assertEqual($result[0]['author'], $user1->name, 'Joined column appears correctly.');
  $this
    ->assertEqual($result[0]['id'], $node1->nid, 'Correct item was filtered.');
}