Created
October 19, 2014 18:00
-
-
Save giorgiosironi/7f5055c3fb3b7a4deeae to your computer and use it in GitHub Desktop.
Using a trait to share test code for multiple implementations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait RepositoryContract | |
{ | |
public function testAdd() { ... } | |
public function testRemove() { ... } | |
} | |
class MongoDBRepositoryTest { | |
use RepositoryContract; | |
public function setUp() | |
{ | |
// create a connection, clean up the state... | |
$this->repository = new MongoDBRepository(/* ... */); | |
} | |
} | |
class InMemoryRepositoryTest { | |
use RepositoryContract; | |
public function setUp() | |
{ | |
$this->repository = new InMemoryRepository(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment