Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move factory set up to protected setter instead of #12

Open
berkod opened this issue Sep 21, 2022 · 1 comment
Open

Move factory set up to protected setter instead of #12

berkod opened this issue Sep 21, 2022 · 1 comment

Comments

@berkod
Copy link
Contributor

berkod commented Sep 21, 2022

I think we need to move the factory set up to a different setter for php8. It's throwing errors in php8 pipelines. Not 100% sure if that's the right way to fix this.

public function set_test_object( object $test_object ) : self {
$this->_test_object = $test_object;
$this->_test_factory = $test_object->factory;
return $this;

1) Test_Class_Plugin::test_filter_wpcom_legacy_redirector_redirect_status
Error: Cannot access protected property Test_Class_Plugin::$factory

/home/runner/work/pmc-plugins/pmc-plugins/pmc-unit-test/vendor/pmc/unit-test/src/mocks/factory.php:21
/home/runner/work/pmc-plugins/pmc-plugins/pmc-unit-test/vendor/pmc/unit-test/src/traits/base.php:110
/home/runner/work/pmc-plugins/pmc-plugins/pmc-unit-test/vendor/pmc/unit-test/src/traits/base.php:134
/home/runner/work/pmc-plugins/pmc-plugins/pmc-410/tests/classes/test-class-plugin.php:21

2) Test_Class_Plugin::test_maybe_set_http_status_410
Error: Cannot access protected property Test_Class_Plugin::$factory

/home/runner/work/pmc-plugins/pmc-plugins/pmc-unit-test/vendor/pmc/unit-test/src/mocks/factory.php:21
/home/runner/work/pmc-plugins/pmc-plugins/pmc-unit-test/vendor/pmc/unit-test/src/traits/base.php:110
/home/runner/work/pmc-plugins/pmc-plugins/pmc-unit-test/vendor/pmc/unit-test/src/traits/base.php:134
/home/runner/work/pmc-plugins/pmc-plugins/pmc-410/tests/classes/test-class-plugin.php:21
@hauvong
Copy link
Contributor

hauvong commented Sep 21, 2022

Not related to PHP8. This is caused by WP 6.1.0 deprecating the $this->factory access documented here.

https://github.com/WordPress/wordpress-develop/blob/trunk/tests/phpunit/includes/abstract-testcase.php#L29

This can be quickly patch like this:
eg.

		$this->_test_factory = Utility::invoke_hidden_static_method( WP_UnitTestCase_Base::class, 'factory' );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants