diff --git a/README.md b/README.md index c57bb09..3ff19f7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Laps — light WordPress profiler [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Rarst/laps/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Rarst/laps/?branch=master) +[![Build Status](https://scrutinizer-ci.com/g/Rarst/laps/badges/build.png?b=master)](https://scrutinizer-ci.com/g/Rarst/laps/build-status/master) +[![Code Coverage](https://scrutinizer-ci.com/g/Rarst/laps/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Rarst/laps/?branch=master) [![Latest Stable Version](https://poser.pugx.org/rarst/laps/v/stable)](https://packagist.org/packages/rarst/laps) [![Total Downloads](https://poser.pugx.org/rarst/laps/downloads)](https://packagist.org/packages/rarst/laps) diff --git a/composer.json b/composer.json index df4c614..f6f8001 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,11 @@ "Rarst\\Laps\\" : "src/" } }, + "autoload-dev": { + "psr-4": { + "Rarst\\Laps\\Tests\\": "tests/" + } + }, "require" : { "composer/installers": "~1.0", "symfony/stopwatch" : "^3.4.4", @@ -26,6 +31,7 @@ "pimple/pimple" : "^3.2.3" }, "require-dev": { - "twbs/bootstrap": "~3.2" + "twbs/bootstrap": "~3.2", + "brain/monkey" : "^2.2" } } diff --git a/composer.lock b/composer.lock index b3fa2b3..23d7cd3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "10f3fc63a5cb37afcc5e4384bc58270a", + "content-hash": "6e02995f57446a59552f7e5a84a75278", "packages": [ { "name": "composer/installers", @@ -322,6 +322,224 @@ } ], "packages-dev": [ + { + "name": "antecedent/patchwork", + "version": "2.1.7", + "source": { + "type": "git", + "url": "https://github.com/antecedent/patchwork.git", + "reference": "00eb113c84fac5446a7d3d1c389aa91fb3da7222" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/antecedent/patchwork/zipball/00eb113c84fac5446a7d3d1c389aa91fb3da7222", + "reference": "00eb113c84fac5446a7d3d1c389aa91fb3da7222", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignas Rudaitis", + "email": "ignas.rudaitis@gmail.com" + } + ], + "description": "Method redefinition (monkey-patching) functionality for PHP.", + "homepage": "http://patchwork2.org/", + "keywords": [ + "aop", + "aspect", + "interception", + "monkeypatching", + "redefinition", + "runkit", + "testing" + ], + "time": "2017-12-21T20:03:40+00:00" + }, + { + "name": "brain/monkey", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/Brain-WP/BrainMonkey.git", + "reference": "ed9e0698bc1292f33698719da8ca1aa2e18acc51" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Brain-WP/BrainMonkey/zipball/ed9e0698bc1292f33698719da8ca1aa2e18acc51", + "reference": "ed9e0698bc1292f33698719da8ca1aa2e18acc51", + "shasum": "" + }, + "require": { + "antecedent/patchwork": "^2.0", + "mockery/mockery": ">=0.9 <2", + "php": ">=5.6.0" + }, + "require-dev": { + "phpunit/phpunit": "~5.7.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-version/1": "1.x-dev", + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Brain\\Monkey\\": "src/" + }, + "files": [ + "inc/api.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Giuseppe Mazzapica", + "email": "giuseppe.mazzapica@gmail.com", + "homepage": "https://gmazzap.me", + "role": "Developer" + } + ], + "description": "Mocking utility for PHP functions and WordPress plugin API", + "keywords": [ + "Monkey Patching", + "interception", + "mock", + "mock functions", + "mockery", + "patchwork", + "redefinition", + "runkit", + "test", + "testing" + ], + "time": "2017-12-01T16:32:09+00:00" + }, + { + "name": "hamcrest/hamcrest-php", + "version": "v2.0.0", + "source": { + "type": "git", + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "776503d3a8e85d4f9a1148614f95b7a608b046ad" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/776503d3a8e85d4f9a1148614f95b7a608b046ad", + "reference": "776503d3a8e85d4f9a1148614f95b7a608b046ad", + "shasum": "" + }, + "require": { + "php": "^5.3|^7.0" + }, + "replace": { + "cordoval/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "kodova/hamcrest-php": "*" + }, + "require-dev": { + "phpunit/php-file-iterator": "1.3.3", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "hamcrest" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" + ], + "time": "2016-01-20T08:20:44+00:00" + }, + { + "name": "mockery/mockery", + "version": "1.0", + "source": { + "type": "git", + "url": "https://github.com/mockery/mockery.git", + "reference": "1bac8c362b12f522fdd1f1fa3556284c91affa38" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mockery/mockery/zipball/1bac8c362b12f522fdd1f1fa3556284c91affa38", + "reference": "1bac8c362b12f522fdd1f1fa3556284c91affa38", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "~2.0", + "lib-pcre": ">=7.0", + "php": ">=5.6.0" + }, + "require-dev": { + "phpunit/phpunit": "~5.7|~6.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Mockery": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "http://blog.astrumfutura.com" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "http://davedevelopment.co.uk" + } + ], + "description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.", + "homepage": "http://github.com/mockery/mockery", + "keywords": [ + "BDD", + "TDD", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "test", + "test double", + "testing" + ], + "time": "2017-10-06T16:20:43+00:00" + }, { "name": "twbs/bootstrap", "version": "v3.3.7", diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..22eed2f --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,12 @@ + + + + tests + + + + + src + + + \ No newline at end of file diff --git a/tests/Asset_ManagerTest.php b/tests/Asset_ManagerTest.php new file mode 100644 index 0000000..f4f0cfd --- /dev/null +++ b/tests/Asset_ManagerTest.php @@ -0,0 +1,35 @@ +assertTrue( has_action( 'wp_enqueue_scripts', [ $manager, 'enqueue_scripts' ] ) ); + $this->assertTrue( has_action( 'admin_enqueue_scripts', [ $manager, 'enqueue_scripts' ] ) ); + + return $manager; + } + + + /** + * @depends test__construct + */ + public function testEnqueue_scripts( Asset_Manager $manager ) { + + Functions\expect( 'wp_register_script' )->once(); + Functions\expect( 'wp_register_style' )->once(); + Functions\expect( 'plugins_url' )->zeroOrMoreTimes(); + Functions\expect( 'is_admin_bar_showing' )->once()->andReturn( true ); + Functions\expect( 'wp_enqueue_script' )->once(); + Functions\expect( 'wp_enqueue_style' )->once(); + + $manager->enqueue_scripts(); + } +} diff --git a/tests/LapsTestCase.php b/tests/LapsTestCase.php new file mode 100644 index 0000000..d61f578 --- /dev/null +++ b/tests/LapsTestCase.php @@ -0,0 +1,22 @@ +