diff --git a/README.md b/README.md index e9012fe..d6c36f2 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ -# HtmlElement +# Html Element This package allows you to easily create HTML elements from PHP. It's inspired by [David Walsh's blogpost](https://davidwalsh.name/create-html-elements-php-htmlelement-class) but further improved. ```$php -use Vdhicts\HtmlElement\HtmlElement; +use Vdhicts\Dicms\Html; // Create new html element with attribute name -$selectElement = new HtmlElement('select'); +$selectElement = new Html\Element('select'); $selectElement->setAttribute('name', 'something'); $selectElement->generate(); // Create new html element with text and attribute -$paragraphElement = new HtmlElement('p', 'text', ['class' => 'center']); +$paragraphElement = new Html\Element('p', 'text', ['class' => 'center']); ``` ## Requirements @@ -35,7 +35,7 @@ composer require vdhicts/html-element A new html element can be created with: ```php -$containerElement = new HtmlElement('div'); +$containerElement = new Html\Element('div'); $containerElement->setAttribute('class', 'container'); ``` @@ -58,8 +58,8 @@ $containerElement->setAttributes(['class' => 'container', 'role' => 'container'] Or the element could contain another html element: ```php -$colElement = new HtmlElement('div', '', ['class' => 'col-md-6']); -$rowElement = new HtmlElement('div', '', ['class' => 'row']); +$colElement = new Html\Element('div', '', ['class' => 'col-md-6']); +$rowElement = new Html\Element('div', '', ['class' => 'row']); $rowElement->inject($colElement); $containerElement->inject($rowElement); @@ -77,8 +77,8 @@ value * `removeAttributes` or `removeAttribute(attribute)` to remove all attributes or just one. * `removeAttributeValue(attribute, value)` to remove one value from a attribute. * `getText`, `addText` or `setText` to retrieve, add or set the inner text. -* `inject` to inject a htmlElement into the current htmlElement. -* `generate` generates the htmlElement and returns its string representation. +* `inject` to inject a Element into the current Element. +* `generate` generates the Element and returns its string representation. * `output` echos the result of `generate`. ## Tests @@ -94,6 +94,17 @@ By default a coverage report will be generated in the `build/coverage` folder. Any contribution is welcome, but it should be fully tested, meet the PSR-2 standard and please create one pull request per feature. In exchange you will be credited as contributor on this page. +## Security + +If you discover any security related issues in this or other packages of Vdhicts, please email info@vdhicts.nl instead +of using the issue tracker. + ## License -This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) +This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT). + +## About vdhicts + +[Van der Heiden ICT services](https://www.vdhicts.nl) is the name of my personal company for which I work as +freelancer. Van der Heiden ICT services develops and implements IT solutions for businesses and educational +institutions. \ No newline at end of file diff --git a/composer.json b/composer.json index d23e0ff..00b68bf 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,9 @@ "authors": [ { "name": "Dick van der Heiden", - "email": "info@vdhicts.nl" + "email": "info@vdhicts.nl", + "role": "Developer", + "homepage": "https://www.vdhicts.nl" } ], "require": { @@ -15,6 +17,6 @@ "phpunit/phpunit": "^6.1" }, "autoload": { - "psr-4": {"Vdhicts\\HtmlElement\\": "src/"} + "psr-4": {"Vdhicts\\Dicms\\Html\\": "src/"} } } diff --git a/composer.lock b/composer.lock index 834e26c..179db56 100644 --- a/composer.lock +++ b/composer.lock @@ -9,32 +9,32 @@ "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.0.5", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", "shasum": "" }, "require": { - "php": ">=5.3,<8.0-DEV" + "php": "^7.1" }, "require-dev": { "athletic/athletic": "~0.1.8", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" + "phpunit/phpunit": "^6.2.3", + "squizlabs/php_codesniffer": "^3.0.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -59,41 +59,44 @@ "constructor", "instantiate" ], - "time": "2015-06-14T21:17:01+00:00" + "time": "2017-07-22T11:58:36+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.6.1", + "version": "1.7.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102" + "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/8e6e04167378abf1ddb4d3522d8755c5fd90d102", - "reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", "shasum": "" }, "require": { - "php": ">=5.4.0" + "php": "^5.6 || ^7.0" }, "require-dev": { - "doctrine/collections": "1.*", - "phpunit/phpunit": "~4.1" + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^4.1" }, "type": "library", "autoload": { "psr-4": { "DeepCopy\\": "src/DeepCopy/" - } + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "description": "Create deep copies (clones) of your objects", - "homepage": "https://github.com/myclabs/DeepCopy", "keywords": [ "clone", "copy", @@ -101,7 +104,7 @@ "object", "object graph" ], - "time": "2017-04-12T18:52:22+00:00" + "time": "2017-10-19T19:58:43+00:00" }, { "name": "phar-io/manifest", @@ -207,16 +210,16 @@ }, { "name": "phpdocumentor/reflection-common", - "version": "1.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", "shasum": "" }, "require": { @@ -257,33 +260,39 @@ "reflection", "static analysis" ], - "time": "2015-12-27T11:43:31+00:00" + "time": "2017-09-11T18:02:19+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "3.2.2", + "version": "4.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "4aada1f93c72c35e22fb1383b47fee43b8f1d157" + "reference": "94fd0001232e47129dd3504189fa1c7225010d08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/4aada1f93c72c35e22fb1383b47fee43b8f1d157", - "reference": "4aada1f93c72c35e22fb1383b47fee43b8f1d157", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", + "reference": "94fd0001232e47129dd3504189fa1c7225010d08", "shasum": "" }, "require": { - "php": ">=5.5", - "phpdocumentor/reflection-common": "^1.0@dev", - "phpdocumentor/type-resolver": "^0.3.0", + "php": "^7.0", + "phpdocumentor/reflection-common": "^1.0.0", + "phpdocumentor/type-resolver": "^0.4.0", "webmozart/assert": "^1.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^4.4" + "doctrine/instantiator": "~1.0.5", + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, "autoload": { "psr-4": { "phpDocumentor\\Reflection\\": [ @@ -302,20 +311,20 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-08-08T06:39:58+00:00" + "time": "2017-11-30T07:14:17+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "0.3.0", + "version": "0.4.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "fb3933512008d8162b3cdf9e18dba9309b7c3773" + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/fb3933512008d8162b3cdf9e18dba9309b7c3773", - "reference": "fb3933512008d8162b3cdf9e18dba9309b7c3773", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", "shasum": "" }, "require": { @@ -349,37 +358,37 @@ "email": "me@mikevanriel.com" } ], - "time": "2017-06-03T08:32:36+00:00" + "time": "2017-07-14T14:27:02+00:00" }, { "name": "phpspec/prophecy", - "version": "v1.7.0", + "version": "1.7.6", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "93d39f1f7f9326d746203c7c056f300f7f126073" + "reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073", - "reference": "93d39f1f7f9326d746203c7c056f300f7f126073", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/33a7e3c4fda54e912ff6338c48823bd5c0f0b712", + "reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", - "sebastian/comparator": "^1.1|^2.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8 || ^5.6.5" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.7.x-dev" } }, "autoload": { @@ -412,20 +421,20 @@ "spy", "stub" ], - "time": "2017-03-02T20:05:34+00:00" + "time": "2018-04-18T13:57:24+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "5.2.2", + "version": "5.3.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "8ed1902a57849e117b5651fc1a5c48110946c06b" + "reference": "c89677919c5dd6d3b3852f230a663118762218ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/8ed1902a57849e117b5651fc1a5c48110946c06b", - "reference": "8ed1902a57849e117b5651fc1a5c48110946c06b", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c89677919c5dd6d3b3852f230a663118762218ac", + "reference": "c89677919c5dd6d3b3852f230a663118762218ac", "shasum": "" }, "require": { @@ -434,14 +443,13 @@ "php": "^7.0", "phpunit/php-file-iterator": "^1.4.2", "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^1.4.11 || ^2.0", + "phpunit/php-token-stream": "^2.0.1", "sebastian/code-unit-reverse-lookup": "^1.0.1", "sebastian/environment": "^3.0", "sebastian/version": "^2.0.1", "theseer/tokenizer": "^1.1" }, "require-dev": { - "ext-xdebug": "^2.5", "phpunit/phpunit": "^6.0" }, "suggest": { @@ -450,7 +458,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.2.x-dev" + "dev-master": "5.3.x-dev" } }, "autoload": { @@ -465,7 +473,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -476,20 +484,20 @@ "testing", "xunit" ], - "time": "2017-08-03T12:40:43+00:00" + "time": "2018-04-06T15:36:58+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "1.4.2", + "version": "1.4.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", "shasum": "" }, "require": { @@ -523,7 +531,7 @@ "filesystem", "iterator" ], - "time": "2016-10-03T07:40:28+00:00" + "time": "2017-11-27T13:52:08+00:00" }, { "name": "phpunit/php-text-template", @@ -617,16 +625,16 @@ }, { "name": "phpunit/php-token-stream", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0" + "reference": "791198a2c6254db10131eecfe8c06670700904db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/9a02332089ac48e704c70f6cefed30c224e3c0b0", - "reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", + "reference": "791198a2c6254db10131eecfe8c06670700904db", "shasum": "" }, "require": { @@ -662,20 +670,20 @@ "keywords": [ "tokenizer" ], - "time": "2017-08-20T05:47:52+00:00" + "time": "2017-11-27T05:48:46+00:00" }, { "name": "phpunit/phpunit", - "version": "6.3.0", + "version": "6.5.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "9501bab711403a1ab5b8378a8adb4ec3db3debdb" + "reference": "4f21a3c6b97c42952fd5c2837bb354ec0199b97b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9501bab711403a1ab5b8378a8adb4ec3db3debdb", - "reference": "9501bab711403a1ab5b8378a8adb4ec3db3debdb", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4f21a3c6b97c42952fd5c2837bb354ec0199b97b", + "reference": "4f21a3c6b97c42952fd5c2837bb354ec0199b97b", "shasum": "" }, "require": { @@ -689,12 +697,12 @@ "phar-io/version": "^1.0", "php": "^7.0", "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^5.2.2", - "phpunit/php-file-iterator": "^1.4.2", + "phpunit/php-code-coverage": "^5.3", + "phpunit/php-file-iterator": "^1.4.3", "phpunit/php-text-template": "^1.2.1", "phpunit/php-timer": "^1.0.9", - "phpunit/phpunit-mock-objects": "^4.0.3", - "sebastian/comparator": "^2.0.2", + "phpunit/phpunit-mock-objects": "^5.0.5", + "sebastian/comparator": "^2.1", "sebastian/diff": "^2.0", "sebastian/environment": "^3.1", "sebastian/exporter": "^3.1", @@ -720,7 +728,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "6.3.x-dev" + "dev-master": "6.5.x-dev" } }, "autoload": { @@ -746,33 +754,33 @@ "testing", "xunit" ], - "time": "2017-08-04T05:20:39+00:00" + "time": "2018-04-10T11:38:34+00:00" }, { "name": "phpunit/phpunit-mock-objects", - "version": "4.0.4", + "version": "5.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "2f789b59ab89669015ad984afa350c4ec577ade0" + "reference": "33fd41a76e746b8fa96d00b49a23dadfa8334cdf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/2f789b59ab89669015ad984afa350c4ec577ade0", - "reference": "2f789b59ab89669015ad984afa350c4ec577ade0", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/33fd41a76e746b8fa96d00b49a23dadfa8334cdf", + "reference": "33fd41a76e746b8fa96d00b49a23dadfa8334cdf", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.5", "php": "^7.0", "phpunit/php-text-template": "^1.2.1", - "sebastian/exporter": "^3.0" + "sebastian/exporter": "^3.1" }, "conflict": { "phpunit/phpunit": "<6.0" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^6.5" }, "suggest": { "ext-soap": "*" @@ -780,7 +788,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0.x-dev" + "dev-master": "5.0.x-dev" } }, "autoload": { @@ -795,7 +803,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -805,7 +813,7 @@ "mock", "xunit" ], - "time": "2017-08-03T14:08:16+00:00" + "time": "2018-01-06T05:45:45+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -854,30 +862,30 @@ }, { "name": "sebastian/comparator", - "version": "2.0.2", + "version": "2.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "ae068fede81d06e7bb9bb46a367210a3d3e1fe6a" + "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/ae068fede81d06e7bb9bb46a367210a3d3e1fe6a", - "reference": "ae068fede81d06e7bb9bb46a367210a3d3e1fe6a", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/34369daee48eafb2651bea869b4b15d75ccc35f9", + "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9", "shasum": "" }, "require": { "php": "^7.0", - "sebastian/diff": "^2.0", - "sebastian/exporter": "^3.0" + "sebastian/diff": "^2.0 || ^3.0", + "sebastian/exporter": "^3.1" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^6.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "2.1.x-dev" } }, "autoload": { @@ -908,13 +916,13 @@ } ], "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", + "homepage": "https://github.com/sebastianbergmann/comparator", "keywords": [ "comparator", "compare", "equality" ], - "time": "2017-08-03T07:14:59+00:00" + "time": "2018-02-01T13:46:46+00:00" }, { "name": "sebastian/diff", @@ -1408,16 +1416,16 @@ }, { "name": "webmozart/assert", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + "reference": "0df1908962e7a3071564e857d86874dad1ef204a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a", "shasum": "" }, "require": { @@ -1454,7 +1462,7 @@ "check", "validate" ], - "time": "2016-11-23T20:04:58+00:00" + "time": "2018-01-29T19:49:41+00:00" } ], "aliases": [], diff --git a/src/HtmlElement.php b/src/Element.php similarity index 98% rename from src/HtmlElement.php rename to src/Element.php index b8c8a98..fc26603 100644 --- a/src/HtmlElement.php +++ b/src/Element.php @@ -1,8 +1,8 @@ addText($htmlElement->generate()); diff --git a/tests/unit/HtmlElementTest.php b/tests/unit/HtmlElementTest.php index 8900daf..9ab66e8 100644 --- a/tests/unit/HtmlElementTest.php +++ b/tests/unit/HtmlElementTest.php @@ -1,6 +1,6 @@ assertTrue(class_exists(HtmlElement::class)); + $this->assertTrue(class_exists(Html\Element::class)); } public function testWithoutTag() { - $htmlElement = new HtmlElement(''); + $htmlElement = new Html\Element(''); $this->assertSame('', $htmlElement->generate()); } public function testTag() { - $htmlElement = new HtmlElement('p'); + $htmlElement = new Html\Element('p'); $this->assertSame('
', $htmlElement->generate()); } public function testTagWithText() { - $htmlElement = new HtmlElement('p', 'test'); + $htmlElement = new Html\Element('p', 'test'); $this->assertSame('test
', $htmlElement->generate()); - $htmlElement = new HtmlElement('p'); + $htmlElement = new Html\Element('p'); $htmlElement->setText('test'); $this->assertSame('test
', $htmlElement->generate()); } public function testTagWithAddingText() { - $htmlElement = new HtmlElement('p', 'test'); + $htmlElement = new Html\Element('p', 'test'); $this->assertSame('test
', $htmlElement->generate()); $htmlElement->addText('ie'); @@ -45,16 +45,16 @@ public function testTagWithAddingText() public function testTagWithTextRetrieval() { - $htmlElement = new HtmlElement('p', 'test'); + $htmlElement = new Html\Element('p', 'test'); $this->assertSame('test', $htmlElement->getText()); } public function testTagWithTextWithAttribute() { - $htmlElement = new HtmlElement('p', 'test', ['class' => 'center']); + $htmlElement = new Html\Element('p', 'test', ['class' => 'center']); $this->assertSame('test
', $htmlElement->generate()); - $htmlElement = new HtmlElement('p'); + $htmlElement = new Html\Element('p'); $htmlElement->setText('test'); $htmlElement->setAttribute('class', 'center'); $this->assertSame('test
', $htmlElement->generate()); @@ -62,10 +62,10 @@ public function testTagWithTextWithAttribute() public function testTagWithTextWithAttributes() { - $htmlElement = new HtmlElement('p', 'test', ['class' => 'center']); + $htmlElement = new Html\Element('p', 'test', ['class' => 'center']); $this->assertSame('test
', $htmlElement->generate()); - $htmlElement = new HtmlElement('p'); + $htmlElement = new Html\Element('p'); $htmlElement->setText('test'); $htmlElement->setAttributes(['class' => 'center', 'data-type' => 'paragraph']); $this->assertSame('test
', $htmlElement->generate()); @@ -73,16 +73,16 @@ public function testTagWithTextWithAttributes() public function testTagWithTextWithAttributeWithoutValue() { - $htmlElement = new HtmlElement('option', 'test', ['selected']); + $htmlElement = new Html\Element('option', 'test', ['selected']); $this->assertSame('', $htmlElement->generate()); - $htmlElement = new HtmlElement('option', 'test', ['value' => 1, 'selected']); + $htmlElement = new Html\Element('option', 'test', ['value' => 1, 'selected']); $this->assertSame('', $htmlElement->generate()); } public function testTagWithAddingAttributeValues() { - $htmlElement = new HtmlElement('p', 'test', ['class' => 'center']); + $htmlElement = new Html\Element('p', 'test', ['class' => 'center']); $this->assertSame('test
', $htmlElement->generate()); $htmlElement->addAttributeValue('class', 'text-success'); @@ -91,7 +91,7 @@ public function testTagWithAddingAttributeValues() public function testTagWithRemovingAttribute() { - $htmlElement = new HtmlElement('p', 'test', ['class' => 'center']); + $htmlElement = new Html\Element('p', 'test', ['class' => 'center']); $this->assertSame('test
', $htmlElement->generate()); $htmlElement->removeAttribute('class'); @@ -100,7 +100,7 @@ public function testTagWithRemovingAttribute() public function testTagWithRemovingAttributes() { - $htmlElement = new HtmlElement('p', 'test', ['class' => 'center', 'data-type' => 'paragraph']); + $htmlElement = new Html\Element('p', 'test', ['class' => 'center', 'data-type' => 'paragraph']); $this->assertSame('test
', $htmlElement->generate()); $htmlElement->removeAttributes(); @@ -109,7 +109,7 @@ public function testTagWithRemovingAttributes() public function testTagWithRemovingAttributeValue() { - $htmlElement = new HtmlElement('p', 'test', ['class' => 'center']); + $htmlElement = new Html\Element('p', 'test', ['class' => 'center']); $this->assertSame('test
', $htmlElement->generate()); $htmlElement->addAttributeValue('class', 'text-success'); @@ -124,20 +124,20 @@ public function testTagWithRemovingAttributeValue() public function testTagWithAttributesRetrieval() { - $htmlElement = new HtmlElement('p', 'test', ['class' => 'center']); + $htmlElement = new Html\Element('p', 'test', ['class' => 'center']); $this->assertSame(['center'], $htmlElement->getAttribute('class')); $this->assertSame(['class' => ['center']], $htmlElement->getAttributes()); - $htmlElement = new HtmlElement('p', 'test'); + $htmlElement = new Html\Element('p', 'test'); $this->assertSame([], $htmlElement->getAttribute('class')); } public function testTagInjection() { - $optionElement = new HtmlElement('option', 'option 1', ['value' => 1]); + $optionElement = new Html\Element('option', 'option 1', ['value' => 1]); $this->assertSame('', $optionElement->generate()); - $selectElement = new HtmlElement('select', '', ['name' => 'something']); + $selectElement = new Html\Element('select', '', ['name' => 'something']); $this->assertSame('', $selectElement->generate()); $selectElement->inject($optionElement); @@ -147,7 +147,7 @@ public function testTagInjection() public function testDirectOutput() { - $htmlElement = new HtmlElement('p', 'test', ['class' => 'center']); + $htmlElement = new Html\Element('p', 'test', ['class' => 'center']); $this->expectOutputString('test
'); $htmlElement->output();