From 554b7193a5ff514c48456812cb721f490bbb7696 Mon Sep 17 00:00:00 2001 From: Robert Podwika Date: Wed, 15 Jul 2015 00:08:55 +0200 Subject: [PATCH] Better tests directory structure with namespaces, readme fixes, library updates in lock --- composer.json | 3 +- composer.lock | 101 +++++++++++------- .../{ => Singleton}/Singleton.php | 2 +- .../{ => Singleton}/SingletonSample.php | 2 +- .../{ => Singleton}/SingletonTrait.php | 2 +- src/Antipatterns/{ => Singleton}/readme.md | 0 src/Behavioral/Adapter/readme.md | 2 +- src/Behavioral/Memento/readme.md | 2 +- src/Behavioral/Observer/readme.md | 2 +- src/Structural/Decorator/readme.md | 2 +- .../Singleton}/SingletonTest.php | 16 +-- .../{ => Behavioral/Adapter}/AdapterTest.php | 4 +- .../Memento}/SimpleBasketTest.php | 4 +- .../Observer}/ObserverTest.php | 3 +- .../Strategy}/RiskCalculatorTest.php | 8 +- .../Factory}/AnyphoneFactoryTest.php | 4 +- .../{ => Creational/Factory}/FactoryTest.php | 3 +- .../Decorator}/DecoratorTest.php | 6 +- 18 files changed, 101 insertions(+), 65 deletions(-) rename src/Antipatterns/{ => Singleton}/Singleton.php (91%) rename src/Antipatterns/{ => Singleton}/SingletonSample.php (79%) rename src/Antipatterns/{ => Singleton}/SingletonTrait.php (88%) rename src/Antipatterns/{ => Singleton}/readme.md (100%) rename tests/{ => Antipatterns/Singleton}/SingletonTest.php (60%) rename tests/{ => Behavioral/Adapter}/AdapterTest.php (90%) rename tests/{ => Behavioral/Memento}/SimpleBasketTest.php (92%) rename tests/{ => Behavioral/Observer}/ObserverTest.php (92%) rename tests/{ => Behavioral/Strategy}/RiskCalculatorTest.php (76%) rename tests/{ => Creational/Factory}/AnyphoneFactoryTest.php (91%) rename tests/{ => Creational/Factory}/FactoryTest.php (92%) rename tests/{ => Structural/Decorator}/DecoratorTest.php (90%) diff --git a/composer.json b/composer.json index d162d64..d4664a1 100755 --- a/composer.json +++ b/composer.json @@ -37,7 +37,8 @@ ], "autoload": { "psr-4": { - "Rpodwika\\Designpatterns\\": "src" + "Rpodwika\\Designpatterns\\": "src/", + "Rpodwika\\Tests\\Designpatterns\\": "tests/" } } } diff --git a/composer.lock b/composer.lock index 8650501..2e766d6 100755 --- 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" ], - "hash": "7229aea1b18626fd429e2801c489b1ef", + "hash": "9517f595cc3b82e36172028ede5e7880", "packages": [ { "name": "doctrine/instantiator", @@ -266,16 +266,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "2.1.7", + "version": "2.1.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "07e27765596d72c378a6103e80da5d84e802f1e4" + "reference": "6044546998c7627ab997501a3d0db972b3db9790" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/07e27765596d72c378a6103e80da5d84e802f1e4", - "reference": "07e27765596d72c378a6103e80da5d84e802f1e4", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6044546998c7627ab997501a3d0db972b3db9790", + "reference": "6044546998c7627ab997501a3d0db972b3db9790", "shasum": "" }, "require": { @@ -324,7 +324,7 @@ "testing", "xunit" ], - "time": "2015-06-30 06:52:35" + "time": "2015-07-13 11:25:58" }, { "name": "phpunit/php-file-iterator", @@ -506,16 +506,16 @@ }, { "name": "phpunit/phpunit", - "version": "4.7.6", + "version": "4.7.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "0ebabb4cda7d066be8391dfdbaf57fe70ac9a99b" + "reference": "9b97f9d807b862c2de2a36e86690000801c85724" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0ebabb4cda7d066be8391dfdbaf57fe70ac9a99b", - "reference": "0ebabb4cda7d066be8391dfdbaf57fe70ac9a99b", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9b97f9d807b862c2de2a36e86690000801c85724", + "reference": "9b97f9d807b862c2de2a36e86690000801c85724", "shasum": "" }, "require": { @@ -574,7 +574,7 @@ "testing", "xunit" ], - "time": "2015-06-30 06:53:57" + "time": "2015-07-13 11:28:34" }, { "name": "phpunit/phpunit-mock-objects", @@ -1115,18 +1115,37 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2015-06-21 13:59:46" }, + { + "name": "sebastianbergmann/phpcov", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpcov.git", + "reference": "1.1.0" + }, + "dist": { + "type": "zip", + "url": "https://github.com/sebastianbergmann/phpcov/archive/1.1.0.zip", + "reference": null, + "shasum": null + }, + "bin": [ + "phpcov.php" + ], + "type": "library" + }, { "name": "symfony/config", - "version": "v2.7.1", + "version": "v2.7.2", "source": { "type": "git", "url": "https://github.com/symfony/Config.git", - "reference": "58ded81f1f582a87c528ef3dae9a859f78b5f374" + "reference": "6c905bbed1e728226de656e4c07d620dfe9e80d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/58ded81f1f582a87c528ef3dae9a859f78b5f374", - "reference": "58ded81f1f582a87c528ef3dae9a859f78b5f374", + "url": "https://api.github.com/repos/symfony/Config/zipball/6c905bbed1e728226de656e4c07d620dfe9e80d9", + "reference": "6c905bbed1e728226de656e4c07d620dfe9e80d9", "shasum": "" }, "require": { @@ -1163,20 +1182,20 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2015-06-11 14:06:56" + "time": "2015-07-09 16:07:40" }, { "name": "symfony/console", - "version": "v2.7.1", + "version": "v2.7.2", "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "564398bc1f33faf92fc2ec86859983d30eb81806" + "reference": "8cf484449130cabfd98dcb4694ca9945802a21ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/564398bc1f33faf92fc2ec86859983d30eb81806", - "reference": "564398bc1f33faf92fc2ec86859983d30eb81806", + "url": "https://api.github.com/repos/symfony/Console/zipball/8cf484449130cabfd98dcb4694ca9945802a21ed", + "reference": "8cf484449130cabfd98dcb4694ca9945802a21ed", "shasum": "" }, "require": { @@ -1220,20 +1239,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2015-06-10 15:30:22" + "time": "2015-07-09 16:07:40" }, { "name": "symfony/event-dispatcher", - "version": "v2.7.1", + "version": "v2.7.2", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "be3c5ff8d503c46768aeb78ce6333051aa6f26d9" + "reference": "9310b5f9a87ec2ea75d20fec0b0017c77c66dac3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/be3c5ff8d503c46768aeb78ce6333051aa6f26d9", - "reference": "be3c5ff8d503c46768aeb78ce6333051aa6f26d9", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/9310b5f9a87ec2ea75d20fec0b0017c77c66dac3", + "reference": "9310b5f9a87ec2ea75d20fec0b0017c77c66dac3", "shasum": "" }, "require": { @@ -1278,20 +1297,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2015-06-08 09:37:21" + "time": "2015-06-18 19:21:56" }, { "name": "symfony/filesystem", - "version": "v2.7.1", + "version": "v2.7.2", "source": { "type": "git", "url": "https://github.com/symfony/Filesystem.git", - "reference": "a0d43eb3e17d4f4c6990289805a488a0482a07f3" + "reference": "2d7b2ddaf3f548f4292df49a99d19c853d43f0b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/a0d43eb3e17d4f4c6990289805a488a0482a07f3", - "reference": "a0d43eb3e17d4f4c6990289805a488a0482a07f3", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/2d7b2ddaf3f548f4292df49a99d19c853d43f0b8", + "reference": "2d7b2ddaf3f548f4292df49a99d19c853d43f0b8", "shasum": "" }, "require": { @@ -1327,20 +1346,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2015-06-08 09:37:21" + "time": "2015-07-09 16:07:40" }, { "name": "symfony/stopwatch", - "version": "v2.7.1", + "version": "v2.7.2", "source": { "type": "git", "url": "https://github.com/symfony/Stopwatch.git", - "reference": "c653f1985f6c2b7dbffd04d48b9c0a96aaef814b" + "reference": "b07a866719bbac5294c67773340f97b871733310" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/c653f1985f6c2b7dbffd04d48b9c0a96aaef814b", - "reference": "c653f1985f6c2b7dbffd04d48b9c0a96aaef814b", + "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/b07a866719bbac5294c67773340f97b871733310", + "reference": "b07a866719bbac5294c67773340f97b871733310", "shasum": "" }, "require": { @@ -1376,20 +1395,20 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "time": "2015-06-04 20:11:48" + "time": "2015-07-01 18:23:16" }, { "name": "symfony/yaml", - "version": "v2.7.1", + "version": "v2.7.2", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160" + "reference": "4bfbe0ed3909bfddd75b70c094391ec1f142f860" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/9808e75c609a14f6db02f70fccf4ca4aab53c160", - "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/4bfbe0ed3909bfddd75b70c094391ec1f142f860", + "reference": "4bfbe0ed3909bfddd75b70c094391ec1f142f860", "shasum": "" }, "require": { @@ -1425,7 +1444,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2015-06-10 15:30:22" + "time": "2015-07-01 11:25:50" } ], "packages-dev": [], diff --git a/src/Antipatterns/Singleton.php b/src/Antipatterns/Singleton/Singleton.php similarity index 91% rename from src/Antipatterns/Singleton.php rename to src/Antipatterns/Singleton/Singleton.php index ccd0e47..63d29b6 100755 --- a/src/Antipatterns/Singleton.php +++ b/src/Antipatterns/Singleton/Singleton.php @@ -6,7 +6,7 @@ * Time: 14:40 */ -namespace Rpodwika\Designpatterns\Antipatterns; +namespace Rpodwika\Designpatterns\Antipatterns\Singleton; class Singleton { diff --git a/src/Antipatterns/SingletonSample.php b/src/Antipatterns/Singleton/SingletonSample.php similarity index 79% rename from src/Antipatterns/SingletonSample.php rename to src/Antipatterns/Singleton/SingletonSample.php index a84324e..a3400b4 100644 --- a/src/Antipatterns/SingletonSample.php +++ b/src/Antipatterns/Singleton/SingletonSample.php @@ -6,7 +6,7 @@ * Time: 21:53 */ -namespace Rpodwika\Designpatterns\Antipatterns; +namespace Rpodwika\Designpatterns\Antipatterns\Singleton; class SingletonSample diff --git a/src/Antipatterns/SingletonTrait.php b/src/Antipatterns/Singleton/SingletonTrait.php similarity index 88% rename from src/Antipatterns/SingletonTrait.php rename to src/Antipatterns/Singleton/SingletonTrait.php index 2483a64..126c51c 100644 --- a/src/Antipatterns/SingletonTrait.php +++ b/src/Antipatterns/Singleton/SingletonTrait.php @@ -6,7 +6,7 @@ * Time: 21:49 */ -namespace Rpodwika\Designpatterns\Antipatterns; +namespace Rpodwika\Designpatterns\Antipatterns\Singleton; trait SingletonTrait diff --git a/src/Antipatterns/readme.md b/src/Antipatterns/Singleton/readme.md similarity index 100% rename from src/Antipatterns/readme.md rename to src/Antipatterns/Singleton/readme.md diff --git a/src/Behavioral/Adapter/readme.md b/src/Behavioral/Adapter/readme.md index ec1fa2d..64b25a1 100644 --- a/src/Behavioral/Adapter/readme.md +++ b/src/Behavioral/Adapter/readme.md @@ -17,4 +17,4 @@ amount of resources. ##How to use -See [tests/AdapterTest](/tests/AdapterTest.php) \ No newline at end of file +See [tests/AdapterTest](/tests/Behavioral/Adapter/AdapterTest.php) \ No newline at end of file diff --git a/src/Behavioral/Memento/readme.md b/src/Behavioral/Memento/readme.md index 4cf02ac..47a6910 100644 --- a/src/Behavioral/Memento/readme.md +++ b/src/Behavioral/Memento/readme.md @@ -10,7 +10,7 @@ object encapsulation. ##How to use -See [tests/SimpleBasketTest](/tests/SimpleBasketTest.php) +See [tests/SimpleBasketTest](/tests/Behavioral/Memento/SimpleBasketTest.php) ##Notice diff --git a/src/Behavioral/Observer/readme.md b/src/Behavioral/Observer/readme.md index 6ad1c60..a213059 100644 --- a/src/Behavioral/Observer/readme.md +++ b/src/Behavioral/Observer/readme.md @@ -24,7 +24,7 @@ observers [AuthMailer.php](AuthMailer.php) - another observer listens for 'logged in' and 'logged out' state change. It pretends to send emails after user logged in and out. -If you want to know how it exactly works check [ObserverTest.php](/tests/ObserverTest.php) +If you want to know how it exactly works check [ObserverTest.php](/tests/Behavioral/Observer/ObserverTest.php) #Example of usage diff --git a/src/Structural/Decorator/readme.md b/src/Structural/Decorator/readme.md index 4cf16b3..795686b 100644 --- a/src/Structural/Decorator/readme.md +++ b/src/Structural/Decorator/readme.md @@ -13,4 +13,4 @@ Decorator can be used to add behavior to class statically or dynamically. ##How to use -See [tests/DecoratorTest](/tests/DecoratorTest.php) \ No newline at end of file +See [tests/DecoratorTest](/tests/Structural/Decorator/DecoratorTest.php) \ No newline at end of file diff --git a/tests/SingletonTest.php b/tests/Antipatterns/Singleton/SingletonTest.php similarity index 60% rename from tests/SingletonTest.php rename to tests/Antipatterns/Singleton/SingletonTest.php index 4ba9e12..8df0bfe 100755 --- a/tests/SingletonTest.php +++ b/tests/Antipatterns/Singleton/SingletonTest.php @@ -1,5 +1,7 @@ assertTrue(is_object($singletonObject)); $this->assertNotNull($singletonObject); - $this->assertInstanceOf('Rpodwika\Designpatterns\Antipatterns\Singleton', $singletonObject); + $this->assertInstanceOf('Rpodwika\Designpatterns\Antipatterns\Singleton\Singleton', $singletonObject); } /** - * @covers \Rpodwika\Designpatterns\Antipatterns\Singleton + * @covers \Rpodwika\Designpatterns\Antipatterns\Singleton\Singleton */ public function testDoSomethingReturnsProperObject() { @@ -32,7 +34,7 @@ public function testDoSomethingReturnsProperObject() } /** - * @covers \Rpodwika\Designpatterns\Antipatterns\SingletonTrait + * @covers \Rpodwika\Designpatterns\Antipatterns\Singleton\SingletonTrait */ public function testSingletonTrait() { diff --git a/tests/AdapterTest.php b/tests/Behavioral/Adapter/AdapterTest.php similarity index 90% rename from tests/AdapterTest.php rename to tests/Behavioral/Adapter/AdapterTest.php index 1be796b..da90314 100644 --- a/tests/AdapterTest.php +++ b/tests/Behavioral/Adapter/AdapterTest.php @@ -1,5 +1,7 @@