From e914f715fc3762c6f5e1f10aa8719bb21504afe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiemo=20M=C3=A4ttig?= Date: Tue, 14 Oct 2014 11:08:57 +0200 Subject: [PATCH 1/4] Test all three SnakObject classes --- tests/unit/Snak/PropertyNoValueSnakTest.php | 32 +++++++++++++++++++ tests/unit/Snak/PropertySomeValueSnakTest.php | 32 +++++++++++++++++++ tests/unit/Snak/SnakObjectTest.php | 2 +- 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 tests/unit/Snak/PropertyNoValueSnakTest.php create mode 100644 tests/unit/Snak/PropertySomeValueSnakTest.php diff --git a/tests/unit/Snak/PropertyNoValueSnakTest.php b/tests/unit/Snak/PropertyNoValueSnakTest.php new file mode 100644 index 00000000..05b8ddd7 --- /dev/null +++ b/tests/unit/Snak/PropertyNoValueSnakTest.php @@ -0,0 +1,32 @@ + Date: Tue, 14 Oct 2014 21:40:27 +0200 Subject: [PATCH 2/4] Adapt to #243 --- tests/unit/Snak/PropertyNoValueSnakTest.php | 12 ++++++++++++ tests/unit/Snak/PropertySomeValueSnakTest.php | 12 ++++++++++++ tests/unit/Snak/PropertyValueSnakTest.php | 1 - tests/unit/Snak/SnakObjectTest.php | 1 - 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/unit/Snak/PropertyNoValueSnakTest.php b/tests/unit/Snak/PropertyNoValueSnakTest.php index 05b8ddd7..eb75f7a4 100644 --- a/tests/unit/Snak/PropertyNoValueSnakTest.php +++ b/tests/unit/Snak/PropertyNoValueSnakTest.php @@ -3,6 +3,7 @@ namespace Wikibase\Test\Snak; use Wikibase\DataModel\Entity\PropertyId; +use Wikibase\DataModel\Snak\PropertyNoValueSnak; /** * @covers Wikibase\DataModel\Snak\PropertyNoValueSnak @@ -29,4 +30,15 @@ public function getClass() { return 'Wikibase\DataModel\Snak\PropertyNoValueSnak'; } + /** + * This test is a safeguard to make sure hashes are not changed unintentionally. + */ + public function testHashStability() { + $snak = new PropertyNoValueSnak( new PropertyId( 'P1' ) ); + $hash = $snak->getHash(); + + $expected = sha1( 'C:43:"Wikibase\DataModel\Snak\PropertyNoValueSnak":4:{i:1;}' ); + $this->assertSame( $expected, $hash ); + } + } diff --git a/tests/unit/Snak/PropertySomeValueSnakTest.php b/tests/unit/Snak/PropertySomeValueSnakTest.php index 9826cb66..b698ce41 100644 --- a/tests/unit/Snak/PropertySomeValueSnakTest.php +++ b/tests/unit/Snak/PropertySomeValueSnakTest.php @@ -3,6 +3,7 @@ namespace Wikibase\Test\Snak; use Wikibase\DataModel\Entity\PropertyId; +use Wikibase\DataModel\Snak\PropertySomeValueSnak; /** * @covers Wikibase\DataModel\Snak\PropertySomeValueSnak @@ -29,4 +30,15 @@ public function getClass() { return 'Wikibase\DataModel\Snak\PropertySomeValueSnak'; } + /** + * This test is a safeguard to make sure hashes are not changed unintentionally. + */ + public function testHashStability() { + $snak = new PropertySomeValueSnak( new PropertyId( 'P1' ) ); + $hash = $snak->getHash(); + + $expected = sha1( 'C:45:"Wikibase\DataModel\Snak\PropertySomeValueSnak":4:{i:1;}' ); + $this->assertSame( $expected, $hash ); + } + } diff --git a/tests/unit/Snak/PropertyValueSnakTest.php b/tests/unit/Snak/PropertyValueSnakTest.php index 42572cbd..38bdcbe3 100644 --- a/tests/unit/Snak/PropertyValueSnakTest.php +++ b/tests/unit/Snak/PropertyValueSnakTest.php @@ -39,7 +39,6 @@ public function getClass() { /** * This test is a safeguard to make sure hashes are not changed unintentionally. - * @see EntityIdTest::testSerializationStability */ public function testHashStability() { $snak = new PropertyValueSnak( new PropertyId( 'P1' ), new StringValue( 'a' ) ); diff --git a/tests/unit/Snak/SnakObjectTest.php b/tests/unit/Snak/SnakObjectTest.php index 964dfdfa..599f3e53 100644 --- a/tests/unit/Snak/SnakObjectTest.php +++ b/tests/unit/Snak/SnakObjectTest.php @@ -114,7 +114,6 @@ public function testGetHash( Snak $snak ) { /** * This test is a safeguard to make sure hashes are not changed unintentionally. - * @see EntityIdTest::testSerializationStability */ public abstract function testHashStability(); From 443525941acb7e5a6a7a7a4a60106eae7b63eb39 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Tue, 14 Oct 2014 22:29:48 +0200 Subject: [PATCH 3/4] Update PropertyNoValueSnakTest.php --- tests/unit/Snak/PropertyNoValueSnakTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/unit/Snak/PropertyNoValueSnakTest.php b/tests/unit/Snak/PropertyNoValueSnakTest.php index eb75f7a4..58b10f70 100644 --- a/tests/unit/Snak/PropertyNoValueSnakTest.php +++ b/tests/unit/Snak/PropertyNoValueSnakTest.php @@ -12,8 +12,6 @@ * @group WikibaseDataModel * @group WikibaseSnak * - * @group Database - * * @licence GNU GPL v2+ * @author Thiemo Mättig */ From 387f31d9323a2de2871abcbe5138d08ee8b3df0e Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Tue, 14 Oct 2014 22:30:00 +0200 Subject: [PATCH 4/4] Update PropertySomeValueSnakTest.php --- tests/unit/Snak/PropertySomeValueSnakTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/unit/Snak/PropertySomeValueSnakTest.php b/tests/unit/Snak/PropertySomeValueSnakTest.php index b698ce41..d2ec9fb8 100644 --- a/tests/unit/Snak/PropertySomeValueSnakTest.php +++ b/tests/unit/Snak/PropertySomeValueSnakTest.php @@ -12,8 +12,6 @@ * @group WikibaseDataModel * @group WikibaseSnak * - * @group Database - * * @licence GNU GPL v2+ * @author Thiemo Mättig */