From deea95642ba81c5905a2b37920954be85cb069e7 Mon Sep 17 00:00:00 2001 From: Trismegiste Date: Sat, 24 Aug 2013 00:36:54 +0200 Subject: [PATCH 1/2] PSR-0 compliance --- Singleton/Singleton.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Singleton/Singleton.php b/Singleton/Singleton.php index ee896e4..75c2dd6 100644 --- a/Singleton/Singleton.php +++ b/Singleton/Singleton.php @@ -1,6 +1,6 @@ Date: Sat, 24 Aug 2013 00:37:08 +0200 Subject: [PATCH 2/2] unit test --- Tests/Singleton/SingletonTest.php | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Tests/Singleton/SingletonTest.php diff --git a/Tests/Singleton/SingletonTest.php b/Tests/Singleton/SingletonTest.php new file mode 100644 index 0000000..7291f9d --- /dev/null +++ b/Tests/Singleton/SingletonTest.php @@ -0,0 +1,34 @@ +assertInstanceOf('DesignPatterns\Singleton\Singleton', $firstCall); + $secondCall = Singleton::getInstance(); + $this->assertSame($firstCall, $secondCall); + } + + public function testNoConstructor() + { + $obj = Singleton::getInstance(); + + $refl = new \ReflectionObject($obj); + $meth = $refl->getMethod('__construct'); + $this->assertTrue($meth->isPrivate()); + } + +} \ No newline at end of file