diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..65ec400 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +vendor +composer.lock +build \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index c54b003..2185801 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,11 +13,15 @@ matrix: install: travis_retry composer install --no-interaction --prefer-source script: + - mkdir -p build/logs + - php vendor/bin/phpunit -c phpunit.xml.dist - phpunit --coverage-text --coverage-clover=coverage.clover + - phpunit --coverage-clover build/logs/clover.xml after_script: - wget https://scrutinizer-ci.com/ocular.phar - php ocular.phar code-coverage:upload --format=php-clover coverage.clover + - travis_retry php vendor/bin/coveralls -v notifications: slack: red-creek:5lI8ybvl6YTcCNPosh4TE13h \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a027f3..982753c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,5 +2,9 @@ All Notable changes to `laravel-quotes` will be documented in this file -## 2015-11-04 -- Initial release \ No newline at end of file +## 2016-01-31 - 1.0.0 +- Initial release + +## 2016-01-31 - 1.0.1 +- Add BlessUp() method to retrieve all keys to success that are blessed up! +- Add text to voice ability for DJkhaled quotes. The quotes are automatically read out via the terminal when you run `php artisan djkhaled:inspire`. Currently works on Mac \ No newline at end of file diff --git a/README.md b/README.md index fd07d9b..fc0ff73 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,9 @@ ![](https://img.shields.io/badge/unicodeveloper-approved-brightgreen.svg) [![License](https://poser.pugx.org/unicodeveloper/laravel-quotes/license.svg)](LICENSE.md) [![Build Status](https://img.shields.io/travis/unicodeveloper/laravel-quotes.svg)](https://travis-ci.org/unicodeveloper/laravel-quotes) +[![Coverage Status](https://coveralls.io/repos/github/unicodeveloper/laravel-quotes/badge.svg?branch=master)](https://coveralls.io/github/unicodeveloper/laravel-quotes?branch=master) [![Quality Score](https://img.shields.io/scrutinizer/g/unicodeveloper/laravel-quotes.svg?style=flat-square)](https://scrutinizer-ci.com/g/unicodeveloper/laravel-quotes) -[![Total Downloads](https://img.shields.io/packagist/dt/unicodeveloper/laravel-quotesc.svg?style=flat-square)](https://packagist.org/packages/unicodeveloper/laravel-quotes) +[![Total Downloads](https://img.shields.io/packagist/dt/unicodeveloper/laravel-quotes.svg?style=flat-square)](https://packagist.org/packages/unicodeveloper/laravel-quotes) > A Laravel 5 Package for providing all kinds of quotes, from PROGRAMMING to DESIGN to DJKHALED Quotes @@ -31,12 +32,12 @@ Also, register the Facade like so: ```php 'aliases' => [ ... - 'Quotes' => Unicodeveloper\Quotes\Facades\QuotesFacade::class, + 'Quotes' => Unicodeveloper\Quotes\Facades\Quotes::class, ... ] ``` -Register the Artisan commands by adding this to the `$commands` array in `Kernel.php` +Register the Artisan commands by adding this to the `$commands` array in `App/Console/Kernel.php` ```php ** diff --git a/composer.json b/composer.json index e83d119..51686eb 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,8 @@ }, "require-dev": { "phpunit/phpunit" : "4.*", - "scrutinizer/ocular": "~1.1" + "scrutinizer/ocular": "~1.1", + "satooshi/php-coveralls": "^0.7.0" }, "autoload": { "psr-4": { diff --git a/src/Commands/Design.php b/src/Commands/Design.php index 9249669..2e46d53 100644 --- a/src/Commands/Design.php +++ b/src/Commands/Design.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Unicodeveloper\Quotes\Commands; use Illuminate\Console\Command; diff --git a/src/Commands/Djkhaled.php b/src/Commands/Djkhaled.php index 55f8b0b..45ec492 100644 --- a/src/Commands/Djkhaled.php +++ b/src/Commands/Djkhaled.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Unicodeveloper\Quotes\Commands; use Illuminate\Console\Command; @@ -29,6 +38,9 @@ class Djkhaled extends Command public function handle() { $quotes = new Quotes(); - $this->comment(PHP_EOL.$quotes->djkhaled()->anotherOne().PHP_EOL); + $keyToSuccess = $quotes->djkhaled()->anotherOne(); + + $this->comment(PHP_EOL.$keyToSuccess.PHP_EOL); + shell_exec("say {$keyToSuccess}"); } } diff --git a/src/Commands/Programming.php b/src/Commands/Programming.php index 1c0225b..a3ea685 100644 --- a/src/Commands/Programming.php +++ b/src/Commands/Programming.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Unicodeveloper\Quotes\Commands; use Illuminate\Console\Command; diff --git a/src/Facades/Quotes.php b/src/Facades/Quotes.php index dc08093..3812b0b 100644 --- a/src/Facades/Quotes.php +++ b/src/Facades/Quotes.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Unicodeveloper\Quotes\Facades; use Illuminate\Support\Facades\Facade; diff --git a/src/Quotes.php b/src/Quotes.php index 7f20655..2d8b294 100644 --- a/src/Quotes.php +++ b/src/Quotes.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Unicodeveloper\Quotes; use GuzzleHttp\Client; @@ -21,10 +30,10 @@ class Quotes { private function getQuotes($category = null) { if(is_null($category)) { - return require_once("Quotes/programming.php"); + return require("Quotes/programming.php"); } - return require_once("Quotes/{$category}.php"); + return require("Quotes/{$category}.php"); } /** @@ -87,4 +96,21 @@ public function all() return $this->quotes->all(); } + /** + * Get all the Keys to Success that are Blessed Up! + * @return array + */ + public function blessUp() + { + $blessUp = []; + + foreach($this->quotes->all() as $keys => $success) { + if(preg_match('/\bbless up\b/i', $success)) { + array_push($blessUp, $success); + } + } + + return $blessUp; + } + } \ No newline at end of file diff --git a/src/Quotes/design.php b/src/Quotes/design.php index ba69e7c..b30b0ab 100644 --- a/src/Quotes/design.php +++ b/src/Quotes/design.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + return [ /* diff --git a/src/Quotes/djkhaled.php b/src/Quotes/djkhaled.php index bde0503..2fcc4a2 100644 --- a/src/Quotes/djkhaled.php +++ b/src/Quotes/djkhaled.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + return [ /* @@ -13,7 +22,7 @@ | */ - "The Key is to be honest, Be honest, but don't play yourself", + "The Key is to be honest, Be honest, but dont play yourself", "The Key is never be afraid of being yourself", "All the great ones jetski", "Major Key: Have good relationships. Keep your face clean out there", @@ -24,10 +33,10 @@ "The Key to success is to have a hammock", "Egg whites, Chicken Sausage, Water. They don't want you to eat", "Watch your back, but more importantly when you get out the shower, dry your back. Its a cold world out there", - "They don't want you to be healthy", + "They dont want you to be healthy", "The key is to have every key, the key to open every door", "Be a Star. Be a Superstar", - "They don't want you to win", + "They dont want you to win", "Its so real out here right now, the only reason why you see anything is cuz i got the flash on", "Almond Milk + Cinnamon Toast Crunch = Major Key To Success", "It's important to shape up your hedges. Its like getting a haircut", @@ -37,8 +46,8 @@ "Cocoa Butter is the key", "The key to more success is to get a massage once a week", "The key to more success is to have a lot of pillows. A lot.", - "Bless Up. Don't play yourself", - "Every conversation you have, including your best friend, start off saing 'This is off the record'", + "Bless Up. Dont play yourself", + "Every conversation you have, including your best friend, start off saing, This is off the record", "Bless up. Egg Whites, Turkey Bacon, Hashbrown, Water", "Major Key, Get a pedicure and manicure once a week", ]; diff --git a/src/Quotes/programming.php b/src/Quotes/programming.php index cddad68..02404c2 100644 --- a/src/Quotes/programming.php +++ b/src/Quotes/programming.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + return [ /* @@ -52,4 +61,6 @@ "One of my most productive days was throwing away 1000 lines of code. - Ken Thompson", "Deleted code is debugged code. - Jeff Sickel", "Controlling complexity is the essence of computer programming. - Brian Kernighan", + "Just heard a QA \"Engineeer\" ask a customer on the phone - \"What made you wanna do THAT!??\" - Kevin Marois", + "The main purpose of multidimensional arrays in C++ is to confuse beginners and generate an endless stream of questions about how to allocate them dynamically, about how to delete them, or why they can't be converted to pointers to pointers. – R. Martinho Fernandes", ]; diff --git a/src/QuotesServiceProvider.php b/src/QuotesServiceProvider.php index 741aca5..01298a6 100644 --- a/src/QuotesServiceProvider.php +++ b/src/QuotesServiceProvider.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Unicodeveloper\Quotes; use Illuminate\Support\ServiceProvider; diff --git a/tests/QuotesTest.php b/tests/QuotesTest.php index 0f95f15..3aac841 100644 --- a/tests/QuotesTest.php +++ b/tests/QuotesTest.php @@ -1,16 +1,124 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Unicodeveloper\Quotes\Test; +use ReflectionClass; use PHPUnit_Framework_TestCase; +use Unicodeveloper\Quotes\Quotes; +use Illuminate\Support\Collection; class QuotesTest extends PHPUnit_Framework_TestCase { + protected $quotes; + + public function setUp() + { + $this->quotes = new Quotes; + } + /** - * Test that true does in fact equal true + * Test the private GetQuotes method for design category + * @return boolean */ - public function testTrueIsTrue() + public function testGetQuotesWithDesignCategory() { - $this->assertTrue(true); + $result = $this->invokeMethod($this->quotes, 'getQuotes', ['design']); + + $this->assertEquals($this->getTotalNumberOfQuotes('design'), count($result)); } + + /** + * Test the private GetQuotes method for programming category + * @return boolean + */ + public function testGetQuotesWithProgrammingCategory() + { + $result = $this->invokeMethod($this->quotes, 'getQuotes', ['programming']); + + $this->assertEquals($this->getTotalNumberOfQuotes('programming'), count($result)); + } + + /** + * Test the private GetQuotes method for djkhaled category + * @return boolean + */ + public function testGetQuotesWithDjkhaledCategory() + { + $result = $this->invokeMethod($this->quotes, 'getQuotes', ['djkhaled']); + + $this->assertEquals($this->getTotalNumberOfQuotes('djkhaled'), count($result)); + } + + /** + * Test the private GetQuotes method if there is no category input + * @return boolean + */ + public function testGetQuotesWithNullCategory() + { + $result = $this->invokeMethod($this->quotes, 'getQuotes', []); + + $this->assertEquals($this->getTotalNumberOfQuotes('programming'), count($result)); + } + + /** + * Test random() actually returns a random quote + * @return boolean + */ + public function testRandomReturnsARandomQuote() + { + $result = $this->quotes->design()->random(); + + $this->assertEquals(1, count($result)); + } + + /** + * Test all() actually returns all the quotes + * @return boolean + */ + public function testAllReturnsAllQuotes() + { + $result = $this->quotes->programming()->all(); + + $this->assertEquals($this->getTotalNumberOfQuotes('programming'), count($result)); + } + + /** + * Get the number of results based on the category of quotes + * @param $category + * @return integer + */ + private function getTotalNumberOfQuotes($category) + { + $result = require( __DIR__ . "/../src/Quotes/{$category}.php"); + + return count($result); + } + + /** + * Call protected/private method of a class. + * + * @param object &$object Instantiated object that we will run method on. + * @param string $methodName Method name to call + * @param array $parameters Array of parameters to pass into method. + * + * @return mixed Method return. + */ + private function invokeMethod(&$object, $methodName, array $parameters = array()) + { + $reflection = new ReflectionClass(get_class($object)); + $method = $reflection->getMethod($methodName); + $method->setAccessible(true); + + return $method->invokeArgs($object, $parameters); + } + } \ No newline at end of file