-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements for next minor release (#94)
* Fix return type for getElementById, closes #65 * Update PHPDoc to include inherited changes * Rename function for removing template attributes * Set value for certain input fields differently * Bind list to document fragment for efficiency for #77 * Remove unbindable check * Allow returning any iterable, not just array - fixes #88 * Implement and test bind* function with get* kept for compatibility Closes #89
- Loading branch information
Showing
4 changed files
with
64 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
namespace Gt\DomTemplate\Test; | ||
|
||
use Gt\DomTemplate\BindDataGetter; | ||
use Gt\DomTemplate\HTMLDocument; | ||
use Gt\DomTemplate\Test\Helper\BindDataGetter\TodoItem; | ||
use Gt\DomTemplate\Test\Helper\Helper; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class BindDataGetterTest extends TestCase { | ||
public function testBindFunction() { | ||
$id = rand(100, 1000); | ||
$name = uniqid(); | ||
$sut = new TodoItem($id, $name); | ||
|
||
$document = new HTMLDocument(Helper::HTML_TODO_LIST); | ||
$document->extractTemplates(); | ||
$document->bindList([$sut]); | ||
|
||
$li = $document->querySelector("li"); | ||
self::assertEquals($id, $li->querySelector("[name='id']")->value); | ||
self::assertEquals($name, $li->querySelector("[name='title']")->value); | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
namespace Gt\DomTemplate\Test\Helper\BindDataGetter; | ||
|
||
use Gt\DomTemplate\BindDataGetter; | ||
|
||
class TodoItem implements BindDataGetter { | ||
private $id; | ||
private $title; | ||
|
||
public function __construct( | ||
int $id, | ||
string $title | ||
) { | ||
$this->id = $id; | ||
$this->title = $title; | ||
} | ||
|
||
public function getTitle():string { | ||
return $this->title; | ||
} | ||
|
||
|
||
public function bindId():int { | ||
return $this->id; | ||
} | ||
public function bindTitle():string { | ||
return $this->getTitle(); | ||
} | ||
} |