-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from cultuurnet/feature/III-2534
III-2534: Add method to get first detail from a list
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
class CultureFeed_Cdb_Data_DetailListTest extends PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \CultureFeed_Cdb_Data_DetailList | ||
*/ | ||
private $details; | ||
|
||
public function setUp() | ||
{ | ||
$this->details = $this->getMockForAbstractClass('\CultureFeed_Cdb_Data_DetailList'); | ||
} | ||
|
||
public function testGetFirstWithOneDetail() | ||
{ | ||
$first = $this->createDetail(); | ||
$first->setTitle('Foo bar'); | ||
|
||
$this->details->add($first); | ||
|
||
$this->assertEquals($first, $this->details->getFirst()); | ||
} | ||
|
||
public function testGetFirstWithMultipleDetails() | ||
{ | ||
$first = $this->createDetail(); | ||
$first->setTitle('Foo bar'); | ||
|
||
$second = $this->createDetail(); | ||
$second->setTitle('Lorem ipsum'); | ||
|
||
$third = $this->createDetail(); | ||
$third->setTitle('Acme'); | ||
|
||
$this->details->add($first); | ||
$this->details->add($second); | ||
$this->details->add($third); | ||
|
||
$this->assertEquals($first, $this->details->getFirst()); | ||
} | ||
|
||
public function testGetFirstWithNoDetails() | ||
{ | ||
$this->assertNull($this->details->getFirst()); | ||
} | ||
|
||
/** | ||
* @return CultureFeed_Cdb_Data_Detail | ||
*/ | ||
private function createDetail() | ||
{ | ||
/* @var CultureFeed_Cdb_Data_Detail $mock */ | ||
$mock = $this->getMockForAbstractClass('\CultureFeed_Cdb_Data_Detail'); | ||
return $mock; | ||
} | ||
} |