Skip to content

Commit

Permalink
Merge pull request #16 from luyadev/xlsx-test
Browse files Browse the repository at this point in the history
add test
  • Loading branch information
nadar committed Jan 25, 2023
2 parents c709157 + 24f5bea commit 19fb23f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: ['7.2', '7.3', '7.4', '8.0', '8.1']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']

steps:
## checkout the repoistory
Expand All @@ -104,7 +104,7 @@ jobs:
## run unit tests
- name: PHP Unit tests for PHP
run: vendor/bin/phpunit --verbose --configuration actions.phpunit.xml
if: matrix.php == '7.2' || matrix.php == '7.3' || matrix.php == '8.1' || matrix.php == '8.0'
if: matrix.php == '7.2' || matrix.php == '7.3' || matrix.php == '8.0' || matrix.php == '8.1' || matrix.php == '8.2'

## unit test with coverage
- name: PHP Unit tests for PHP 7.4 Coverage
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).

## 1.4.2 (25. January 2022)

+ [#16](https://github.com/luyadev/yii-helpers/pull/16) Fix PHP 8.1 compatibility bug in `ExportHelper::xlsx()`.

## 1.4.1 (18. January 2022)

+ [#15](https://github.com/luyadev/yii-helpers/pull/15) Fix PHP 8.1 compatibility bug in `ArrayHelper::searchColumns()`
+ [#15](https://github.com/luyadev/yii-helpers/pull/15) Fix PHP 8.1 compatibility bug in `ArrayHelper::searchColumns()`.

## 1.4.0 (20. October 2022)

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/XLSXWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ public static function xmlspecialchars($val)
static $badchars = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f";
static $goodchars = " ";
return strtr(
htmlspecialchars($val, ENT_QUOTES | ENT_XML1),
htmlspecialchars((string) $val, ENT_QUOTES | ENT_XML1),
$badchars,
$goodchars
);//strtr appears to be faster than str_replace
Expand Down
26 changes: 26 additions & 0 deletions tests/helpers/ExportHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,30 @@ public function testSpecialCharsEncoding()

$this->assertSameTrimmed('"&","\'","a""b""c" "nix","nix","\'=1+2"";=1+2"', $content);
}

public function testXlsPhp81()
{
$data = [
[
'Datum' => '20.01.2023, 10:52:52',
'Sprache' => 'de',
'name' => 'TEST',
'visit' => 'Sehr gut',
'happiness' => 'Ja',
'fragen' => '',
'datenschutz' => 'Ja',
],
[
'Datum' => '13.11.2022, 13:36:56',
'Sprache' => 'de',
'name' => 'TEST',
'visit' => 'Sehr gut',
'happiness' => 'Ja',
'fragen' => '',
'datenschutz' => 'Ja',
],
];

$this->assertNotEmpty(ExportHelper::xlsx($data, [], true, ['sort' => false]));
}
}

0 comments on commit 19fb23f

Please sign in to comment.