From a567b17a9033ea74126a465e6da16a4167ee3f7c Mon Sep 17 00:00:00 2001 From: Josantonius Date: Sat, 6 Jan 2018 11:18:00 +0100 Subject: [PATCH] Updated to 1.1.0 version --- .gitattributes | 4 +- CHANGELOG.md | 8 +++- LICENSE | 2 +- README-ES.md | 10 ++--- README.md | 10 ++--- tests/Example.php | 36 +----------------- tests/HookTest.php | 93 ++++++++++++++++++++++++---------------------- 7 files changed, 71 insertions(+), 92 deletions(-) diff --git a/.gitattributes b/.gitattributes index 2b2dd96..58ff123 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,4 +8,6 @@ phpmd.xml export-ignore .travis.yml export-ignore .editorconfig export-ignore .gitattributes export-ignore -.gitignore export-ignore \ No newline at end of file +.gitignore export-ignore +.php_cs.dist export-ignore +CONDUCT.md export-ignore \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 21604dd..8055f51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # CHANGELOG +## 1.1.0 - 2018-01-06 + +* The tests were fixed. + +* Changes in documentation. + ## 1.0.9 - 2017-11-08 * Implemented `PHP Mess Detector` to detect inconsistencies in code styles. @@ -86,7 +92,7 @@ ## 1.0.5 - 2017-06-24 -*The class was improved to work with different instances and some static methods were changed to dynamic ones. +* The class was improved to work with different instances and some static methods were changed to dynamic ones. ## 1.0.4 - 2017-06-02 diff --git a/LICENSE b/LICENSE index 1446102..9a70c15 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ The MIT License (MIT) ===================== -Copyright (c) `2017` `Josantonius, https://josantonius.com ` +Copyright (c) `2017 - 2018` `Josantonius, https://josantonius.com ` Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README-ES.md b/README-ES.md index 01eb77f..d3be715 100644 --- a/README-ES.md +++ b/README-ES.md @@ -272,10 +272,10 @@ Ejecutar todas las pruebas anteriores: ## ☑ Tareas pendientes -- [ ] Añadir nueva funcionalidad -- [ ] Mejorar pruebas -- [ ] Mejorar documentación -- [ ] Refactorizar código +- [ ] Añadir nueva funcionalidad. +- [ ] Mejorar pruebas. +- [ ] Mejorar documentación. +- [ ] Refactorizar código para las reglas de estilo de código deshabilitadas. Ver [phpmd.xml](phpmd.xml) y [.php_cs.dist](.php_cs.dist). ## Contribuir @@ -302,7 +302,7 @@ Este proyecto está licenciado bajo **licencia MIT**. Consulta el archivo [LICEN ## Copyright -2017 Josantonius, [josantonius.com](https://josantonius.com/) +2017 - 2018 Josantonius, [josantonius.com](https://josantonius.com/) Si te ha resultado útil, házmelo saber :wink: diff --git a/README.md b/README.md index 1d31ebb..80b5272 100644 --- a/README.md +++ b/README.md @@ -272,10 +272,10 @@ Run all previous tests: ## ☑ TODO -- [ ] Add new feature -- [ ] Improve tests -- [ ] Improve documentation -- [ ] Refactor code +- [ ] Add new feature. +- [ ] Improve tests. +- [ ] Improve documentation. +- [ ] Refactor code for disabled code style rules. See [phpmd.xml](phpmd.xml) and [.php_cs.dist](.php_cs.dist). ## Contribute @@ -302,7 +302,7 @@ This project is licensed under **MIT license**. See the [LICENSE](LICENSE) file ## Copyright -2017 Josantonius, [josantonius.com](https://josantonius.com/) +2017 - 2018 Josantonius, [josantonius.com](https://josantonius.com/) If you find it useful, let me know :wink: diff --git a/tests/Example.php b/tests/Example.php index 5851841..987102f 100644 --- a/tests/Example.php +++ b/tests/Example.php @@ -3,7 +3,7 @@ * Library for handling hooks. * * @author Josantonius - * @copyright 2017 (c) Josantonius - PHP-Hook + * @copyright 2017 - 2018 (c) Josantonius - PHP-Hook * @license https://opensource.org/licenses/MIT - The MIT License (MIT) * @link https://github.com/Josantonius/PHP-Hook * @since 1.0.8 @@ -12,93 +12,59 @@ /** * Example class. - * - * @since 1.0.8 */ class Example { /** * Class instance. - * - * @since 1.0.8 */ private static $singleton; - /** - * @since 1.0.8 - */ public static function getInstance() { return self::$singleton = new self; } - /** - * @since 1.0.8 - */ public static function singletonMethod() { return self::getInstance(); } - /** - * @since 1.0.8 - */ public function meta($title) { return 'meta-hook'; } - /** - * @since 1.0.8 - */ public function css() { return 'css-hook'; } - /** - * @since 1.0.8 - */ public function js() { return 'js-hook'; } - /** - * @since 1.0.8 - */ public function afterBody() { return 'after-hook'; } - /** - * @since 1.0.8 - */ public function slide() { return Hook::current(); } - /** - * @since 1.0.8 - */ public function form($input, $select) { return 'form-hook'; } - /** - * @since 1.0.8 - */ public function article() { return 'article-hook'; } - /** - * @since 1.0.8 - */ public function footer() { return 'footer-hook'; diff --git a/tests/HookTest.php b/tests/HookTest.php index 8a34f8c..af5b1f0 100644 --- a/tests/HookTest.php +++ b/tests/HookTest.php @@ -3,7 +3,7 @@ * Library for handling hooks. * * @author Josantonius - * @copyright 2017 (c) Josantonius - PHP-Hook + * @copyright 2017 - 2018 (c) Josantonius - PHP-Hook * @license https://opensource.org/licenses/MIT - The MIT License (MIT) * @link https://github.com/Josantonius/PHP-Hook * @since 1.0.6 @@ -14,8 +14,6 @@ /** * Tests class for Hook library. - * - * @since 1.0.6 */ final class HookTest extends TestCase { @@ -35,6 +33,8 @@ final class HookTest extends TestCase */ public function setUp() { + $hook = $this->Hook; + parent::setUp(); $this->Hook = new Hook; @@ -47,101 +47,102 @@ public function setUp() */ public function testIsInstanceOfHook() { - $actual = $this->Hook; - $this->assertInstanceOf('Josantonius\Hook\Hook', $actual); + $hook = $this->Hook; + + $this->assertInstanceOf('Josantonius\Hook\Hook', $this->Hook); } /** * Add action hook. - * - * @since 1.0.6 */ public function testAddAction() { + $hook = $this->Hook; + $this->assertTrue( - $this->Hook->addAction('css', ['Josantonius\Hook\Example', 'css']) + $hook::addAction('css', ['Josantonius\Hook\Example', 'css']) ); } /** * Add action hook with priority. - * - * @since 1.0.6 */ public function testAddActionWithPriority() { + $hook = $this->Hook; + $this->assertTrue( - $this->Hook->addAction('js', ['Josantonius\Hook\Example', 'js'], 1) + $hook::addAction('js', ['Josantonius\Hook\Example', 'js'], 1) ); } /** * Add action hook with priority and arguments number. - * - * @since 1.0.6 */ public function testAddActionWithPriorityAndArguments() { + $hook = $this->Hook; + $instance = new Example; $this->assertTrue( - $this->Hook->addAction('meta', [$instance, 'meta'], 2, 1) + $hook::addAction('meta', [$instance, 'meta'], 2, 1) ); } /** * Add action hook and set singleton method. - * - * @since 1.0.6 */ public function testAddActionWithCustomSingletonMethod() { - $this->Hook->setSingletonName('singletonMethod'); + $hook = $this->Hook; + + $hook::setSingletonName('singletonMethod'); $instance = call_user_func( 'Josantonius\Hook\Example::singletonMethod' ); $this->assertTrue( - $this->Hook->addAction('article', [$instance, 'article'], 3, 0) + $hook::addAction('article', [$instance, 'article'], 3, 0) ); } /** * Add multiple action hooks. - * - * @since 1.0.6 */ public function testAddMultipleActions() { + $hook = $this->Hook; + $instance = new Example; $this->assertTrue( - $this->Hook->addActions([ + $hook::addActions([ ['after-body', [$instance, 'afterBody'], 4, 0], ['footer', [$instance, 'footer'], 5, 0], - ]) + ]) ); } /** * Add multiple action hooks and set singleton method. - * - * @since 1.0.6 */ public function testAddMultipleActionsWithCustomSingletonMethod() { - $this->Hook->setSingletonName('singletonMethod'); + $hook = $this->Hook; + + $hook::setSingletonName('singletonMethod'); $instance = call_user_func( 'Josantonius\Hook\Example::singletonMethod' ); $this->assertTrue( - $this->Hook->addActions([ + $hook::addActions([ ['slide', [$instance, 'slide'], 6, 0], ['form', [$instance, 'form'], 7, 2], - ]) + ]) ); } @@ -152,12 +153,14 @@ public function testAddMultipleActionsWithCustomSingletonMethod() */ public function testIsAction() { + $hook = $this->Hook; + $this->assertTrue( - $this->Hook->isAction('meta') + $hook::isAction('meta') ); $this->assertTrue( - $this->Hook->isAction('form') + $hook::isAction('form') ); } @@ -168,50 +171,52 @@ public function testIsAction() */ public function testIsNotAction() { + $hook = $this->Hook; + $this->assertFalse( - $this->Hook->isAction('unknown') + $hook::isAction('unknown') ); } /** * Execute action hooks. - * - * @since 1.0.6 */ public function testDoActions() { - $this->assertContains('css-hook', $this->Hook->doAction('css')); - $this->assertContains('js-hook', $this->Hook->doAction('js')); - $this->assertContains('after-hook', $this->Hook->doAction('after-body')); - $this->assertContains('article-hook', $this->Hook->doAction('article')); - $this->assertContains('footer-hook', $this->Hook->doAction('footer')); + $hook = $this->Hook; + + $this->assertContains('css-hook', $hook::doAction('css')); + $this->assertContains('js-hook', $hook::doAction('js')); + $this->assertContains('after-hook', $hook::doAction('after-body')); + $this->assertContains('article-hook', $hook::doAction('article')); + $this->assertContains('footer-hook', $hook::doAction('footer')); } /** * Execute action hooks and get current hook. - * - * @since 1.0.6 */ public function testDoActionAndGetCurrentHook() { - $this->assertContains('slide', $this->Hook->doAction('slide')); + $hook = $this->Hook; + + $this->assertContains('slide', $hook::doAction('slide')); } /** * Execute action hook with arguments. - * - * @since 1.0.6 */ public function testDoActionsWithArguments() { + $hook = $this->Hook; + $this->assertContains( 'meta-hook', - $this->Hook->doAction('meta', 'The title') + $hook::doAction('meta', 'The title') ); $this->assertContains( 'form-hook', - $this->Hook->doAction('form', ['input', 'select']) + $hook::doAction('form', ['input', 'select']) ); } }