Skip to content

Commit c283a49

Browse files
committed
criando a biblioteca sem SOLID
1 parent 9179e92 commit c283a49

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"autoload": {
1414
"psr-4": {
15-
"Solid\\Html\\": "src"
15+
"\\Solid\\Html\\": "src"
1616
}
1717
}
1818
}

src/Html.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Solid\Html;
4+
5+
class Html
6+
{
7+
public function img(string $src)
8+
{
9+
return '<img src="' . $src . '">';
10+
}
11+
12+
public function a(string $href , string $anchor)
13+
{
14+
return '<a href="' . $href . '">' . $anchor . '</a>';
15+
}
16+
}

tests/HtmlTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Solid\Html;
4+
5+
class HtmlTest extends \PHPUnit\Framework\TestCase
6+
{
7+
8+
public function testCriarTagImgComSrc()
9+
{
10+
$html = new Html;
11+
$img = $html->img('img/photo.png');
12+
13+
$this->assertEquals('<img src="img/photo.png">', $img);
14+
}
15+
16+
public function testCriarTagAComImgAncora()
17+
{
18+
$html = new Html;
19+
$img = $html->img('img/photo.png');
20+
21+
$a = $html->a('http://www.example.com.br', $img);
22+
23+
$this->assertEquals('<a href="http://www.example.com.br"><img src="img/photo.png"></a>', $a);
24+
}
25+
26+
}

0 commit comments

Comments
 (0)