Skip to content

Commit

Permalink
set up test
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Jan 21, 2025
1 parent 9d1f8d3 commit 453e4fe
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions Tests/Unit/inc/functions/Attachments/ImagifyAttachmentMetadata.php
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;

Check failure on line 12 in Tests/Unit/inc/functions/Attachments/ImagifyAttachmentMetadata.php

View workflow job for this annotation

GitHub Actions / WPRocket lint with PHP Stan. PHP 8.2 on ubuntu-latest.

Property functions\Attachments\Test_magifyAttachmentMetadata::$attachment_id is unused.

public function setUp(): void {
parent::setUp();
global $wpdb;

$this->wpdb = $this->getMockBuilder('wpdb')

Check failure on line 18 in Tests/Unit/inc/functions/Attachments/ImagifyAttachmentMetadata.php

View workflow job for this annotation

GitHub Actions / WPRocket lint with PHP Stan. PHP 8.2 on ubuntu-latest.

Access to an undefined property functions\Attachments\Test_magifyAttachmentMetadata::$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

View workflow job for this annotation

GitHub Actions / WPRocket lint with PHP Stan. PHP 8.2 on ubuntu-latest.

Access to an undefined property functions\Attachments\Test_magifyAttachmentMetadata::$mime_types.
$this->statuses = "'inherit', 'private'";

Check failure on line 27 in Tests/Unit/inc/functions/Attachments/ImagifyAttachmentMetadata.php

View workflow job for this annotation

GitHub Actions / WPRocket lint with PHP Stan. PHP 8.2 on ubuntu-latest.

Access to an undefined property functions\Attachments\Test_magifyAttachmentMetadata::$statuses.
$this->exist_clause = "";

Check failure on line 28 in Tests/Unit/inc/functions/Attachments/ImagifyAttachmentMetadata.php

View workflow job for this annotation

GitHub Actions / WPRocket lint with PHP Stan. PHP 8.2 on ubuntu-latest.

Access to an undefined property functions\Attachments\Test_magifyAttachmentMetadata::$exist_clause.

$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())

Check failure on line 44 in Tests/Unit/inc/functions/Attachments/ImagifyAttachmentMetadata.php

View workflow job for this annotation

GitHub Actions / WPRocket lint with PHP Stan. PHP 8.2 on ubuntu-latest.

Access to an undefined property functions\Attachments\Test_magifyAttachmentMetadata::$wpdb.
->method('get_var')
->willReturn(1);

$result = imagify_has_attachments_without_required_metadata();
$this->assertTrue($result);
}
}

0 comments on commit 453e4fe

Please sign in to comment.