-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enh: added slider method into Content helper
- Loading branch information
1 parent
bcddaa3
commit 7912ea4
Showing
6 changed files
with
129 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
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
65 changes: 65 additions & 0 deletions
65
tests/sokolnikov911/YandexTurboPages/helpers/ContentSliderTest.php
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,65 @@ | ||
<?php | ||
|
||
namespace sokolnikov911\YandexTurboPages\helpers; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class ContentSliderTest extends TestCase | ||
{ | ||
private $header = 'Some slider description'; | ||
private $items = [ | ||
['url' => 'http://example.com/image1.jpg', 'title' => 'Image title 1', 'link' => ''], | ||
['url' => 'http://example.com/image2.jpg', 'title' => 'Image title 2', 'link' => ''], | ||
['url' => 'http://example.com/image3.jpg'], | ||
['href' => 'http://example.com/page1.html', 'title' => 'Link title 1', 'text' => 'Link text 1'] | ||
]; | ||
|
||
public function testBaseSlider() | ||
{ | ||
$slider = Content::slider($this->items); | ||
$baseSlider = "<div data-block=\"slider\" data-view=\"square\" data-item-view=\"cover\"> | ||
<figure> | ||
<figcaption>Image title 1</figcaption> | ||
<img src=\"http://example.com/image1.jpg\" /> | ||
</figure> | ||
<figure> | ||
<figcaption>Image title 2</figcaption> | ||
<img src=\"http://example.com/image2.jpg\" /> | ||
</figure> | ||
<figure> | ||
<img src=\"http://example.com/image3.jpg\" /> | ||
</figure> | ||
<figure> | ||
<figcaption>Link title 1</figcaption> | ||
<a href=\"http://example.com/page1.html\">Link text 1</a> | ||
</figure> | ||
</div>"; | ||
|
||
$this->assertXmlStringEqualsXmlString($baseSlider, $slider); | ||
} | ||
|
||
public function testSliderWithHeader() | ||
{ | ||
$slider = Content::slider($this->items, 'Slider header', Content::SLIDER_DATA_VIEW_PORTRAIT, Content::SLIDER_DATA_ITEM_VIEW_CONTAIN); | ||
$baseSlider = "<div data-block=\"slider\" data-view=\"portrait\" data-item-view=\"contain\"> | ||
<header>Slider header</header> | ||
<figure> | ||
<figcaption>Image title 1</figcaption> | ||
<img src=\"http://example.com/image1.jpg\" /> | ||
</figure> | ||
<figure> | ||
<figcaption>Image title 2</figcaption> | ||
<img src=\"http://example.com/image2.jpg\" /> | ||
</figure> | ||
<figure> | ||
<img src=\"http://example.com/image3.jpg\" /> | ||
</figure> | ||
<figure> | ||
<figcaption>Link title 1</figcaption> | ||
<a href=\"http://example.com/page1.html\">Link text 1</a> | ||
</figure> | ||
</div>"; | ||
|
||
$this->assertXmlStringEqualsXmlString($baseSlider, $slider); | ||
} | ||
} |