diff --git a/.gitignore b/.gitignore index dcc034b..ed0ef5d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,54 +3,4 @@ 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 - - +.idea \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 9926fa1..27b931a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,15 +5,18 @@ module.exports = function( grunt ) { pkg: grunt.file.readJSON( 'package.json' ), concat: { options: { - stripBanners: true + stripBanners: true, + banner: '/*! <%= pkg.title %> - v<%= pkg.version %>\n' + + ' * <%= pkg.homepage %>\n' + + ' * Copyright (c) <%= grunt.template.today("yyyy") %>;' + + ' * Licensed GPLv2+' + + ' */\n' }, main: { src: [ - 'assets/js/vendor/*/*.min.js', - 'assets/js/vendor/*/*.js', - 'assets/js/src/ascribeio.js' + 'assets/js/src/ascribe.js' ], - dest: 'assets/js/ascribeio.js' + dest: 'assets/js/ascribe.js' } }, jshint: { @@ -26,26 +29,32 @@ module.exports = function( grunt ) { uglify: { all: { files: { - 'assets/js/ascribeio.min.js': ['assets/js/ascribeio.js'] + 'assets/js/ascribe.min.js': ['assets/js/ascribe.js'] }, options: { + banner: '/*! <%= pkg.title %> - v<%= pkg.version %>\n' + + ' * <%= pkg.homepage %>\n' + + ' * Copyright (c) <%= grunt.template.today("yyyy") %>;' + + ' * Licensed GPLv2+' + + ' */\n', mangle: { except: ['jQuery'] } } } }, - - less: { - all: { - options: { - sourceMap: false - }, - files: { - 'assets/css/ascribeio.css': 'assets/css/less/ascribeio.less' - } - } - }, + + sass: { + all: { + options: { + precision: 2, + sourceMap: true + }, + files: { + 'assets/css/ascribe.css': 'assets/css/sass/ascribe.scss' + } + } + }, postcss: { @@ -56,17 +65,24 @@ module.exports = function( grunt ) { ] }, files: { - 'assets/css/ascribeio.css': [ 'assets/css/ascribeio.css' ] + 'assets/css/ascribe.css': [ 'assets/css/ascribe.css' ] } } }, cssmin: { + options: { + banner: '/*! <%= pkg.title %> - v<%= pkg.version %>\n' + + ' * <%=pkg.homepage %>\n' + + ' * Copyright (c) <%= grunt.template.today("yyyy") %>;' + + ' * Licensed GPLv2+' + + ' */\n' + }, minify: { expand: true, cwd: 'assets/css/', - src: ['ascribeio.css'], + src: ['ascribe.css'], dest: 'assets/css/', ext: '.min.css' @@ -80,8 +96,8 @@ module.exports = function( grunt ) { } }, styles: { - files: ['assets/css/less/**/*.less'], - tasks: ['less', 'autoprefixer', 'cssmin'], + files: ['assets/css/sass/**/*.scss'], + tasks: ['sass', 'autoprefixer', 'cssmin'], options: { debounceDelay: 500 } @@ -94,65 +110,62 @@ module.exports = function( grunt ) { } } }, - '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/ascribe/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/ascribe/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/ascribe/controller/', - serverSep: '/', - concurrency: 4, - progress: true - } - } + 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'] + } } ); // Load tasks @@ -160,13 +173,16 @@ module.exports = function( grunt ) { // Register tasks - grunt.registerTask( 'css', ['less', 'postcss', 'cssmin', 'sftp-deploy:css'] ); + grunt.registerTask( 'css', ['sass', 'postcss', 'cssmin'] ); + - grunt.registerTask( 'js', ['jshint', 'concat', 'uglify', 'sftp-deploy:js'] ); + grunt.registerTask( 'js', ['jshint', 'concat', 'uglify'] ); - grunt.registerTask( 'controller', ['sftp-deploy:controller'] ); + grunt.registerTask( 'default', ['css', 'js'] ); - grunt.registerTask( 'default', ['css', 'js', 'controller'] ); + grunt.registerTask( 'build', ['default', 'clean', 'copy', 'compress'] ); + + grunt.registerTask( 'test', ['phpunit', 'qunit'] ); grunt.util.linefeed = '\n'; }; diff --git a/assets/css/ascribeio.css b/assets/css/ascribeio.css deleted file mode 100644 index ccf22a0..0000000 --- a/assets/css/ascribeio.css +++ /dev/null @@ -1,3 +0,0 @@ -h1 { - color: blue; -} diff --git a/assets/css/ascribeio.min.css b/assets/css/ascribeio.min.css deleted file mode 100644 index 9cb59d2..0000000 --- a/assets/css/ascribeio.min.css +++ /dev/null @@ -1 +0,0 @@ -h1{color:#00f} \ No newline at end of file diff --git a/assets/css/less/ascribeio.less b/assets/css/less/ascribeio.less deleted file mode 100644 index a4c9b4b..0000000 --- a/assets/css/less/ascribeio.less +++ /dev/null @@ -1,3 +0,0 @@ -h1 { - color: blue; -} \ No newline at end of file diff --git a/assets/css/sass/ascribe.scss b/assets/css/sass/ascribe.scss new file mode 100644 index 0000000..4ebfe77 --- /dev/null +++ b/assets/css/sass/ascribe.scss @@ -0,0 +1,7 @@ +/** + * ascribe + * http://wordpress.org/themes + * + * Copyright (c) 2015 Territorial + * Licensed under the GPLv2+ license. + */ diff --git a/assets/js/ascribeio.js b/assets/js/ascribeio.js deleted file mode 100644 index 2f7c101..0000000 --- a/assets/js/ascribeio.js +++ /dev/null @@ -1,5 +0,0 @@ -( function( window, undefined ) { - 'use strict'; - - -} )( this ); diff --git a/assets/js/ascribeio.min.js b/assets/js/ascribeio.min.js deleted file mode 100644 index 2dce2ce..0000000 --- a/assets/js/ascribeio.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(a,b){"use strict"}(this); \ No newline at end of file diff --git a/assets/js/src/ascribeio.js b/assets/js/src/ascribe.js similarity index 100% rename from assets/js/src/ascribeio.js rename to assets/js/src/ascribe.js diff --git a/bootstrap.php.dist b/bootstrap.php.dist index e499c82..b634b94 100644 --- a/bootstrap.php.dist +++ b/bootstrap.php.dist @@ -3,16 +3,16 @@ if ( ! defined( 'PROJECT' ) ) { define( 'PROJECT', __DIR__ . '/includes/' ); } -if ( ! defined( 'TTL_DIR' ) ) { - define( 'TTL_DIR', __DIR__ . '/' ); +if ( ! defined( 'WPTHEME_DIR' ) ) { + define( 'WPTHEME_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 ( ! defined( 'WPTHEME_PATH' ) ) { + define( 'WPTHEME_PATH', 'path' ); } if ( ! file_exists( __DIR__ . '/vendor/autoload.php' ) ) { diff --git a/bower.json b/bower.json index 1ad1104..e0ce6a7 100644 --- a/bower.json +++ b/bower.json @@ -1,5 +1,5 @@ { - "name": "ascribeio", + "name": "ascribe", "version": "0.0.1", "main": "/", "license": "GPLv2+", diff --git a/composer.json b/composer.json index 19cab82..c02e225 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "name": "ascribeio", - "description": "ascribe theme by Territorial", + "name": "ascribe", + "description": "The best WordPress theme ever made!", "version": "0.0.1", "type": "wordpress-theme", "keywords": [], diff --git a/functions.php b/functions.php index 3add182..b15ad80 100644 --- a/functions.php +++ b/functions.php @@ -14,14 +14,14 @@ */ // 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/' ); +define( 'WPTHEME_VERSION', '0.1.0' ); +define( 'WPTHEME_URL', get_stylesheet_directory_uri() ); +define( 'WPTHEME_TEMPLATE_URL', get_template_directory_uri() ); +define( 'WPTHEME_PATH', get_template_directory() . '/' ); +define( 'WPTHEME_INC', WPTHEME_PATH . 'includes/' ); // Include compartmentalized functions -require_once TTL_INC . 'functions/core.php'; +require_once WPTHEME_INC . 'functions/core.php'; // Include lib classes diff --git a/includes/functions/core.php b/includes/functions/core.php index d98198c..0f244eb 100644 --- a/includes/functions/core.php +++ b/includes/functions/core.php @@ -1,4 +1,5 @@ '; + $humans = ''; - echo apply_filters( 'ttl_humans', $humans ); + echo apply_filters( 'wptheme_humans', $humans ); } diff --git a/languages/ttl.pot b/languages/wptheme.pot similarity index 83% rename from languages/ttl.pot rename to languages/wptheme.pot index cd37550..fb2fd30 100644 --- a/languages/ttl.pot +++ b/languages/wptheme.pot @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: ascribe\n" -"POT-Creation-Date: 2015-09-16T23:04:11.784Z\n" -"PO-Revision-Date: 2015-09-16T23:04:11.785Z\n" +"POT-Creation-Date: 2015-09-16T23:52:34.272Z\n" +"PO-Revision-Date: 2015-09-16T23:52:34.274Z\n" "Last-Translator: 10up \n" "Language-Team: \n" "MIME-Version: 1.0\n" diff --git a/package.json b/package.json index f3db3ca..40e62e7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "ascribeio", + "name": "ascribe", "title": "ascribe", - "description": "ascribe theme by Territorial", + "description": "The best WordPress theme ever made!", "version": "0.0.1", "homepage": "http://wordpress.org/themes", "repository": { @@ -14,22 +14,20 @@ "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-uglify": "^0.9.1", + "grunt-sass": "^1.0.0", + "autoprefixer-core": "^5.2.1", + "grunt-postcss": "^0.5.4", "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-contrib-clean": "^0.6.0", + "grunt-contrib-copy": "^0.8.0", + "grunt-contrib-compress": "^0.13.0", "grunt-phpunit": "^0.3.6", - "grunt-postcss": "^0.5.4", - "grunt-sass": "^1.0.0", - "grunt-sftp-deploy": "^0.2.4", + "grunt-contrib-qunit": "^0.7.0", "load-grunt-tasks": "^3.2.0", "qunitjs": "~1.18.0" }, diff --git a/sftpCache.json b/sftpCache.json deleted file mode 100644 index b0a7127..0000000 --- a/sftpCache.json +++ /dev/null @@ -1 +0,0 @@ -{"/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/css//ascribeio.css":"2015-09-16T23:36:41.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/css//ascribeio.min.css":"2015-09-16T23:36:41.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/css//readme.md":"2015-09-16T23:04:11.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/css//less/ascribeio.less":"2015-09-16T23:17:47.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/js//ascribeio.js":"2015-09-16T23:36:44.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/js//ascribeio.min.js":"2015-09-16T23:36:44.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/js//src/ascribeio.js":"2015-09-16T23:04:11.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/js//vendor/readme.md":"2015-09-16T23:04:11.000Z"} \ No newline at end of file diff --git a/style.css b/style.css index 6bbb788..f0f9b82 100644 --- a/style.css +++ b/style.css @@ -1,12 +1,12 @@ /** * Theme Name: ascribe * Theme URI: http://wordpress.org/themes - * Description: ascribe theme by Territorial + * Description: The best WordPress theme ever made! * Author: Territorial * Author URI: http://territorial.ca * Version: 0.1.0 * Tags: - * Text Domain: ttl + * Text Domain: wptheme * * License: GPLv2+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html diff --git a/tests/phpunit/Core_Tests.php b/tests/phpunit/Core_Tests.php new file mode 100644 index 0000000..4e18b64 --- /dev/null +++ b/tests/phpunit/Core_Tests.php @@ -0,0 +1,163 @@ +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 = ''; + \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 ); + } +} diff --git a/tests/phpunit/test-tools/TestCase.php b/tests/phpunit/test-tools/TestCase.php new file mode 100644 index 0000000..21b7613 --- /dev/null +++ b/tests/phpunit/test-tools/TestCase.php @@ -0,0 +1,75 @@ +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 ); + } +} \ No newline at end of file diff --git a/tests/qunit/ascribe.html b/tests/qunit/ascribe.html new file mode 100644 index 0000000..12810c3 --- /dev/null +++ b/tests/qunit/ascribe.html @@ -0,0 +1,14 @@ + + + + + QUnit Example + + + +
+
+ + + + diff --git a/tests/qunit/tests/ascribe.js b/tests/qunit/tests/ascribe.js new file mode 100644 index 0000000..cb590c4 --- /dev/null +++ b/tests/qunit/tests/ascribe.js @@ -0,0 +1,4 @@ +// Qunit Tests +test( "hello test", function() { + ok( 1 == "1", "Passed!" ); +});