-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCenterTextTest.php
More file actions
69 lines (61 loc) · 2.34 KB
/
CenterTextTest.php
File metadata and controls
69 lines (61 loc) · 2.34 KB
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
<?php
/**
* Tests the functionality of centering text.
* php version 7.3
*
* @category Tests
* @package PosterEditorTest
* @author Anton Lukin <anton@lukin.me>
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
* @link https://github.com/antonlukin/poster-editor
*/
use PHPUnit\Framework\TestCase;
/**
* Tests the functionality of centering text.
* php version 7.3
*
* @category Tests
* @package PosterEditorTest
* @author Anton Lukin <anton@lukin.me>
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
* @link https://github.com/antonlukin/poster-editor
*/
class CenterTextTest extends TestCase
{
/**
* Save and compare rendered image
*
* @return void
*/
public function testRendring()
{
$image = new PosterEditor\PosterEditor();
$image->make(ASSET_PATH . '/images/bridge.jpg')->fit(1200, 630);
$image->grayscale()->brightness(-40);
$image->text(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat Lorem ipsum dolor sit amet', // phpcs:ignore
array(
'x' => 100,
'y' => 100,
'width' => 1000, // Calculate width for nulled values
'height' => 400, // Calculate height for nulled values
'horizontal' => 'center', // Can be left/right/center/justify
'vertical' => 'center', // Can be top/center/bottom/justify
'fontpath' => ASSET_PATH. '/fonts/opensans.ttf',
'fontsize' => 24,
'lineheight' => 1.75,
'color' => '#ffffff',
'opacity' => 0,
)
);
$generatedPath = __DIR__ . '/output/center.jpg';
$referencePath = __DIR__ . '/references/center.jpg';
$image->save($generatedPath);
// Compare file checksums
$generatedHash = md5_file($generatedPath);
$referenceHash = md5_file($referencePath);
$this->assertEquals($referenceHash, $generatedHash);
// Remove the temporary file after verification
unlink($generatedPath);
}
}