1
0
mirror of https://github.com/ascribe/wp-theme synced 2024-12-22 17:23:55 +01:00

Initial Commit

This commit is contained in:
Sarah Etter 2015-09-16 17:26:48 -06:00
commit 025e035ca0
37 changed files with 939 additions and 0 deletions

3
.bowerrc Normal file
View File

@ -0,0 +1,3 @@
{
"directory": "bower_components"
}

56
.gitignore vendored Normal file
View File

@ -0,0 +1,56 @@
node_modules
release
vendor
composer.lock
phpunit.xml
.idea
.ftppass
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion
*.iml
## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:
# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries
# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml
# Gradle:
# .idea/gradle.xml
# .idea/libraries
# Mongo Explorer plugin:
# .idea/mongoSettings.xml
## File-based project format:
*.ipr
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties

8
.idea/ascribe.iml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

4
.idea/encodings.xml generated Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ascribe.iml" filepath="$PROJECT_DIR$/.idea/ascribe.iml" />
</modules>
</component>
</project>

5
.idea/scopes/scope_settings.xml generated Normal file
View File

@ -0,0 +1,5 @@
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

20
.jshintrc Normal file
View File

@ -0,0 +1,20 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"boss": true,
"eqnull": true,
"validthis": true,
"globals": {
"exports": true,
"module": false,
"console": true,
"document": true,
"window": true,
}
}

172
Gruntfile.js Normal file
View File

@ -0,0 +1,172 @@
module.exports = function( grunt ) {
// Project configuration
grunt.initConfig( {
pkg: grunt.file.readJSON( 'package.json' ),
concat: {
options: {
stripBanners: true
},
main: {
src: [
'assets/js/vendor/*/*.min.js',
'assets/js/vendor/*/*.js',
'assets/js/src/ascribeio.js'
],
dest: 'assets/js/ascribeio.js'
}
},
jshint: {
all: [
'Gruntfile.js',
'assets/js/src/**/*.js',
'assets/js/test/**/*.js'
]
},
uglify: {
all: {
files: {
'assets/js/ascribeio.min.js': ['assets/js/ascribeio.js']
},
options: {
mangle: {
except: ['jQuery']
}
}
}
},
less: {
all: {
options: {
sourceMap: false
},
files: {
'assets/css/ascribeio.css': 'assets/css/less/ascribeio.less'
}
}
},
postcss: {
dist: {
options: {
processors: [
require('autoprefixer-core')({browsers: 'last 2 versions'})
]
},
files: {
'assets/css/ascribeio.css': [ 'assets/css/ascribeio.css' ]
}
}
},
cssmin: {
minify: {
expand: true,
cwd: 'assets/css/',
src: ['ascribeio.css'],
dest: 'assets/css/',
ext: '.min.css'
}
},
watch: {
livereload: {
files: ['assets/css/*.css'],
options: {
livereload: true
}
},
styles: {
files: ['assets/css/less/**/*.less'],
tasks: ['less', 'autoprefixer', 'cssmin'],
options: {
debounceDelay: 500
}
},
scripts: {
files: ['assets/js/src/**/*.js', 'assets/js/vendor/**/*.js'],
tasks: ['jshint', 'concat', 'uglify'],
options: {
debounceDelay: 500
}
}
},
'sftp-deploy': {
build: {
auth: {
host: 'server.territorial.ca',
port: 22,
authKey: 'key1'
},
cache: 'sftpCache.json',
src: '/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/',
dest: '/home/ascribe/public_html/wp-content/themes/ascribe/',
exclusions: ['/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/node_modules',
'/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/release',
'/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/vendor',
'/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/.git',
'/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/.idea',
'/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/**/.DS_Store'],
serverSep: '/',
concurrency: 4,
progress: true
},
css: {
auth: {
host: 'server.territorial.ca',
port: 22,
authKey: 'key1'
},
cache: 'sftpCache.json',
src: '/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/css/',
dest: '/home/ascribe/public_html/wp-content/themes/territorial/assets/css',
serverSep: '/',
concurrency: 4,
progress: true
},
js: {
auth: {
host: 'server.territorial.ca',
port: 22,
authKey: 'key1'
},
cache: 'sftpCache.json',
src: '/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/js/',
dest: '/home/ascribe/public_html/wp-content/themes/territorial/assets/js',
serverSep: '/',
concurrency: 4,
progress: true
},
controller: {
auth: {
host: 'server.territorial.ca',
port: 22,
authKey: 'key1'
},
src: '/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/controller/',
dest: '/home/ascribe/public_html/wp-content/themes/territorial/controller/',
serverSep: '/',
concurrency: 4,
progress: true
}
}
} );
// Load tasks
require('load-grunt-tasks')(grunt);
// Register tasks
grunt.registerTask( 'css', ['less', 'postcss', 'cssmin', 'sftp-deploy:css'] );
grunt.registerTask( 'js', ['jshint', 'concat', 'uglify', 'sftp-deploy:js'] );
grunt.registerTask( 'controller', ['sftp-deploy:controller'] );
grunt.registerTask( 'default', ['css', 'js', 'controller'] );
grunt.util.linefeed = '\n';
};

3
assets/css/ascribeio.css Normal file
View File

@ -0,0 +1,3 @@
h1 {
color: blue;
}

1
assets/css/ascribeio.min.css vendored Normal file
View File

@ -0,0 +1 @@
h1{color:#00f}

View File

@ -0,0 +1,3 @@
h1 {
color: blue;
}

3
assets/css/readme.md Normal file
View File

@ -0,0 +1,3 @@
# Styles
Only final CSS styles should exist in this folder. If you are using SASS, LESS, autoprefixer, or some other pre-processor, please place your raw source files in a subdirectory.

5
assets/js/ascribeio.js Normal file
View File

@ -0,0 +1,5 @@
( function( window, undefined ) {
'use strict';
} )( this );

1
assets/js/ascribeio.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(a,b){"use strict"}(this);

View File

@ -0,0 +1,13 @@
/**
* ascribe.io
* http://wordpress.org/themes
*
* Copyright (c) 2015 Territorial
* Licensed under the GPLv2+ license.
*/
( function( window, undefined ) {
'use strict';
} )( this );

31
bootstrap.php.dist Normal file
View File

@ -0,0 +1,31 @@
<?php
if ( ! defined( 'PROJECT' ) ) {
define( 'PROJECT', __DIR__ . '/includes/' );
}
if ( ! defined( 'TTL_DIR' ) ) {
define( 'TTL_DIR', __DIR__ . '/' );
}
// Place any additional bootstrapping requirements here for PHP Unit.
if ( ! defined( 'WP_LANG_DIR' ) ) {
define( 'WP_LANG_DIR', 'lang_dir' );
}
if ( ! defined( 'TTL_PATH' ) ) {
define( 'TTL_PATH', 'path' );
}
if ( ! file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
throw new PHPUnit_Framework_Exception(
'ERROR' . PHP_EOL . PHP_EOL .
'You must use Composer to install the test suite\'s dependencies!' . PHP_EOL
);
}
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/tests/phpunit/test-tools/TestCase.php';
WP_Mock::setUsePatchwork( true );
WP_Mock::bootstrap();
WP_Mock::tearDown();

23
bower.json Normal file
View File

@ -0,0 +1,23 @@
{
"name": "ascribeio",
"version": "0.0.1",
"main": "/",
"license": "GPLv2+",
"ignore": [
"**/.*",
"*.md",
"assets/css/sass/*",
"assets/css/src/*",
"assets/js/src/*",
"assets/js/vendor/*",
"images/src/*",
"tests",
"bootstrap.php",
"Gruntfile.js",
"package.json",
"composer.json",
"phpunit.xml.dist"
],
"devDependencies": {},
"keywords": []
}

27
composer.json Normal file
View File

@ -0,0 +1,27 @@
{
"name": "ascribeio",
"description": "ascribe.io theme by Territorial",
"version": "0.0.1",
"type": "wordpress-theme",
"keywords": [],
"homepage": "http://wordpress.org/themes",
"license": "GPLv2.0+",
"authors": [
{
"name": "Territorial",
"email": "us@territorial.ca",
"homepage": "http://territorial.ca",
"role": "Developer"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=5.4"
},
"require-dev": {
"antecedent/patchwork": "1.2.*",
"phpunit/phpunit" : "*@stable",
"brianium/paratest" : "dev-master",
"10up/wp_mock" : "dev-master"
}
}

12
footer.php Normal file
View File

@ -0,0 +1,12 @@
<?php
/**
* The template for displaying the footer.
*
* @package ascribe.io
* @since 0.1.0
*/
?>
<?php wp_footer(); ?>
</body>
</html>

29
functions.php Normal file
View File

@ -0,0 +1,29 @@
<?php
/**
* ascribe.io functions and definitions
*
* When using a child theme (see http://codex.wordpress.org/Theme_Development and
* http://codex.wordpress.org/Child_Themes), you can override certain functions
* (those wrapped in a function_exists() call) by defining them first in your child theme's
* functions.php file. The child theme's functions.php file is included before the parent
* theme's file, so the child theme functions would be used.
*
* @package ascribe.io
* @since 0.1.0
*/
// Useful global constants
define( 'TTL_VERSION', '0.1.0' );
define( 'TTL_URL', get_stylesheet_directory_uri() );
define( 'TTL_TEMPLATE_URL', get_template_directory_uri() );
define( 'TTL_PATH', get_template_directory() . '/' );
define( 'TTL_INC', TTL_PATH . 'includes/' );
// Include compartmentalized functions
require_once TTL_INC . 'functions/core.php';
// Include lib classes
// Run the setup functions
TenUp\ascribe.io\Core\setup();

15
header.php Normal file
View File

@ -0,0 +1,15 @@
<?php
/**
* The template for displaying the header.
*
* @package ascribe.io
* @since 0.1.0
*/
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<?php wp_head(); ?>
</head>
<body>

21
humans.txt Normal file
View File

@ -0,0 +1,21 @@
/* TEAM */
Developer: Territorial
Contact: us@territorial.ca
URI: http://territorial.ca
/* THANKS */
Template Design: 10up
URI: http://10up.com
Twitter: @10up
Template Design: Eric Mann
URI: https://eamann.com
Twitter: @ericmann
Template Design: Luke Woodward
URI: http://lkwdwrd.com
Twitter: @lkwdwrd
/* SITE */
Created: Wed Sep 16 2015
Template: https://github.com/10up/generator-wp-make

3
images/readme.md Normal file
View File

@ -0,0 +1,3 @@
# Project Images
Only images in-use by the project should be placed in this folder. Wherever possible, combine multiple small images into sprites to be used by CSS. Original (non-sprite) images should be placed in the `/src` subdirectory.

3
images/src/readme.md Normal file
View File

@ -0,0 +1,3 @@
# Project Images
Only source images (i.e. non-sprites, PSDs, raw photos) should be placed in this directory. Source files are meant to serve as a backup for any images that can be edited by an end user.

View File

@ -0,0 +1,95 @@
<?php
namespace TenUp\ascribe.io\Core;
/**
* Set up theme defaults and register supported WordPress features.
*
* @since 0.1.0
*
* @uses add_action()
*
* @return void.
*/
function setup() {
$n = function( $function ) {
return __NAMESPACE__ . "\\$function";
};
add_action( 'after_setup_theme', $n( 'i18n' ) );
add_action( 'wp_head', $n( 'header_meta' ) );
add_action( 'wp_enqueue_scripts', $n( 'scripts' ) );
add_action( 'wp_enqueue_scripts', $n( 'styles' ) );
}
/**
* Makes WP Theme available for translation.
*
* Translations can be added to the /lang directory.
* If you're building a theme based on WP Theme, use a find and replace
* to change 'wptheme' to the name of your theme in all template files.
*
* @uses load_theme_textdomain() For translation/localization support.
*
* @since 0.1.0
*
* @return void.
*/
function i18n() {
load_theme_textdomain( 'ttl', TTL_PATH . '/languages' );
}
/**
* Enqueue scripts for front-end.
*
* @uses wp_enqueue_script() to load front end scripts.
*
* @since 0.1.0
*
* @return void.
*/
function scripts( $debug = false ) {
$min = ( $debug || defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
wp_enqueue_script(
'ttl',
TTL_TEMPLATE_URL . "/assets/js/ascribeio{$min}.js",
array(),
TTL_VERSION,
true
);
}
/**
* Enqueue styles for front-end.
*
* @uses wp_enqueue_style() to load front end styles.
*
* @since 0.1.0
*
* @return void.
*/
function styles( $debug = false ) {
$min = ( $debug || defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
wp_enqueue_style(
'ttl',
TTL_URL . "/assets/css/ascribeio{$min}.css",
array(),
TTL_VERSION
);
}
/**
* Add humans.txt to the <head> element.
*
* @uses apply_filters()
*
* @since 0.1.0
*
* @return void.
*/
function header_meta() {
$humans = '<link type="text/plain" rel="author" href="' . TTL_TEMPLATE_URL . '/humans.txt" />';
echo apply_filters( 'ttl_humans', $humans );
}

3
includes/readme.md Normal file
View File

@ -0,0 +1,3 @@
# Includes
All theme classes, objects, and libraries should be hidden away in this `/includes` directory.

18
index.php Normal file
View File

@ -0,0 +1,18 @@
<?php
/**
* The main template file
*
* @package ascribe.io
* @since 0.1.0
*/
get_header(); ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ): the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php endwhile; ?>
<?php endif; ?>
<?php get_footer();

16
languages/ttl.pot Normal file
View File

@ -0,0 +1,16 @@
msgid ""
msgstr ""
"Project-Id-Version: ascribe.io\n"
"POT-Creation-Date: 2015-09-16T23:04:11.784Z\n"
"PO-Revision-Date: 2015-09-16T23:04:11.785Z\n"
"Last-Translator: 10up <info@10up.com>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
"_n_noop:1,2;_x:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_ex:1,2c;"
"esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
"X-Poedit-Basepath: .\n"
"X-Poedit-SearchPath-0: ..\n"

36
package.json Normal file
View File

@ -0,0 +1,36 @@
{
"name": "ascribeio",
"title": "ascribe.io",
"description": "ascribe.io theme by Territorial",
"version": "0.0.1",
"homepage": "http://wordpress.org/themes",
"repository": {
"type": "git",
"url": ""
},
"author": {
"name": "Territorial",
"email": "us@territorial.ca",
"url": "http://territorial.ca"
},
"devDependencies": {
"autoprefixer-core": "^5.2.1",
"grunt": "^0.4.5",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-compress": "^0.13.0",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-cssmin": "^0.12.3",
"grunt-contrib-jshint": "^0.11.2",
"grunt-contrib-less": "^1.0.1",
"grunt-contrib-qunit": "^0.7.0",
"grunt-contrib-uglify": "^0.9.1",
"grunt-contrib-watch": "^0.6.1",
"grunt-phpunit": "^0.3.6",
"grunt-postcss": "^0.5.4",
"grunt-sass": "^1.0.0",
"load-grunt-tasks": "^3.2.0",
"qunitjs": "~1.18.0"
},
"keywords": []
}

21
phpunit.xml.dist Normal file
View File

@ -0,0 +1,21 @@
<phpunit
bootstrap="bootstrap.php.dist"
backupGlobals="false"
processIsolation="false"
colors="false">
<testsuites>
<testsuite name="Default">
<directory suffix="Tests.php">./tests/phpunit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./includes</directory>
</whitelist>
</filter>
<php>
<ini name="error_reporting" value="32767" />
<ini name="display_errors" value="1" />
<ini name="display_startup_errors" value="1" />
</php>
</phpunit>

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

19
style.css Normal file
View File

@ -0,0 +1,19 @@
/**
* Theme Name: ascribe.io
* Theme URI: http://wordpress.org/themes
* Description: ascribe.io theme by Territorial
* Author: Territorial
* Author URI: http://territorial.ca
* Version: 0.1.0
* Tags:
* Text Domain: ttl
*
* License: GPLv2+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
/**
* Built using yo wp-make:theme
* Copyright (c) 2014 10up, LLC
* https://github.com/lkwdwrd/generator-wp-make
*/

View File

@ -0,0 +1,163 @@
<?php
namespace TenUp\ascribe.io\Core;
/**
* This is a very basic test case to get things started. You should probably rename this and make
* it work for your project. You can use all the tools provided by WP Mock and Mockery to create
* your tests. Coverage is calculated against your includes/ folder, so try to keep all of your
* functional code self contained in there.
*
* References:
* - http://phpunit.de/manual/current/en/index.html
* - https://github.com/padraic/mockery
* - https://github.com/10up/wp_mock
*/
use TenUp\ascribe.io as Base;
class Core_Tests extends Base\TestCase {
protected $testFiles = [
'functions/core.php'
];
/**
* Make sure all theme-specific constants are defined before we get started
*/
public function setUp() {
if ( ! defined( 'TTL_TEMPLATE_URL' ) ) {
define( 'TTL_TEMPLATE_URL', 'template_url' );
}
if ( ! defined( 'TTL_VERSION' ) ) {
define( 'TTL_VERSION', '0.0.1' );
}
if ( ! defined( 'TTL_URL' ) ) {
define( 'TTL_URL', 'url' );
}
parent::setUp();
}
/**
* Test setup method.
*/
public function test_setup() {
// Setup
\WP_Mock::expectActionAdded( 'after_setup_theme', 'TenUp\ascribe.io\Core\i18n' );
\WP_Mock::expectActionAdded( 'wp_head', 'TenUp\ascribe.io\Core\header_meta' );
\WP_Mock::expectActionAdded( 'wp_enqueue_scripts', 'TenUp\ascribe.io\Core\scripts' );
\WP_Mock::expectActionAdded( 'wp_enqueue_scripts', 'TenUp\ascribe.io\Core\styles' );
// Act
setup();
// Verify
$this->assertConditionsMet();
}
/**
* Test internationalization integration.
*/
public function test_i18n() {
// Setup
\WP_Mock::wpFunction( 'load_theme_textdomain', array(
'times' => 1,
'args' => array(
'ttl',
TTL_PATH . '/languages'
),
) );
// Act
i18n();
// Verify
$this->assertConditionsMet();
}
/**
* Test scripts enqueue.
*/
public function test_scripts() {
// Regular
\WP_Mock::wpFunction( 'wp_enqueue_script', array(
'times' => 1,
'args' => array(
'ttl',
'template_url/assets/js/ascribeio.min.js',
array(),
'0.0.1',
true,
),
) );
scripts();
$this->assertConditionsMet();
// Debug Mode
\WP_Mock::wpFunction( 'wp_enqueue_script', array(
'times' => 1,
'args' => array(
'ttl',
'template_url/assets/js/ascribeio.js',
array(),
'0.0.1',
true,
),
) );
scripts( true );
$this->assertConditionsMet();
}
/**
* Test style enqueue.
*/
public function test_styles() {
// Regular
\WP_Mock::wpFunction( 'wp_enqueue_style', array(
'times' => 1,
'args' => array(
'ttl',
'url/assets/css/ascribeio.min.css',
array(),
'0.0.1',
),
) );
styles();
$this->assertConditionsMet();
// Debug Mode
\WP_Mock::wpFunction( 'wp_enqueue_style', array(
'times' => 1,
'args' => array(
'ttl',
'url/assets/css/ascribeio.css',
array(),
'0.0.1',
),
) );
styles( true );
$this->assertConditionsMet();
}
/**
* Test header meta injection
*/
public function test_header_meta() {
// Setup
$meta = '<link type="text/plain" rel="author" href="template_url/humans.txt" />';
\WP_Mock::onFilter( 'ttl_humans' )->with( $meta )->reply( $meta );
// Act
ob_start();
header_meta();
$result = ob_get_clean();
// Verify
$this->assertConditionsMet();
$this->assertEquals( $meta, $result );
}
}

View File

@ -0,0 +1,75 @@
<?php
namespace TenUp\ascribe.io;
use PHPUnit_Framework_TestResult;
use Text_Template;
use WP_Mock;
use WP_Mock\Tools\TestCase as BaseTestCase;
class TestCase extends BaseTestCase {
public function run( PHPUnit_Framework_TestResult $result = null ) {
$this->setPreserveGlobalState( false );
return parent::run( $result );
}
protected $testFiles = array();
public function setUp() {
if ( ! empty( $this->testFiles ) ) {
foreach ( $this->testFiles as $file ) {
if ( file_exists( PROJECT . $file ) ) {
require_once( PROJECT . $file );
}
}
}
parent::setUp();
}
public function assertActionsCalled() {
$actions_not_added = $expected_actions = 0;
try {
WP_Mock::assertActionsCalled();
} catch ( \Exception $e ) {
$actions_not_added = 1;
$expected_actions = $e->getMessage();
}
$this->assertEmpty( $actions_not_added, $expected_actions );
}
public function ns( $function ) {
if ( ! is_string( $function ) || false !== strpos( $function, '\\' ) ) {
return $function;
}
$thisClassName = trim( get_class( $this ), '\\' );
if ( ! strpos( $thisClassName, '\\' ) ) {
return $function;
}
// $thisNamespace is constructed by exploding the current class name on
// namespace separators, running array_slice on that array starting at 0
// and ending one element from the end (chops the class name off) and
// imploding that using namespace separators as the glue.
$thisNamespace = implode( '\\', array_slice( explode( '\\', $thisClassName ), 0, - 1 ) );
return "$thisNamespace\\$function";
}
/**
* Define constants after requires/includes
*
* See http://kpayne.me/2012/07/02/phpunit-process-isolation-and-constant-already-defined/
* for more details
*
* @param \Text_Template $template
*/
public function prepareTemplate( \Text_Template $template ) {
$template->setVar( [
'globals' => '$GLOBALS[\'__PHPUNIT_BOOTSTRAP\'] = \'' . $GLOBALS['__PHPUNIT_BOOTSTRAP'] . '\';',
] );
parent::prepareTemplate( $template );
}
}

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>QUnit Example</title>
<link rel="stylesheet" href="../../node_modules/qunitjs/qunit/qunit.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="../../node_modules/qunitjs/qunit/qunit.js"></script>
<script src="tests/ascribeio.js"></script>
</body>
</html>

View File

@ -0,0 +1,4 @@
// Qunit Tests
test( "hello test", function() {
ok( 1 == "1", "Passed!" );
});