You are here

public function UbercartFileTestCase::testFilePurchaseCheckout in Ubercart 7.3

File

uc_file/tests/uc_file.test, line 36
File download product feature tests.

Class

UbercartFileTestCase
Tests the file download purchase functionality.

Code

public function testFilePurchaseCheckout() {

  // Add file download feature to the test product.
  $filename = $this
    ->uploadTestFile();
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalPost('node/' . $this->product->nid . '/edit/features', array(
    'feature' => 'file',
  ), t('Add'));
  $edit = array(
    'uc_file_model' => '',
    'uc_file_filename' => $filename,
  );
  $this
    ->drupalPost(NULL, $edit, t('Save feature'));

  // Check out with the test product.
  $this
    ->drupalPost('node/' . $this->product->nid, array(), t('Add to cart'));
  $order = $this
    ->checkout();
  uc_payment_enter($order->order_id, 'other', $order->order_total);

  // Test that the file was granted.
  $this
    ->drupalGet('user/' . $order->uid . '/purchased-files');
  $this
    ->assertText($filename, 'File found in list of purchased files.');

  // Test that the email is correct.
  $mail = $this
    ->findMail('/File Downloads for Order# ' . preg_quote($order->order_id) . '/');

  // Delete the user.
  user_delete($order->uid);

  // Run cron to ensure deleted users are handled correctly.
  $this
    ->drupalLogout();
  $this
    ->cronRun();
}