1
0
mirror of https://github.com/ascribe/wp-theme synced 2025-01-03 10:25:08 +01:00

Theme working

This commit is contained in:
Sarah Etter 2015-09-17 16:21:29 -06:00
parent c429b69d2d
commit ff877bf048
15 changed files with 108 additions and 350 deletions

6
.ftppass Normal file
View File

@ -0,0 +1,6 @@
{
"key1": {
"username": "ascribe",
"password": "zS!wfsBm9FK$"
}
}

1
.idea/ascribe.iml generated
View File

@ -4,5 +4,6 @@
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="ascribe node_modules" level="project" />
</component>
</module>

View File

@ -43,18 +43,17 @@ module.exports = function( grunt ) {
}
}
},
sass: {
all: {
options: {
precision: 2,
sourceMap: true
},
files: {
'assets/css/ascribe.css': 'assets/css/sass/ascribe.scss'
}
}
},
less: {
all: {
options: {
sourceMap: false
},
files: {
'assets/css/ascribe.css': 'assets/css/less/ascribe.less'
}
}
},
postcss: {
@ -96,8 +95,8 @@ module.exports = function( grunt ) {
}
},
styles: {
files: ['assets/css/sass/**/*.scss'],
tasks: ['sass', 'autoprefixer', 'cssmin'],
files: ['assets/css/less/**/*.less'],
tasks: ['less', 'autoprefixer', 'cssmin'],
options: {
debounceDelay: 500
}
@ -110,62 +109,65 @@ module.exports = function( grunt ) {
}
}
},
clean: {
main: ['release/<%= pkg.version %>']
},
copy: {
// Copy the theme to a versioned release directory
main: {
src: [
'**',
'!**/.*',
'!**/readme.md',
'!node_modules/**',
'!vendor/**',
'!tests/**',
'!release/**',
'!assets/css/sass/**',
'!assets/css/src/**',
'!assets/js/src/**',
'!images/src/**',
'!bootstrap.php',
'!bower.json',
'!composer.json',
'!composer.lock',
'!Gruntfile.js',
'!package.json',
'!phpunit.xml',
'!phpunit.xml.dist'
],
dest: 'release/<%= pkg.version %>/'
}
},
compress: {
main: {
options: {
mode: 'zip',
archive: './release/wptheme.<%= pkg.version %>.zip'
},
expand: true,
cwd: 'release/<%= pkg.version %>/',
src: ['**/*'],
dest: 'wptheme/'
}
},
phpunit: {
classes: {
dir: 'tests/phpunit/'
},
options: {
bin: 'vendor/bin/phpunit',
bootstrap: 'bootstrap.php.dist',
colors: true,
testSuffix: 'Tests.php'
}
},
qunit: {
all: ['tests/qunit/**/*.html']
}
'sftp-deploy': {
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/ascribe/assets/css',
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
},
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/ascribe/assets/js',
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
},
controller: {
auth: {
host: 'server.territorial.ca',
port: 22,
authKey: 'key1'
},
cache: 'sftpCache.json',
src: '/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/controller/',
dest: '/home/ascribe/public_html/wp-content/themes/ascribe/controller/',
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
}
}
} );
// Load tasks
@ -173,16 +175,13 @@ module.exports = function( grunt ) {
// Register tasks
grunt.registerTask( 'css', ['sass', 'postcss', 'cssmin'] );
grunt.registerTask( 'css', ['less', 'postcss', 'cssmin', 'sftp-deploy:css'] );
grunt.registerTask( 'js', ['jshint', 'concat', 'uglify'] );
grunt.registerTask( 'js', ['jshint', 'concat', 'uglify', 'sftp-deploy:js'] );
grunt.registerTask( 'default', ['css', 'js'] );
grunt.registerTask( 'controller', ['sftp-deploy:controller'] );
grunt.registerTask( 'build', ['default', 'clean', 'copy', 'compress'] );
grunt.registerTask( 'test', ['phpunit', 'qunit'] );
grunt.registerTask( 'default', ['css', 'js', 'controller'] );
grunt.util.linefeed = '\n';
};

0
assets/css/ascribe.css Normal file
View File

0
assets/css/ascribe.min.css vendored Normal file
View File

View File

View File

@ -1,7 +0,0 @@
/**
* ascribe
* http://wordpress.org/themes
*
* Copyright (c) 2015 Territorial
* Licensed under the GPLv2+ license.
*/

8
assets/js/ascribe.js Normal file
View File

@ -0,0 +1,8 @@
/*! ascribe - v0.0.1
* http://wordpress.org/themes
* Copyright (c) 2015; * Licensed GPLv2+ */
( function( window, undefined ) {
'use strict';
} )( this );

4
assets/js/ascribe.min.js vendored Normal file
View File

@ -0,0 +1,4 @@
/*! ascribe - v0.0.1
* http://wordpress.org/themes
* Copyright (c) 2015; * Licensed GPLv2+ */
!function(a,b){"use strict"}(this);

View File

@ -14,20 +14,22 @@
"url": "http://territorial.ca"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-uglify": "^0.9.1",
"grunt-sass": "^1.0.0",
"autoprefixer-core": "^5.2.1",
"grunt-postcss": "^0.5.4",
"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-watch": "^0.6.1",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-compress": "^0.13.0",
"grunt-phpunit": "^0.3.6",
"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",
"grunt-sftp-deploy": "^0.2.4",
"load-grunt-tasks": "^3.2.0",
"qunitjs": "~1.18.0"
},

1
sftpCache.json Normal file
View File

@ -0,0 +1 @@
{"/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/css//ascribe.css":"2015-09-17T22:20:29.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/css//ascribe.min.css":"2015-09-17T22:20:29.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/css//readme.md":"2015-09-16T23:52:34.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/css//less/ascribe.less":"2015-09-17T22:05:05.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/js//ascribe.js":"2015-09-17T22:20:36.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/js//ascribe.min.js":"2015-09-17T22:20:36.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/js//src/ascribe.js":"2015-09-16T23:52:34.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/js//vendor/readme.md":"2015-09-16T23:52:34.000Z"}

View File

@ -1,163 +0,0 @@
<?php
namespace TenUp\ascribe\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 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( 'WPTHEME_TEMPLATE_URL' ) ) {
define( 'WPTHEME_TEMPLATE_URL', 'template_url' );
}
if ( ! defined( 'WPTHEME_VERSION' ) ) {
define( 'WPTHEME_VERSION', '0.0.1' );
}
if ( ! defined( 'WPTHEME_URL' ) ) {
define( 'WPTHEME_URL', 'url' );
}
parent::setUp();
}
/**
* Test setup method.
*/
public function test_setup() {
// Setup
\WP_Mock::expectActionAdded( 'after_setup_theme', 'TenUp\ascribe\Core\i18n' );
\WP_Mock::expectActionAdded( 'wp_head', 'TenUp\ascribe\Core\header_meta' );
\WP_Mock::expectActionAdded( 'wp_enqueue_scripts', 'TenUp\ascribe\Core\scripts' );
\WP_Mock::expectActionAdded( 'wp_enqueue_scripts', 'TenUp\ascribe\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(
'wptheme',
WPTHEME_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(
'wptheme',
'template_url/assets/js/ascribe.min.js',
array(),
'0.0.1',
true,
),
) );
scripts();
$this->assertConditionsMet();
// Debug Mode
\WP_Mock::wpFunction( 'wp_enqueue_script', array(
'times' => 1,
'args' => array(
'wptheme',
'template_url/assets/js/ascribe.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(
'wptheme',
'url/assets/css/ascribe.min.css',
array(),
'0.0.1',
),
) );
styles();
$this->assertConditionsMet();
// Debug Mode
\WP_Mock::wpFunction( 'wp_enqueue_style', array(
'times' => 1,
'args' => array(
'wptheme',
'url/assets/css/ascribe.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( 'wptheme_humans' )->with( $meta )->reply( $meta );
// Act
ob_start();
header_meta();
$result = ob_get_clean();
// Verify
$this->assertConditionsMet();
$this->assertEquals( $meta, $result );
}
}

View File

@ -1,75 +0,0 @@
<?php
namespace TenUp\ascribe;
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

@ -1,14 +0,0 @@
<!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/ascribe.js"></script>
</body>
</html>

View File

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