From eb58563b4bb94fcc63e28cf6993f98860bc1659a Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 16 Dec 2017 17:15:13 +0900 Subject: [PATCH] Written DataValidation was corrupted Fixes #290 --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Cell/DataValidation.php | 4 ++-- .../Cell/DataValidationTest.php | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 tests/PhpSpreadsheetTests/Cell/DataValidationTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 11533e00..12732fa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Can read very small HTML files - [#194](https://github.com/PHPOffice/PhpSpreadsheet/issues/194) +- Written DataValidation was corrupted - [#290](https://github.com/PHPOffice/PhpSpreadsheet/issues/290) ### BREAKING CHANGE diff --git a/src/PhpSpreadsheet/Cell/DataValidation.php b/src/PhpSpreadsheet/Cell/DataValidation.php index 216383a4..a041ea0e 100644 --- a/src/PhpSpreadsheet/Cell/DataValidation.php +++ b/src/PhpSpreadsheet/Cell/DataValidation.php @@ -449,8 +449,8 @@ class DataValidation return md5( $this->formula1 . $this->formula2 . - $this->type = self::TYPE_NONE . - $this->errorStyle = self::STYLE_STOP . + $this->type . + $this->errorStyle . $this->operator . ($this->allowBlank ? 't' : 'f') . ($this->showDropDown ? 't' : 'f') . diff --git a/tests/PhpSpreadsheetTests/Cell/DataValidationTest.php b/tests/PhpSpreadsheetTests/Cell/DataValidationTest.php new file mode 100644 index 00000000..c41c0335 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Cell/DataValidationTest.php @@ -0,0 +1,19 @@ +getHashCode()); + $dataValidation->setType(DataValidation::TYPE_CUSTOM); + + self::assertSame('778f6c9e0ffcd5eaa7d8e1432d67f919', $dataValidation->getHashCode()); + self::assertSame('778f6c9e0ffcd5eaa7d8e1432d67f919', $dataValidation->getHashCode(), 'getHashCode() should not have side effect'); + } +}