Skip to content

Commit

Permalink
Switch to PHP 8.0 pipeline (#19)
Browse files Browse the repository at this point in the history
* Remove PMC specific feature, fix test cause by WP 6.0 upgrade
* Update test to align with PHP 8.0
* Add condition to test is_amp_endpoint
  • Loading branch information
hauvong authored Oct 28, 2022
1 parent 3284400 commit 4bd0f38
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: "3.5"
services:

pipeline-test:
image: penskemediacorporation/pipeline-test:vipgo
image: penskemediacorporation/pipeline-test:php8
env_file: docker-compose.env
restart: on-failure
command: start-pipeline-build-test
Expand Down
2 changes: 1 addition & 1 deletion src/mocks/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function __call( $name, array $arguments ) {
}
return $this;
}
throw new \Error( sprintf( 'Call to un known function "%s"', $name ) );
throw new \Error( sprintf( 'Call to unknown function "%s"', $name ) );
}

}
16 changes: 8 additions & 8 deletions tests/test-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ public function test_base() { // phpcs:ignore.
$this->assert_plugin_loaded( My_Dummy_Plugin::class );
$this->remove_added_uploads();

$this->assertContains(
$this->assertStringContainsString(
'Closure()',
$this->_sprint_callback(
function () {
}
)
);
$this->assertContains( 'Array', $this->_sprint_callback( [] ) );
$this->assertStringContainsString( 'Array', $this->_sprint_callback( [] ) );

}

Expand Down Expand Up @@ -174,7 +174,7 @@ function () {
}

$this->assertNotEmpty( $exception );
$this->assertContains( 'Expecting no call to wp_redirect', $exception->getMessage() );
$this->assertStringContainsString( 'Expecting no call to wp_redirect', $exception->getMessage() );
}

/**
Expand Down Expand Up @@ -448,7 +448,7 @@ function () {
$exception = $e;
}
$this->assertNotEmpty( $exception );
$this->assertContains( 'Must provide a valid list of $hooks to validate', $exception->getMessage() );
$this->assertStringContainsString( 'Must provide a valid list of $hooks to validate', $exception->getMessage() );

$exception = null;
try {
Expand All @@ -457,7 +457,7 @@ function () {
$exception = $e;
}
$this->assertNotEmpty( $exception );
$this->assertContains( 'Must provide a valid class, instance, or closure', $exception->getMessage() );
$this->assertStringContainsString( 'Must provide a valid class, instance, or closure', $exception->getMessage() );

$exception = null;
try {
Expand All @@ -466,7 +466,7 @@ function () {
$exception = $e;
}
$this->assertNotEmpty( $exception );
$this->assertContains( 'Class not found null', $exception->getMessage() );
$this->assertStringContainsString( 'Class not found null', $exception->getMessage() );

$exception = null;
try {
Expand All @@ -475,7 +475,7 @@ function () {
$exception = $e;
}
$this->assertNotEmpty( $exception );
$this->assertContains( sprintf( 'Class must implement singleton function %s::get_instance()', self::class ), $exception->getMessage() );
$this->assertStringContainsString( sprintf( 'Class must implement singleton function %s::get_instance()', self::class ), $exception->getMessage() );

$this->assert_hooks( $filters, Test_Construct::class );
$this->assert_hooks( $filters, Test_Construct::get_instance() );
Expand All @@ -502,7 +502,7 @@ function () {
$exception = $e;
}
$this->assertNotEmpty( $exception );
$this->assertContains( 'Must provide a valid list of $hooks to validate', $exception->getMessage() );
$this->assertStringContainsString( 'Must provide a valid list of $hooks to validate', $exception->getMessage() );

$filters['run_custom_method']['run_custom_method'] = 10;
$this->assert_hooks(
Expand Down
2 changes: 1 addition & 1 deletion tests/test-mock-http.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function test_mock_requests() {
$this->assertTrue( isset( $mocks['https://ifconfig.me/once'] ) );
$result = \Requests::get( 'https://ifconfig.me/once' );
$this->assertTrue( $result->success );
$this->assertContains( 'once', $result->body );
$this->assertStringContainsString( 'once', $result->body );

$result = \Requests::get( 'https://ifconfig.me/once' );
$this->assertTrue( $result->success );
Expand Down
10 changes: 6 additions & 4 deletions tests/test-mock-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ public function test_mock() {
$this->assertTrue( has_category( 'category1', $post ) );

// Test is_amp endpoint
$this->mock->post()->is_amp( true );
$this->assertTrue( is_amp_endpoint() );
$this->mock->post()->is_amp( false );
$this->assertFalse( is_amp_endpoint() );
if ( function_exists( 'is_amp_endpoint' ) ) {
$this->mock->post()->is_amp( true );
$this->assertTrue( is_amp_endpoint() );
$this->mock->post()->is_amp( false );
$this->assertFalse( is_amp_endpoint() );
}

$post = $this->mock->post( [ 'post_title' => 'attachment', 'post_type' => 'attachment' ])->get();
$this->assertTrue( is_single() );
Expand Down
2 changes: 1 addition & 1 deletion tests/test-mock-user.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function test_mock() {
$this->assertTrue( is_admin() );
$this->assertInstanceOf( \WP_User::class, $user );
$this->assertSame( wp_get_current_user(), $user );
$this->assertContains( 'administrator', $user->roles);
$this->assertContains( 'administrator', $user->roles );

$user = $this->mock->user( 'admin', 'custom-screen' )->get();
$this->assertTrue( is_admin() );
Expand Down
2 changes: 2 additions & 0 deletions tests/test-utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function setUp():void {
self::$ignore_files = true;
parent::setUp();

remove_all_filters( 'pmc_unit_test__http_mocks' );

add_filter( 'http_request_host_is_external', '__return_true' );

/**
Expand Down

0 comments on commit 4bd0f38

Please sign in to comment.