-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
Tests/Unit/inc/functions/Attachments/ImagifyAttachmentMetadata.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace functions\Attachments; | ||
|
||
use Imagify\Tests\Unit\TestCase; | ||
use Brain\Monkey\{Filters, Functions}; | ||
use Imagify_DB; | ||
use Mockery; | ||
use wpdb; | ||
|
||
class Test_magifyAttachmentMetadata extends TestCase { | ||
private $attachment_id; | ||
|
||
public function setUp(): void { | ||
parent::setUp(); | ||
global $wpdb; | ||
|
||
$this->wpdb = $this->getMockBuilder('wpdb') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$this->wpdb->posts = 'wp_posts'; | ||
$wpdb = $this->wpdb; | ||
|
||
$imagify_db = Mockery::mock( Imagify_DB::class ); | ||
|
||
$this->mime_types = "'image/jpeg', 'image/png'"; | ||
Check failure on line 26 in Tests/Unit/inc/functions/Attachments/ImagifyAttachmentMetadata.php
|
||
$this->statuses = "'inherit', 'private'"; | ||
Check failure on line 27 in Tests/Unit/inc/functions/Attachments/ImagifyAttachmentMetadata.php
|
||
$this->exist_clause = ""; | ||
Check failure on line 28 in Tests/Unit/inc/functions/Attachments/ImagifyAttachmentMetadata.php
|
||
|
||
$imagify_db->shouldReceive('get_mime_types') | ||
->andReturn($this->mime_types); | ||
$imagify_db->shouldReceive('get_post_statuses') | ||
->andReturn($this->statuses); | ||
$imagify_db->shouldReceive('get_required_wp_metadata_exist_clause') | ||
->andReturn($this->exist_clause); | ||
|
||
require_once IMAGIFY_PLUGIN_ROOT . 'inc/functions/attachments.php'; | ||
} | ||
|
||
|
||
|
||
public function testShouldReturnSanitizedKey() | ||
{ | ||
$this->wpdb->expects($this->once()) | ||
->method('get_var') | ||
->willReturn(1); | ||
|
||
$result = imagify_has_attachments_without_required_metadata(); | ||
$this->assertTrue($result); | ||
} | ||
} |