public function VideoFieldTestCase::testDeleteVideoFieldItem in Video 7.2
Tests basic behavior for deleting a video from a node
File
- tests/
VideoField.test, line 113 - Tests for the the Video field type
Class
- VideoFieldTestCase
- Tests for the the Video field type
Code
public function testDeleteVideoFieldItem() {
// Build test data
$file = $this
->createFile('file1.mp4');
$node = new stdClass();
$node->uid = $this->user->uid;
$node->type = 'page';
$node->title = 'Test node';
$node->videofield['und'][0] = array(
'fid' => $file->fid,
'dimensions' => '100x60',
);
node_save($node);
$node = node_load($node->nid);
// Quick sanity checks
$queues = $this
->getQueues($file->fid);
$this
->assertEqual(1, count($queues), 'One video_queue entry should be present');
$this
->assertEqual(1, count($this
->getFileUsage($file->fid)), 'There should be one usage entry immediately after saving');
$this
->transcodeVideo($node, $queues[0]->vid, $file->fid);
$tn = $this
->getThumbnailFiles($file->fid);
$conv = $this
->getConvertedFiles($file->fid);
// Delete the file
unset($node->videofield['und'][0]);
node_save($node);
// Check if everything is deleted properly
$this
->assertEqual(0, count($this
->getQueues($file->fid)), 'video_queue entry should be removed');
$this
->assertEqual(0, count($this
->getFileUsage($file->fid)), 'There should be no usage entries after deleting');
$this
->assertEqual(0, count($this
->getThumbnailFiles($file->fid)), 'There should be no thumbnail entries after deleting');
$this
->assertEqual(0, count($this
->getConvertedFiles($file->fid)), 'There should be no converted entries after deleting');
// Check usage for converted video and thumbnails
foreach ($conv + $tn as $df) {
$u = $this
->getFileUsage($df->fid);
$this
->assertEqual(0, count($u), 'There should be no usage entries for derived file ' . $df->fid . ' immediately after saving');
}
}