mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-24 09:42:24 +01:00
the test is the client
This commit is contained in:
parent
9278f295b0
commit
20433dd8a5
42
Tests/Adapter/AdapterTest.php
Normal file
42
Tests/Adapter/AdapterTest.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* DesignPatternPHP
|
||||
*/
|
||||
|
||||
namespace DesignPatterns\Tests\Adapter;
|
||||
|
||||
use DesignPatterns\Adapter\ElecBookAdapter;
|
||||
use DesignPatterns\Adapter\Kindle;
|
||||
use DesignPatterns\Adapter\PaperBookInterface;
|
||||
use DesignPatterns\Adapter\Book;
|
||||
|
||||
/**
|
||||
* AdapterTest shows the use of an adapted e-book that behave like a book
|
||||
* You don't have to change the code of your client
|
||||
*/
|
||||
class AdapterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function getBook()
|
||||
{
|
||||
return array(
|
||||
array(new Book()),
|
||||
// we build a "wrapped" electronic book in the adapter
|
||||
array(new ElecBookAdapter(new Kindle()))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This client only knows paper book but surprise, surprise, the second book
|
||||
* is in fact an electronic book.
|
||||
*
|
||||
* @dataProvider getBook
|
||||
*/
|
||||
public function test_I_am_an_old_Client(PaperBookInterface $book)
|
||||
{
|
||||
$book->open();
|
||||
$book->turnPage();
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user