Assets/Block settings: Only lookup page if ID > 0 (https://github.com/woocommerce/woocommerce-blocks/pull/2369)

* Only lookup page if ID > 0

* Check for valid post

* Maybe fix test path
This commit is contained in:
Mike Jolley 2020-05-01 11:02:20 +01:00 committed by GitHub
parent bf8cff6f50
commit a640a230ca
2 changed files with 3 additions and 3 deletions

View File

@ -163,10 +163,10 @@ class Assets {
* @return array * @return array
*/ */
protected static function format_page_resource( $page ) { protected static function format_page_resource( $page ) {
if ( is_numeric( $page ) ) { if ( is_numeric( $page ) && $page > 0 ) {
$page = get_post( $page ); $page = get_post( $page );
} }
if ( ! $page ) { if ( ! is_a( $page, '\WP_Post' ) ) {
return [ return [
'id' => 0, 'id' => 0,
'title' => '', 'title' => '',

View File

@ -56,7 +56,7 @@ function wc_blocks_install() {
* Adds WooCommerce testing framework classes. * Adds WooCommerce testing framework classes.
*/ */
function wc_test_includes() { function wc_test_includes() {
$wc_tests_framework_base_dir = wc_dir() . '/tests'; $wc_tests_framework_base_dir = wc_dir() . '/tests/legacy';
// WooCommerce test classes. // WooCommerce test classes.
// Framework. // Framework.
require_once $wc_tests_framework_base_dir . '/framework/class-wc-unit-test-factory.php'; require_once $wc_tests_framework_base_dir . '/framework/class-wc-unit-test-factory.php';