Skip to content
Snippets Groups Projects
Commit ff0953e5 authored by Vasili Guruli's avatar Vasili Guruli
Browse files

Merge branch 'feature/minimum-plugin-version-check-demo1' into 'master'

Small fix with plugin name

See merge request !23
parents 091afdc1 3fa300ac
No related branches found
No related tags found
1 merge request!23Small fix with plugin name
Pipeline #10484 passed with stages
in 45 seconds
## [3.2.1] - 2019-11-15 ## [3.2.1] - 2019-11-15
### Fixed ### Fixed
- Fixed plugin version notice - Fixed plugin version notice
- Fixed required plugin name display in admin notices
## [3.2.0] - 2019-11-14 ## [3.2.0] - 2019-11-14
### Added ### Added
......
...@@ -297,7 +297,7 @@ ...@@ -297,7 +297,7 @@
foreach ( $required_plugins as $plugin ) { foreach ( $required_plugins as $plugin ) {
if ( version_compare ( $plugin[ 'Version' ], $plugin[ self::PLUGIN_INFO_APPEND_PLUGIN_DATA ] , '<' ) ) { if ( version_compare ( $plugin[ 'Version' ], $plugin[ self::PLUGIN_INFO_APPEND_PLUGIN_DATA ] , '<' ) ) {
$notices[] = $this->prepare_notice_message( sprintf( __( 'The &#8220;%s&#8221; plugin requires at least %s version of %s to work correctly. Please update it', $this->get_text_domain() ), $notices[] = $this->prepare_notice_message( sprintf( __( 'The &#8220;%s&#8221; plugin requires at least %s version of %s to work correctly. Please update it', $this->get_text_domain() ),
esc_html( $this->plugin_name ), $plugin[ self::PLUGIN_INFO_APPEND_PLUGIN_DATA ], $plugin[ 'Version' ] ) ); esc_html( $this->plugin_name ), $plugin[ self::PLUGIN_INFO_APPEND_PLUGIN_DATA ], $plugin[ 'Name' ] ) );
} }
} }
} }
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
$requirements_checker = new WPDesk_Basic_Requirement_Checker_With_Update_Disable( $requirements_checker = new WPDesk_Basic_Requirement_Checker_With_Update_Disable(
$plugin_file, $plugin_file,
$plugin_name, $plugin_name,
$text_domain, $text_domain,
$requirements['php'], $requirements['php'],
$requirements['wp'] $requirements['wp']
); );
......
<?php <?php
class Test_Basic_Requirement_Checker_Factory extends PHPUnit\Framework\TestCase { class Test_Basic_Requirement_Checker_Factory extends PHPUnit\Framework\TestCase {
public function test_can_create_checker_withn_valid_requirements() { public function test_can_create_checker_withn_valid_requirements() {
$existing_locale = 'pl_PL'; $existing_locale = 'pl_PL';
$requirements = array( $requirements = array(
'php' => '5.6', 'php' => '5.6',
'wp' => '4.5', 'wp' => '4.5',
'plugins' => array( 'plugins' => array(
array( array(
'name' => 'woocommerce/woocommerce.php', 'name' => 'woocommerce/woocommerce.php',
'nice_name' => 'WooCommerce', 'nice_name' => 'WooCommerce',
'version' => '1.0' 'version' => '1.0'
),
), ),
), 'repo_plugins' => array(
'repo_plugins' => array( array(
array( 'name' => 'flexible-checkout-fields/flexible-checkout-fields.php',
'name' => 'flexible-checkout-fields/flexible-checkout-fields.php', 'version' => '1.0',
'version' => '1.0', 'nice_name' => 'Flexible Checkout Fields',
'nice_name' => 'Flexible Checkout Fields', ),
), ),
), );
);
WP_Mock::wpFunction( 'get_locale' )
WP_Mock::wpFunction( 'get_locale' ) ->andReturn( $existing_locale );
->andReturn( $existing_locale );
$factory = new WPDesk_Basic_Requirement_Checker_Factory();
$factory = new WPDesk_Basic_Requirement_Checker_Factory(); $checker = $factory->create_from_requirement_array( 'whatever', 'whatever', $requirements );
$checker = $factory->create_from_requirement_array( 'whatever', 'whatever', $requirements );
WP_Mock::wpFunction( 'get_plugins' )
WP_Mock::wpFunction( 'get_plugins' ) ->andReturn( array() );
->andReturn( array() );
WP_Mock::wpFunction( 'get_option' )
WP_Mock::wpFunction( 'get_option' ) ->withArgs( array( 'active_plugins', array() ) )
->withArgs( array( 'active_plugins', array() ) ) ->andReturn( array() );
->andReturn( array() );
WP_Mock::passthruFunction( 'self_admin_url' );
WP_Mock::passthruFunction( 'self_admin_url' ); WP_Mock::passthruFunction( 'wp_kses' );
WP_Mock::passthruFunction( 'wp_kses' ); WP_Mock::passthruFunction( 'wp_nonce_url' );
WP_Mock::passthruFunction( 'wp_nonce_url' ); WP_Mock::passthruFunction( 'wp_create_nonce' );
WP_Mock::passthruFunction( 'wp_create_nonce' ); WP_Mock::passthruFunction( 'admin_url' );
WP_Mock::passthruFunction( 'admin_url' );
$this->assertFalse( $checker->are_requirements_met(), '2 plugins required and there should be none activated' );
$this->assertFalse( $checker->are_requirements_met(), '2 plugins required and there should be none activated' );
$this->expectOutputRegex( '/Flexible Checkout Fields/' );
$this->expectOutputRegex( '/Flexible Checkout Fields/' ); $this->expectOutputRegex( '/WooCommerce/' );
$this->expectOutputRegex( '/WooCommerce/' ); $checker->handle_render_notices_action();
$checker->handle_render_notices_action(); }
} }
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment