Skip to content

Commit de09eea

Browse files
committed
Normalize test method names
1 parent e289197 commit de09eea

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.PHONY: test
2+
test:
3+
@echo "Design Pattern Tests"
4+
php ./vendor/bin/phpunit --bootstrap ./vendor/autoload.php ./tests/ --testdox --colors

src/Creational/Singleton/Singleton.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace DesignPatterns\Creational\Singleton;
5+
namespace Growthdev\DesignPatterns\Creational\Singleton;
66

77
use LogicException;
88

@@ -23,16 +23,17 @@ protected function __construct()
2323
{
2424
}
2525

26-
private function __clone()
26+
private function __clone(): void
2727
{
2828
}
2929

30-
public function __wakeup()
30+
public function __sleep()
3131
{
32-
throw new LogicException('Cannot unserialize a singleton.');
32+
throw new LogicException('Cannot serialize a singleton.');
3333
}
34-
35-
private function __sleep()
34+
35+
public function __wakeup(): void
3636
{
37+
throw new LogicException('Cannot unserialize a singleton.');
3738
}
38-
}
39+
}

tests/Creational/Singleton/SingletonTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,40 @@
44

55
namespace Growthdev\DesignPatterns\Creational\Singleton;
66

7-
use DesignPatterns\Creational\Singleton\Singleton;
7+
use Growthdev\DesignPatterns\Creational\Singleton\Singleton;
8+
use Error;
9+
use LogicException;
810
use PHPUnit\Framework\TestCase;
911

1012
final class SingletonTest extends TestCase
1113
{
12-
public function testShoudBeTheSameInstanceForTwoObjets(): void
14+
public function testShouldBeTheSameInstanceForTwoObjets(): void
1315
{
1416
$firstInstance = Singleton::getInstance();
1517
$secondInstance = SingleTon::getInstance();
1618

1719
$this->assertSame($firstInstance, $secondInstance);
1820
}
1921

20-
public function testThrowErrorWhenTryToCreateInstance(): void
22+
public function testShouldThrowErrorWhenTryToCreateInstance(): void
2123
{
2224
$this->expectException(Error::class);
2325

2426
$instance = new Singleton();
2527
}
2628

27-
public function testThrowExceptionWhenTryToClone(): void
29+
public function testShouldThrowErrorWhenTryToClone(): void
2830
{
2931
$this->expectException(Error::class);
3032

3133
$instance = Singleton::getInstance();
3234
$clone = clone $instance;
3335
}
3436

35-
public function testThrowExceptionWhenTryToSerialize(): void
37+
public function testShouldThrowExceptionWhenTryToSerialize(): void
3638
{
37-
$this->expectException(Error::class);
39+
$this->expectException(LogicException::class);
40+
$this->expectExceptionMessage('Cannot serialize a singleton.');
3841

3942
$instance = Singleton::getInstance();
4043
$serialize = serialize($instance);

0 commit comments

Comments
 (0)