-
Notifications
You must be signed in to change notification settings - Fork 0
/
scribd_filter.test
85 lines (76 loc) · 3.06 KB
/
scribd_filter.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/**
* @file
* Test class.
*/
class ScribdFilterTestCase extends DrupalWebTestCase {
protected $profile = 'testing';
protected $user;
protected $contentType;
protected $scribd_document_id = '50662460';
protected $scribd_access_key = 'key-1pf4xhwewj9fj8m54q0l';
protected $scribd_mode = 'scroll';
public static function getInfo() {
return array(
'name' => t('Scribd Filter Tests'),
'description' => t('Tests for the Scribd Filter module.'),
'group' => t('Input filters'),
);
}
/**
* Setup stuff.
*/
public function setUp() {
parent::setUp('scribd_filter');
// Create a content type to test the filters (with default format)
$this->contentType = $this->drupalCreateContentType();
// Create and log in our user.
$this->user = $this->drupalCreateUser(array(
'create ' . $this->contentType->type . ' content',
'administer filters',
));
$this->drupalLogin($this->user);
}
/**
* Testing the embedded scribd option.
*/
function testEmbedStyle() {
// Turn on our input filter and set the option to embed.
$edit = array(
'filters[scribd_filter][status]' => 1,
'filters[scribd_filter][settings][scribd_filter_display_method]' => 'embed',
);
$this->drupalPost('admin/config/content/formats/plain_text', $edit, t('Save configuration'));
// Create a test node
$langcode = LANGUAGE_NONE;
$edit = array(
"title" => $this->randomName(),
"body[$langcode][0][value]" => 'Hello! [scribd id=' . $this->scribd_document_id . ' key=' . $this->scribd_access_key . ']',
);
$result = $this->drupalPost('node/add/' . $this->contentType->type, $edit, t('Save'));
$this->assertResponse(200);
$this->assertRaw("Hello! ");
$this->assertRaw('<iframe class="scribd_iframe_embed" src="//www.scribd.com/embeds/' . $this->scribd_document_id . '/content?start_page=1&view_mode=' . $this->scribd_mode . '&access_key=' . $this->scribd_access_key . '" data-auto-height="true" data-aspect-ratio="1.44339622641509" scrolling="no" id="doc_' . $this->scribd_document_id . '" width="100%" height="600" frameborder="0"></iframe>');
}
/**
* Testing the link option.
*/
function testLinkStyle() {
// Turn on our input filter and set the option to link.
$edit = array(
'filters[scribd_filter][status]' => 1,
'filters[scribd_filter][settings][scribd_filter_display_method]' => 'link',
);
$this->drupalPost('admin/config/content/formats/plain_text', $edit, t('Save configuration'));
// Create a test node
$langcode = LANGUAGE_NONE;
$edit = array(
"title" => $this->randomName(),
"body[$langcode][0][value]" => 'Hello! [scribd id=' . $this->scribd_document_id . ' key=' . $this->scribd_access_key . ']',
);
$result = $this->drupalPost('node/add/' . $this->contentType->type, $edit, t('Save'));
$this->assertResponse(200);
$url = 'http://www.scribd.com/full/' . $this->scribd_document_id . '?access_key=' . $this->scribd_access_key;
$this->assertRaw('Hello! <a href="' . $url . '">' . $url . '</a>');
}
}