mirror of
https://github.com/10h30/wp-strava.git
synced 2026-07-11 18:56:18 +09:00
Scaffolded unit tests
This commit is contained in:
+3
-1
@@ -5,6 +5,8 @@
|
||||
"php": ">=5.2.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"wp-coding-standards/wpcs": "~0.14"
|
||||
"wp-coding-standards/wpcs": "1.*",
|
||||
"phpunit/phpunit": "^6",
|
||||
"10up/wp_mock": "0.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Autoloads files with classes when needed.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @param string $class_name Name of the class being requested.
|
||||
* @return void
|
||||
*/
|
||||
function wpstrava_autoload_classes( $class_name ) {
|
||||
$parts = explode( '_', $class_name );
|
||||
|
||||
// If our class doesn't have our namespace, don't load it.
|
||||
if ( empty( $parts[0] ) || 'WPStrava' !== $parts[0] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// @TODO Add directory searching if they get created.
|
||||
$file = WPSTRAVA_PLUGIN_DIR . '/lib/' . implode( '/', $parts ) . '.php';
|
||||
if ( file_exists( $file ) ) {
|
||||
include_once $file;
|
||||
}
|
||||
}
|
||||
spl_autoload_register( 'wpstrava_autoload_classes' );
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.3/phpunit.xsd"
|
||||
bootstrap="./tests/bootstrap.php"
|
||||
colors="true"
|
||||
forceCoversAnnotation="true"
|
||||
beStrictAboutCoversAnnotation="true"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
beStrictAboutTodoAnnotatedTests="true"
|
||||
verbose="true">
|
||||
<testsuites>
|
||||
<testsuite name="default">
|
||||
<directory suffix="Test.php">tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">lib</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
use \WP_Mock\Tools\TestCase;
|
||||
|
||||
class WPStrava_SOMEnglishTest extends TestCase {
|
||||
|
||||
public function test_true() {
|
||||
$som = new WPStrava_SOMEnglish();
|
||||
$this->assertInstanceOf( 'WPStrava_SOMEnglish', $som );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'WPSTRAVA_PLUGIN_DIR' ) ) define( 'WPSTRAVA_PLUGIN_DIR', dirname( __FILE__ ) . '/../' );
|
||||
require_once dirname( __FILE__ ) . '/../lib/autoload.php';
|
||||
|
||||
WP_Mock::bootstrap();
|
||||
+4
-25
@@ -3,7 +3,7 @@
|
||||
* Plugin Name: WP Strava
|
||||
* Plugin URI: https://wordpress.org/plugins/wp-strava/
|
||||
* Description: Show your strava.com activity on your WordPress site. Some Icons are Copyright © Yusuke Kamiyamane. All rights reserved. Licensed under a Creative Commons Attribution 3.0 license.
|
||||
* Version: 1.6.0
|
||||
* Version: 1.7.0-b1
|
||||
* Author: Carlos Santa Cruz, Justin Foell, Lance Willett, Daniel Lintott
|
||||
* License: GPL2
|
||||
* Text Domain: wp-strava
|
||||
@@ -35,33 +35,12 @@ if ( ! defined( 'WPSTRAVA_DEBUG' ) ) {
|
||||
define( 'WPSTRAVA_DEBUG', false );
|
||||
}
|
||||
|
||||
// Load the multilingual support.
|
||||
require_once WPSTRAVA_PLUGIN_DIR . 'lib/autoload.php';
|
||||
|
||||
// Load the plugin and multilingual support.
|
||||
function wpstrava_load_plugin_textdomain() {
|
||||
load_plugin_textdomain( 'wp-strava', false, WPSTRAVA_PLUGIN_DIR . 'lang/' );
|
||||
}
|
||||
add_action( 'plugins_loaded', 'wpstrava_load_plugin_textdomain' );
|
||||
|
||||
/**
|
||||
* Autoloads files with classes when needed.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @param string $class_name Name of the class being requested.
|
||||
* @return void
|
||||
*/
|
||||
function wpstrava_autoload_classes( $class_name ) {
|
||||
$parts = explode( '_', $class_name );
|
||||
|
||||
// If our class doesn't have our namespace, don't load it.
|
||||
if ( empty( $parts[0] ) || 'WPStrava' !== $parts[0] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// @TODO Add directory searching if they get created.
|
||||
$file = dirname( __FILE__ ) . '/lib/' . implode( '/', $parts ) . '.php';
|
||||
if ( file_exists( $file ) ) {
|
||||
include_once $file;
|
||||
}
|
||||
}
|
||||
spl_autoload_register( 'wpstrava_autoload_classes' );
|
||||
|
||||
$wpstrava = WPStrava::get_instance();
|
||||
|
||||
Reference in New Issue
Block a user