You are here

function ShurlyTestCase::testSubmitSameUrlTwice in ShURLy 7

Test that we can submit the same long URL twice in a row and then submit another URL.

File

./shurly.test, line 30
Tests for the Shurly module.

Class

ShurlyTestCase
Shurly tests.

Code

function testSubmitSameUrlTwice() {

  // Sign in.
  $user = $this
    ->drupalCreateUser(array(
    'Create short URLs',
  ));
  $this
    ->drupalLogin($user);
  $this
    ->drupalGet('shurly');

  // Shrink http://example.net/foo and verify it got shrinked.
  $edit = array(
    'long_url' => 'http://example.net/foo',
  );
  $this
    ->drupalPost(NULL, $edit, t('Shrink it!'));
  $this
    ->assertUrlShrinked('http://example.net/foo');

  // Shrink the same url once again.
  $edit = array(
    'long_url' => 'http://example.net/foo',
  );
  $this
    ->drupalPost(NULL, $edit, t('Shrink it!'));

  // Shrink http://example.net/bar and verify it got shrinked.
  $edit = array(
    'long_url' => 'http://example.net/bar',
  );
  $this
    ->drupalPost(NULL, $edit, t('Shrink it!'));
  $this
    ->assertUrlShrinked('http://example.net/bar');
}