generated from helsingborg-stad/Wordpress-Plugin-Boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: indicate card has image even if only placeholder (#478)
* fix: Card datebadge position * feat: add has-image class to card if has placeholder
- Loading branch information
Showing
5 changed files
with
51 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace ComponentLibrary\Component\Card; | ||
|
||
use ComponentLibrary\Cache\CacheInterface; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class CardTest extends TestCase { | ||
|
||
/** | ||
* @testdox Test that the class is added to the classList if image is truthy | ||
*/ | ||
public function testFoo() { | ||
$controller = $this->getController(['image' => true]); | ||
$controller->init(); | ||
|
||
|
||
$this->assertContains('c-card--has-image', $controller->getData()['classList']); | ||
} | ||
|
||
/** | ||
* @testdox Test that the class is added to the classList if hasPlaceholder and date is truthy | ||
*/ | ||
public function testBar() { | ||
$controller = $this->getController(['hasPlaceholder' => true]); | ||
$controller->init(); | ||
|
||
$this->assertContains('c-card--has-image', $controller->getData()['classList']); | ||
} | ||
|
||
private function getController(array $data = []): Card | ||
{ | ||
$default = [ | ||
'buttons' => false, | ||
'classList' => [], | ||
'collapsible' => false, | ||
'content' => false, | ||
'dateBadge' => false, | ||
'hasPlaceholder' => false, | ||
'image' => false, | ||
'link' => false, | ||
'ratio' => false, | ||
'tags' => false, | ||
]; | ||
|
||
return new Card(array_merge($default, $data), $this->createMock(CacheInterface::class)); | ||
} | ||
} |
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
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