From 2d9b0069ff03f01d44c0dcf2e26d6ffe63cec7b1 Mon Sep 17 00:00:00 2001
From: John Bintz
Date: Sun, 29 Nov 2009 14:02:38 -0500
Subject: [PATCH] working on tests and code coverage
---
quick-audio-embed.php | 33 +++++++++++++++++++------
test/QuickAudioEmbedTest.php | 47 ++++++++++++++++++++++++++++++++++++
2 files changed, 73 insertions(+), 7 deletions(-)
diff --git a/quick-audio-embed.php b/quick-audio-embed.php
index 54a2569..a9baba9 100644
--- a/quick-audio-embed.php
+++ b/quick-audio-embed.php
@@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class QuickAudioEmbed {
+ // @codeCoverageIgnoreStart
function init() {
$qae = new QuickAudioEmbed();
$qae->load();
@@ -42,11 +43,27 @@ class QuickAudioEmbed {
}
}
- function load() {
+ function plugins_loaded() {
+ if (version_compare(PHP_VERSION, '5.0.0') === 1) {
+ add_action('init', array('QuickAudioEmbed', 'init'));
+ } else {
+ add_action('admin_notices', array('QuickAudioEmbed', 'admin_notices'));
+ }
+ }
+
+ function admin_notices() {
+ deactivate_plugins(plugin_basename(__FILE__)); ?>
+
+ settings = array(
'dimensions' => '300x50'
);
+ }
+ // @codeCoverageIgnoreEnd
+ function load() {
$options = get_option('quick-audio-embed-settings');
if (is_array($options)) {
$this->settings = array_merge($this->settings, $options);
@@ -86,16 +103,13 @@ class QuickAudioEmbed {
return null;
}
+ // @codeCoverageIgnoreStart
function admin_menu() {
add_settings_section('quick-audio-embed', __('Quick Audio Embed', 'quick-audio-embed'), array(&$this, 'media_settings'), 'media');
add_settings_field('qae-dimensions', __('Dimensions', 'quick-audio-embed'), array(&$this, 'qae_dimensions'), 'media', 'quick-audio-embed');
}
- function the_content($content = '') {
- return preg_replace_callback('#]+href="(?P[^\"]+\.mp3)"[^\>]*>.*#mis', array(&$this, '_the_content_callback'), $content);
- }
-
function media_settings() { ?>
Quick Audio Embed takes any linked-to MP3 file and wraps it in Google Reader's Audio Player.
@@ -107,6 +121,11 @@ class QuickAudioEmbed {
The dimensions of the player as widthxheight: 300x50
]+href="(?P[^\"]+\.mp3)"[^\>]*>.*#mis', array(&$this, '_the_content_callback'), $content);
+ }
function _the_content_callback($matches) {
$dimensions = explode('x', $this->settings['dimensions']);
@@ -124,7 +143,7 @@ class QuickAudioEmbed {
return sprintf('