You are here

public function FivestarTestCase::testViewerRatingAjax in Fivestar 7.2

Same name and namespace in other branches
  1. 8 test/fivestar.field.test \FivestarTestCase::testViewerRatingAjax()

Test that users can rate content with exposed widgets.

File

test/fivestar.field.test, line 128
Simpletests for the Fivestar module.

Class

FivestarTestCase
Makes sure fivestar widgets can be created and used.

Code

public function testViewerRatingAjax() {

  // Add a viewer-rated fivestar field to the test_node_type content type.
  $this
    ->createFivestarField(array(
    'widget_type' => 'exposed',
  ));

  // Add a test_node_type to rate.
  $node = $this
    ->drupalCreateNode(array(
    'type' => 'test_node_type',
  ));

  // Rate the test_node_type.
  $this
    ->drupalLogin($this->voterUser);
  $edit = array(
    'vote' => '60',
  );
  $commands = $this
    ->drupalPostAJAX('node/' . $node->nid, $edit, "vote", NULL, array(), array(), "fivestar-custom-widget");
  $expected = array(
    'command' => 'fivestarUpdate',
  );
  $this
    ->assertCommand($commands, $expected, "The fivestarUpdate AJAX command was returned.");
}