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 8f1b010..982753c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,5 +2,9 @@ All Notable changes to `laravel-quotes` will be documented in this file -## 2016-01-31 -- 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 7294273..fc0ff73 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ ![](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-quotes.svg?style=flat-square)](https://packagist.org/packages/unicodeveloper/laravel-quotes) 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/Quotes.php b/src/Quotes.php index c85c1f3..2d8b294 100644 --- a/src/Quotes.php +++ b/src/Quotes.php @@ -30,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"); } /** diff --git a/src/Quotes/programming.php b/src/Quotes/programming.php index 6bd0029..02404c2 100644 --- a/src/Quotes/programming.php +++ b/src/Quotes/programming.php @@ -61,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/tests/QuotesTest.php b/tests/QuotesTest.php index dfff5e8..3aac841 100644 --- a/tests/QuotesTest.php +++ b/tests/QuotesTest.php @@ -11,15 +11,114 @@ 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 the private GetQuotes method for design category + * @return boolean + */ + public function testGetQuotesWithDesignCategory() + { + $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); + } + /** - * Test that true does in fact equal true + * 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. */ - public function testTrueIsTrue() + private function invokeMethod(&$object, $methodName, array $parameters = array()) { - $this->assertTrue(true); + $reflection = new ReflectionClass(get_class($object)); + $method = $reflection->getMethod($methodName); + $method->setAccessible(true); + + return $method->invokeArgs($object, $parameters); } + } \ No newline at end of file