Skip to content

Commit

Permalink
Better tests directory structure with namespaces, readme fixes, libra…
Browse files Browse the repository at this point in the history
…ry updates in lock
  • Loading branch information
rpodwika committed Jul 14, 2015
1 parent 666308c commit 554b719
Show file tree
Hide file tree
Showing 18 changed files with 101 additions and 65 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
],
"autoload": {
"psr-4": {
"Rpodwika\\Designpatterns\\": "src"
"Rpodwika\\Designpatterns\\": "src/",
"Rpodwika\\Tests\\Designpatterns\\": "tests/"
}
}
}
101 changes: 60 additions & 41 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Time: 14:40
*/

namespace Rpodwika\Designpatterns\Antipatterns;
namespace Rpodwika\Designpatterns\Antipatterns\Singleton;

class Singleton
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Time: 21:53
*/

namespace Rpodwika\Designpatterns\Antipatterns;
namespace Rpodwika\Designpatterns\Antipatterns\Singleton;


class SingletonSample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Time: 21:49
*/

namespace Rpodwika\Designpatterns\Antipatterns;
namespace Rpodwika\Designpatterns\Antipatterns\Singleton;


trait SingletonTrait
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/Behavioral/Adapter/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ amount of resources.

##How to use

See [tests/AdapterTest](/tests/AdapterTest.php)
See [tests/AdapterTest](/tests/Behavioral/Adapter/AdapterTest.php)
2 changes: 1 addition & 1 deletion src/Behavioral/Memento/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object encapsulation.

##How to use

See [tests/SimpleBasketTest](/tests/SimpleBasketTest.php)
See [tests/SimpleBasketTest](/tests/Behavioral/Memento/SimpleBasketTest.php)

##Notice

Expand Down
2 changes: 1 addition & 1 deletion src/Behavioral/Observer/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/Structural/Decorator/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
See [tests/DecoratorTest](/tests/Structural/Decorator/DecoratorTest.php)
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
<?php

namespace Rpodwika\Designpatterns\Tests\Antipatterns\Singleton\Singleton;

/**
* Created by PhpStorm.
* User: robertpodwikamac
* Date: 05.07.15
* Time: 14:38
*/

use Rpodwika\Designpatterns\Antipatterns\Singleton;
use Rpodwika\Designpatterns\Antipatterns\SingletonSample;
use Rpodwika\Designpatterns\Antipatterns\Singleton\Singleton;
use Rpodwika\Designpatterns\Antipatterns\Singleton\SingletonSample;

class SingletonTest extends PHPUnit_Framework_TestCase
class SingletonTest extends \PHPUnit_Framework_TestCase
{
/**
* @covers \Rpodwika\Designpatterns\Antipatterns\Singleton
* @covers \Rpodwika\Designpatterns\Antipatterns\Singleton\Singleton
*/
public function testSingletonReturnsObject()
{
$singletonObject = Singleton::getInstance();
$this->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()
{
$this->assertEquals('I do something', Singleton::getInstance()->doSomething());
}

/**
* @covers \Rpodwika\Designpatterns\Antipatterns\SingletonTrait
* @covers \Rpodwika\Designpatterns\Antipatterns\Singleton\SingletonTrait
*/
public function testSingletonTrait()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Rpodwika\Designpatterns\Tests\Behavioral\Adapter;

/**
* Created by PhpStorm.
* User: robertpodwikamac
Expand All @@ -10,7 +12,7 @@
use \Rpodwika\Designpatterns\Behavioral\Adapter\EmailClient;
use \Rpodwika\Designpatterns\Behavioral\Adapter\EmailClientOnlyUtfAdapter;

class AdapterTest extends PHPUnit_Framework_TestCase
class AdapterTest extends \PHPUnit_Framework_TestCase
{
/**
* @covers \Rpodwika\Designpatterns\Behavioral\Adapter\EmailClient::sendUtf8Email
Expand Down
Loading

0 comments on commit 554b719

Please sign in to comment.