diff --git a/README.md b/README.md index 62d8dc5..0974c68 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ For example, when you start your plugin by instantiating a new object, you shoul _Example:_ ```php -$updatePhp = new WPUpdatePhp( '5.4.0' ); +$updatePhp = new WPUpdatePhp( '5.6.0' ); if ( $updatePhp->does_it_meet_required_php_version() ) { // Instantiate new object here diff --git a/phpspec.yml b/phpspec.yml new file mode 100644 index 0000000..ccfd7f7 --- /dev/null +++ b/phpspec.yml @@ -0,0 +1 @@ +bootstrap: spec/bootstrap.php \ No newline at end of file diff --git a/spec/WPUP/Minimum/NoticeSpec.php b/spec/WPUP/Minimum/NoticeSpec.php new file mode 100644 index 0000000..c18c59f --- /dev/null +++ b/spec/WPUP/Minimum/NoticeSpec.php @@ -0,0 +1,18 @@ +beConstructedWith('5.4.0', 'Test Plugin'); + } + + function it_adds_plugin_name_to_admin_notice() + { + $this->getNoticeText()->shouldMatch('/Test Plugin/i'); + } +} \ No newline at end of file diff --git a/spec/WPUP/Recommended/NoticeSpec.php b/spec/WPUP/Recommended/NoticeSpec.php new file mode 100644 index 0000000..e8355e4 --- /dev/null +++ b/spec/WPUP/Recommended/NoticeSpec.php @@ -0,0 +1,18 @@ +beConstructedWith('5.4.0', 'Test Plugin'); + } + + function it_adds_plugin_name_to_admin_notice() + { + $this->getNoticeText()->shouldMatch('/Test Plugin/i'); + } +} \ No newline at end of file diff --git a/spec/WPUpdatePhpSpec.php b/spec/WPUpdatePhpSpec.php index 96fdeee..54ccb66 100644 --- a/spec/WPUpdatePhpSpec.php +++ b/spec/WPUpdatePhpSpec.php @@ -1,45 +1,27 @@ beConstructedWith( '5.4.0', '5.3.0' ); - } +use PhpSpec\ObjectBehavior; - function it_can_run_on_minimum_version() { - $this->does_it_meet_required_php_version( '5.4.0' )->shouldReturn( true ); - } +class WPUpdatePhpSpec extends ObjectBehavior { + function let() { + $this->beConstructedWith( '5.4.0', '5.3.0' ); + } - function it_passes_the_recommended_version() { - $this->does_it_meet_recommended_php_version( '5.3.0' )->shouldReturn( true ); - } + function it_can_run_on_minimum_version() { + $this->does_it_meet_required_php_version( '5.4.0' )->shouldReturn( true ); + } - function it_will_not_run_on_old_version() { - $this->does_it_meet_required_php_version( '5.2.4' )->shouldReturn( false ); - } + function it_passes_the_recommended_version() { + $this->does_it_meet_recommended_php_version( '5.3.0' )->shouldReturn( true ); + } - function it_fails_the_recommended_version() { - $this->does_it_meet_recommended_php_version( '5.2.9' )->shouldReturn( false ); - } + function it_will_not_run_on_old_version() { + $this->does_it_meet_required_php_version( '5.2.4' )->shouldReturn( false ); + } - function it_adds_plugin_name_to_admin_notice() { - $this->set_plugin_name( 'Test Plugin' ); - $this->get_admin_notice()->shouldMatch('/Test Plugin/i'); - $this->get_admin_notice( 'recommended' )->shouldMatch('/Test Plugin/i'); - } + function it_fails_the_recommended_version() { + $this->does_it_meet_recommended_php_version( '5.2.9' )->shouldReturn( false ); } } \ No newline at end of file diff --git a/spec/bootstrap.php b/spec/bootstrap.php new file mode 100644 index 0000000..9bc4061 --- /dev/null +++ b/spec/bootstrap.php @@ -0,0 +1,13 @@ +version = $version; + $this->plugin_name = $plugin_name; + } + + public function display() + { + return '
' . $this->plugin_name . ' recommends a PHP version higher than ' . $this->recommended_version . '. Read more information about how you can update.
'; - } else { - return 'This plugin recommends a PHP version higher than ' . $this->recommended_version . '. Read more information about how you can update.
'; - } - } - - if ( ! empty( $this->plugin_name ) ) { - return 'Unfortunately, ' . $this->plugin_name . ' cannot run on PHP versions older than ' . $this->minimum_version . '. Read more information about how you can update.
'; - } else { - return 'Unfortunately, this plugin cannot run on PHP versions older than ' . $this->minimum_version . '. Read more information about how you can update.
'; - } - } - - /** - * Method hooked into admin_notices when minimum required PHP version is not - * available to show this in a notice. - * - * @hook admin_notices - */ - public function minimum_admin_notice() { - echo '