You are here

public function KalturaUploadTestCase::testNotifications in Kaltura 7.3

Same name and namespace in other branches
  1. 7.2 tests/kaltura_notification.test \KalturaUploadTestCase::testNotifications()

File

tests/kaltura_notification.test, line 27
Tests functionality for notifications.

Class

KalturaUploadTestCase
Ensure that adding partner info works properly.

Code

public function testNotifications() {
  $this
    ->drupalGet('admin/config/media/kaltura');
  $edit['first_name'] = 'name';
  $edit['last_name'] = 'last';
  $edit['email'] = $this
    ->randomname(16) . '@example.com';
  $edit['phone'] = '111111111';
  $edit['company'] = 'autotest';
  $edit['title'] = 'autotestbot';
  $edit['vertical'] = 'Media';
  $edit['country'] = 'IL';
  $edit['would_you_like_to_be_contacted'] = 'no';
  $edit['terms'] = TRUE;
  $this
    ->drupalPost(NULL, $edit, t('submit'));
  $this
    ->assertText(t('Congratulations!'), t('Make sure instaltion is complate'));
  $pid = variable_get('kaltura_partner_id', 'error');
  $path = drupal_get_path('module', 'kaltura') . '/tests/test.flv';
  $helpers = new KalturaHelpers();
  $kaltura_client = $helpers
    ->getKalturaClient(TRUE);
  $token = $kaltura_client->baseEntry
    ->upload($path);
  $entry = new KalturaBaseEntry();
  $entry->name = $this
    ->randomname();
  $res = $kaltura_client->baseEntry
    ->addFromUploadedFile($entry, $token, NULL);
  $eid = $res->id;
  $rows = db_select('node_kaltura', 'n')
    ->fields('n', array(
    'kaltura_entryid',
  ))
    ->condition('kaltura_entryid', $eid, '=')
    ->countQuery()
    ->execute()
    ->fetchField();
  $this
    ->assertEqual($rows, 1, t('check add entry notication'));

  // Change metadata.
  // Change title.
  $en = new KalturaBaseEntry();
  $name = $this
    ->randomname();
  $en->name = $name;
  $res = $kaltura_client->baseEntry
    ->update($eid, $en);
  $ename = db_select('node_kaltura', 'n')
    ->fields('n', array(
    'kaltura_title',
  ))
    ->condition('kaltura_entryid', $eid, '=')
    ->execute()
    ->fetchField();
  $this
    ->assertEqual($ename, $name, t('check change title notification'));

  // Change tags.
  $tags = $this
    ->randomname();
  $en->tags = $tags;
  $res = $kaltura_client->baseEntry
    ->update($eid, $en);
  $etags = db_select('node_kaltura', 'n')
    ->fields('n', array(
    'kaltura_tags',
  ))
    ->condition('kaltura_entryid', $eid, '=')
    ->execute()
    ->fetchField();
  $this
    ->assertEqual($etags, $tags, t('check change tags notification'));

  // Change description.
  $desc = $this
    ->randomname(32);
  $en->description = $desc;
  $res = $kaltura_client->baseEntry
    ->update($eid, $en);
  $edesc = db_select('node_kaltura', 'n')
    ->fields('n', array(
    'kaltura_description',
  ))
    ->condition('kaltura_entryid', $eid, '=')
    ->execute()
    ->fetchField();
  $this
    ->assertEqual($edesc, $desc, t('check change description notification'));
}