mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-06 06:57:25 +02:00
Replaced with strict assertions
This commit is contained in:
@@ -15,7 +15,7 @@ class AdapterTest extends TestCase
|
||||
$book->open();
|
||||
$book->turnPage();
|
||||
|
||||
$this->assertEquals(2, $book->getPage());
|
||||
$this->assertSame(2, $book->getPage());
|
||||
}
|
||||
|
||||
public function testCanTurnPageOnKindleLikeInANormalBook()
|
||||
@@ -26,6 +26,6 @@ class AdapterTest extends TestCase
|
||||
$book->open();
|
||||
$book->turnPage();
|
||||
|
||||
$this->assertEquals(2, $book->getPage());
|
||||
$this->assertSame(2, $book->getPage());
|
||||
}
|
||||
}
|
||||
|
@@ -12,10 +12,10 @@ class BridgeTest extends TestCase
|
||||
public function testCanPrintUsingThePlainTextPrinter()
|
||||
{
|
||||
$service = new HelloWorldService(new PlainTextFormatter());
|
||||
$this->assertEquals('Hello World', $service->get());
|
||||
$this->assertSame('Hello World', $service->get());
|
||||
|
||||
// now change the implementation and use the HtmlFormatter instead
|
||||
$service->setImplementation(new HtmlFormatter());
|
||||
$this->assertEquals('<p>Hello World</p>', $service->get());
|
||||
$this->assertSame('<p>Hello World</p>', $service->get());
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ class CompositeTest extends TestCase
|
||||
// This is just an example, in a real world scenario it is important to remember that web browsers do not
|
||||
// currently support nested forms
|
||||
|
||||
$this->assertEquals(
|
||||
$this->assertSame(
|
||||
'<form>Email:<input type="text" /><form>Password:<input type="text" /></form></form>',
|
||||
$form->render()
|
||||
);
|
||||
|
@@ -13,8 +13,8 @@ class DecoratorTest extends TestCase
|
||||
{
|
||||
$booking = new DoubleRoomBooking();
|
||||
|
||||
$this->assertEquals(40, $booking->calculatePrice());
|
||||
$this->assertEquals('double room', $booking->getDescription());
|
||||
$this->assertSame(40, $booking->calculatePrice());
|
||||
$this->assertSame('double room', $booking->getDescription());
|
||||
}
|
||||
|
||||
public function testCanCalculatePriceForDoubleRoomBookingWithWiFi()
|
||||
@@ -22,8 +22,8 @@ class DecoratorTest extends TestCase
|
||||
$booking = new DoubleRoomBooking();
|
||||
$booking = new WiFi($booking);
|
||||
|
||||
$this->assertEquals(42, $booking->calculatePrice());
|
||||
$this->assertEquals('double room with wifi', $booking->getDescription());
|
||||
$this->assertSame(42, $booking->calculatePrice());
|
||||
$this->assertSame('double room with wifi', $booking->getDescription());
|
||||
}
|
||||
|
||||
public function testCanCalculatePriceForDoubleRoomBookingWithWiFiAndExtraBed()
|
||||
@@ -32,7 +32,7 @@ class DecoratorTest extends TestCase
|
||||
$booking = new WiFi($booking);
|
||||
$booking = new ExtraBed($booking);
|
||||
|
||||
$this->assertEquals(72, $booking->calculatePrice());
|
||||
$this->assertEquals('double room with wifi with extra bed', $booking->getDescription());
|
||||
$this->assertSame(72, $booking->calculatePrice());
|
||||
$this->assertSame('double room with wifi with extra bed', $booking->getDescription());
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,6 @@ class DependencyInjectionTest extends TestCase
|
||||
$config = new DatabaseConfiguration('localhost', 3306, 'domnikl', '1234');
|
||||
$connection = new DatabaseConnection($config);
|
||||
|
||||
$this->assertEquals('domnikl:1234@localhost:3306', $connection->getDsn());
|
||||
$this->assertSame('domnikl:1234@localhost:3306', $connection->getDsn());
|
||||
}
|
||||
}
|
||||
|
@@ -31,6 +31,6 @@ class FacadeTest extends TestCase
|
||||
$facade->turnOn();
|
||||
|
||||
// but you can also access the underlying components
|
||||
$this->assertEquals('Linux', $os->getName());
|
||||
$this->assertSame('Linux', $os->getName());
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,6 @@ class FluentInterfaceTest extends TestCase
|
||||
->from('foobar', 'f')
|
||||
->where('f.bar = ?');
|
||||
|
||||
$this->assertEquals('SELECT foo, bar FROM foobar AS f WHERE f.bar = ?', (string) $query);
|
||||
$this->assertSame('SELECT foo, bar FROM foobar AS f WHERE f.bar = ?', (string) $query);
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ class FlyweightTest extends TestCase
|
||||
$flyweight = $factory->get($char);
|
||||
$rendered = $flyweight->render($font);
|
||||
|
||||
$this->assertEquals(sprintf('Character %s with font %s', $char, $font), $rendered);
|
||||
$this->assertSame(sprintf('Character %s with font %s', $char, $font), $rendered);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -13,12 +13,12 @@ class ProxyTest extends TestCase
|
||||
$bankAccount->deposit(30);
|
||||
|
||||
// this time balance is being calculated
|
||||
$this->assertEquals(30, $bankAccount->getBalance());
|
||||
$this->assertSame(30, $bankAccount->getBalance());
|
||||
|
||||
// inheritance allows for BankAccountProxy to behave to an outsider exactly like ServerBankAccount
|
||||
$bankAccount->deposit(50);
|
||||
|
||||
// this time the previously calculated balance is returned again without re-calculating it
|
||||
$this->assertEquals(30, $bankAccount->getBalance());
|
||||
$this->assertSame(30, $bankAccount->getBalance());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user