-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathbeansEditImage.php
More file actions
98 lines (83 loc) · 2.67 KB
/
beansEditImage.php
File metadata and controls
98 lines (83 loc) · 2.67 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
* Tests for beans_edit_image().
*
* @package Beans\Framework\Tests\Integration\API\Image
*
* @since 1.5.0
*/
namespace Beans\Framework\Tests\Integration\API\Image;
use Beans\Framework\Tests\Integration\API\Image\Includes\Image_Test_Case;
require_once __DIR__ . '/includes/class-image-test-case.php';
/**
* Class Tests_BeansEditImage
*
* @package Beans\Framework\Tests\Integration\API\Image
* @group api
* @group api-image
*/
class Tests_BeansEditImage extends Image_Test_Case {
/**
* Path of the fixtures directory.
*
* @var string
*/
protected static $fixtures_dir;
/**
* Set up the test fixture before we start.
*/
public static function setUpBeforeClass() {
parent::setUpBeforeClass();
static::$fixtures_dir = realpath( __DIR__ . '/../fixtures' );
}
/**
* Test beans_edit_image() should return original src when the image does not exist.
*/
public function test_should_return_original_src_when_no_image() {
$src = 'http://example.org/path/does/not/exist/image.jpg';
// Run the tests.
$this->assertFileNotExists( $src );
$this->assertSame( $src, beans_edit_image( $src, [ 'resize' => [ 800, false ] ] ) );
}
/**
* Test beans_edit_image() should return an indexed array with the original src when the image does not exist.
*/
public function test_should_return_indexed_array_with_original_src_when_no_image() {
$src = 'http://example.org/path/does/not/exist/image.jpg';
// Run the tests.
$this->assertFileNotExists( $src );
$this->assertSame(
[ $src, null, null ],
beans_edit_image( $src, [ 'resize' => [ 800, false ] ], ARRAY_N )
);
}
/**
* Test beans_edit_image() should return an object with the original src when the image does not exist.
*/
public function test_should_return_object_with_original_src_when_no_image() {
$src = 'http://example.org/path/does/not/exist/image.jpg';
// Run the tests.
$this->assertFileNotExists( $src );
$image_info = beans_edit_image( $src, [ 'resize' => [ 800, false ] ], OBJECT );
$this->assertInstanceOf( 'stdClass', $image_info );
$this->assertSame( $src, $image_info->src );
$this->assertNull( $image_info->width );
$this->assertNull( $image_info->height );
}
/**
* Test beans_edit_image() should return an associative array with the original src when the image does not exist.
*/
public function test_should_return_associative_array_with_original_src_when_no_image() {
$src = 'http://example.org/path/does/not/exist/image.jpg';
// Run the tests.
$this->assertFileNotExists( $src );
$this->assertSame(
[
'src' => $src,
'width' => null,
'height' => null,
],
beans_edit_image( $src, [ 'resize' => [ 800, false ] ], ARRAY_A )
);
}
}