mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-06 15:06:31 +02:00
create a Test folder for each pattern
This commit is contained in:
41
Structural/Adapter/Tests/AdapterTest.php
Normal file
41
Structural/Adapter/Tests/AdapterTest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\Structural\Adapter\Tests;
|
||||
|
||||
use DesignPatterns\Structural\Adapter\EBookAdapter;
|
||||
use DesignPatterns\Structural\Adapter\Kindle;
|
||||
use DesignPatterns\Structural\Adapter\PaperBookInterface;
|
||||
use DesignPatterns\Structural\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
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getBook()
|
||||
{
|
||||
return array(
|
||||
array(new Book()),
|
||||
// we build a "wrapped" electronic book in the adapter
|
||||
array(new EBookAdapter(new Kindle()))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This client only knows paper book but surprise, surprise, the second book
|
||||
* is in fact an electronic book, but both work the same way
|
||||
*
|
||||
* @param PaperBookInterface $book
|
||||
*
|
||||
* @dataProvider getBook
|
||||
*/
|
||||
public function testIAmAnOldClient(PaperBookInterface $book)
|
||||
{
|
||||
$book->open();
|
||||
$book->turnPage();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user