-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathphpword.test
67 lines (51 loc) · 1.48 KB
/
phpword.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
<?php
/**
* Simpletest unit tests.
*/
class PhpWordTest extends DrupalWebTestCase {
public function getInfo() {
return array(
'name' => t('Print a test page'),
'desc' => t('Instantiates, writes to and saves a PhpWord document.'),
'group' => t('PhpWord'),
);
}
public function setUp() {
parent::setUp(array('phpword'));
$this->privileged_user = $this->drupalCreateUser(array(
'administer phpword',
));
$this->drupalLogin($this->privileged_user);
}
/**
* Create a test document to check that PhpWord is working as expected.
*
* @return object
* An instantiated PhpWord object.
*/
public function testPhpWord() {
$phpword = phpword();
$section = $phpword->addSection();
$bigBold = new \PhpOffice\PhpWord\Style\Font();
$bigBold->setBold(true);
$bigBold->setName('Ubuntu');
$bigBold->setSize(40);
$section->addText('Hello Word! :)', $bigBold);
$B = new \PhpOffice\PhpWord\Style\Font();
$B->setColor('ff89cf');
$B->setName('comic sans ms');
$B->setItalic();
$B->setSize(16);
$B->setBgColor('000');
$section->addText(" This should be a delightful colour of pink! ", $B);
$created_file = phpword_save('hello-world.docx');
$message = "Successfully created file $created_file->uri";
if (function_exists('drush_print_r')) {
drush_print_r($message);
}
else {
drupal_set_message($message);
}
$this->assertTrue(TRUE, 'Created!');
}
}