Skip to content

Commit

Permalink
1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bupy7 committed Nov 21, 2018
1 parent 4b85682 commit f6605a6
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 8 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
language: php
dist: trusty
php:
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- hhvm

before_script:
- composer install --no-interaction
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
xml-constrcutor
===============

v1.3.0 [2018-11-22]
-------------------

- Added [CData](http://php.net/manual/ru/function.xmlwriter-write-cdata.php) feature.
- No longer support for PHP 5.5, 5.6 and HHVM.

v1.2.5 [2018-11-08]
-------------------

Expand Down
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,29 @@
"xml maker"
],
"license": "BSD-3-Clause",
"version": "1.2.5",
"version": "1.3.0",
"authors": [
{
"name": "Vasily Belosloodcev",
"email": "vasily.belosloodcev@gmail.com"
}
],
"require": {
"php": ">=5.4",
"php": ">=5.6",
"ext-libxml": "*"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"satooshi/php-coveralls": "^1.0"
"phpunit/phpunit": "^5.7.27",
"satooshi/php-coveralls": "^1.0.1 || ^2.0"
},
"autoload": {
"psr-4": {
"bupy7\\xml\\constructor\\": "src",
"bupy7\\xml\\constructor\\tests\\": "tests"
}
},
"scripts": {
"test:run": "php vendor/bin/phpunit --no-coverage",
"test:run-with-cov": "php vendor/bin/phpunit"
}
}
11 changes: 10 additions & 1 deletion src/XmlConstructor.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
* ],
* ],
* ],
* [
* 'tag' => 'tag4',
* 'content' => '<b>content4</b>',
* 'cdata' => true, // by default - false
* ],
* ],
* ],
* ];
Expand Down Expand Up @@ -103,7 +108,11 @@ public function fromArray($in)
if (is_array($content)) {
$this->fromArray($content);
} else {
$this->text($content);
if (isset($element['cdata']) && $element['cdata']) {
$this->writeCdata($content);
} else {
$this->text($content);
}
}
}
$this->endElement();
Expand Down
37 changes: 37 additions & 0 deletions tests/XmlConstructTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ class XmlConstructTest extends TestCase
],
],
];
/**
* @since 1.3.0
* @var array
*/
private $in3 = [
[
'tag' => 'root',
'elements' => [
[
'tag' => 'tag1',
'content' => '<b>content1</b>',
'cdata' => true,
],
[
'tag' => 'tag2',
'content' => 'content2',
],
],
],
];

public function testDefaultDocument1()
{
Expand Down Expand Up @@ -121,6 +141,23 @@ public function testCustomIndentString()
$out2 = $xml->fromArray($this->in1)->toOutput();
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
}

/**
* @since 1.3.0
*/
public function testCdataContent()
{
$out1 = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
<tag1><![CDATA[<b>content1</b>]]></tag1>
<tag2>content2</tag2>
</root>
XML;
$xml = new XmlConstructor(['indentString' => false]);
$out2 = $xml->fromArray($this->in3)->toOutput();
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
}

public function testError()
{
Expand Down

0 comments on commit f6605a6

Please sign in to comment.