Skip to content

Commit

Permalink
Temp
Browse files Browse the repository at this point in the history
  • Loading branch information
andaniel05 committed Apr 22, 2020
1 parent 1f96a10 commit 28ec4b9
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions tests/HtmlElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

namespace ThenLabs\ComposedViews\Tests;

use ThenLabs\ComposedViews\AbstractView;
use ThenLabs\ComposedViews\AbstractCompositeView;
use ThenLabs\ComposedViews\HtmlElement;
use ThenLabs\ComposedViews\TextView;
use ThenLabs\Components\DependencyInterface;
use ThenLabs\ClassBuilder\ClassBuilder;

setTestCaseNamespace(__NAMESPACE__);
setTestCaseClass(TestCase::class);
Expand Down Expand Up @@ -311,26 +313,44 @@
$element = $this->getMockBuilder(HtmlElement::class)
->disableOriginalConstructor()
->setMethods([
'setTagName',
'setAttributes',
'setInnerHtml',
'setEndTag',
'setSelfClosingTag',
])
->getMock();
$element->expects($this->once())
->method('setTagName')
->with($this->equalTo($tagName));
$element->expects($this->never())->method('setAttributes');
$element->expects($this->never())->method('setInnerHtml');
$element->expects($this->once())
->method('setEndTag')
->with($this->equalTo($endTag));
$element->expects($this->once())
->method('setSelfClosingTag')
->with($this->equalTo($selfClosingTag));

$element->__construct($tagName, null, '', $endTag, $selfClosingTag);
$element->__construct($tagName, null, null, $endTag, $selfClosingTag);
});

test(function () {
$tagName = uniqid();
$endTag = boolval(mt_rand(0, 1));
$selfClosingTag = boolval(mt_rand(0, 1));

$expectedResult = uniqid();
$view = (new ClassBuilder)->extends(AbstractView::class)
->addMethod('getView')
->setAccess('protected')
->setClosure(function (array $data = []) use ($expectedResult): string {
return $expectedResult;
})
->end()
->newInstance()
;

$element = $this->getMockBuilder(HtmlElement::class)
->disableOriginalConstructor()
->setMethods([
'setInnerHtml',
])
->getMock();
$element->expects($this->once())
->method('setInnerHtml')
->with($this->equalTo($expectedResult));

$element->__construct($tagName, null, $view, $endTag, $selfClosingTag);
});
});
});
Expand Down

0 comments on commit 28ec4b9

Please sign in to comment.