From 879b702fc14ab1572ee4b639738e95eee4bdd702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Mon, 28 Aug 2023 22:47:15 +0200 Subject: [PATCH] Fixed PHPunit tests --- tests/Serializer/StructuralElementDenormalizerTest.php | 5 +++-- .../StructuralElementFromNameDenormalizerTest.php | 4 +++- tests/Serializer/StructuralElementNormalizerTest.php | 7 +++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/Serializer/StructuralElementDenormalizerTest.php b/tests/Serializer/StructuralElementDenormalizerTest.php index 19cf4ea8..fc1c0f1d 100644 --- a/tests/Serializer/StructuralElementDenormalizerTest.php +++ b/tests/Serializer/StructuralElementDenormalizerTest.php @@ -44,8 +44,9 @@ class StructuralElementDenormalizerTest extends WebTestCase $this->assertFalse($this->service->supportsDenormalization('doesnt_matter', Category::class, 'json', ['groups' => ['import']])); $this->assertFalse($this->service->supportsDenormalization(['name' => 'Test'], Category::class, 'json', ['groups' => ['simple']])); - //Denormalizer should only be active, when we use the import function - $this->assertTrue($this->service->supportsDenormalization(['name' => 'Test'], Category::class, 'json', ['groups' => ['import']])); + //Denormalizer should only be active, when we use the import function and partdb_import is set + $this->assertFalse($this->service->supportsDenormalization(['name' => 'Test'], Category::class, 'json', ['groups' => ['import']])); + $this->assertTrue($this->service->supportsDenormalization(['name' => 'Test'], Category::class, 'json', ['groups' => ['import'], 'partdb_import' => true])); } /** diff --git a/tests/Serializer/StructuralElementFromNameDenormalizerTest.php b/tests/Serializer/StructuralElementFromNameDenormalizerTest.php index 918c0339..b344508c 100644 --- a/tests/Serializer/StructuralElementFromNameDenormalizerTest.php +++ b/tests/Serializer/StructuralElementFromNameDenormalizerTest.php @@ -45,7 +45,9 @@ class StructuralElementFromNameDenormalizerTest extends WebTestCase $this->assertFalse($this->service->supportsDenormalization('doesnt_matter', \stdClass::class)); $this->assertFalse($this->service->supportsDenormalization(['a' => 'b'], Category::class)); - $this->assertTrue($this->service->supportsDenormalization('doesnt_matter', Category::class)); + //The denormalizer should only be active, when we are doing a file import operation + $this->assertFalse($this->service->supportsDenormalization('doesnt_matter', Category::class)); + $this->assertTrue($this->service->supportsDenormalization('doesnt_matter', Category::class, 'json', ['partdb_import' => true])); } public function testDenormalizeCreateNew(): void diff --git a/tests/Serializer/StructuralElementNormalizerTest.php b/tests/Serializer/StructuralElementNormalizerTest.php index 8d4df05a..b151f249 100644 --- a/tests/Serializer/StructuralElementNormalizerTest.php +++ b/tests/Serializer/StructuralElementNormalizerTest.php @@ -71,8 +71,11 @@ class StructuralElementNormalizerTest extends WebTestCase //Normalizer must only support StructuralElement objects (and child classes) $this->assertFalse($this->service->supportsNormalization(new \stdClass())); $this->assertFalse($this->service->supportsNormalization(new Part())); - $this->assertTrue($this->service->supportsNormalization(new Category())); - $this->assertTrue($this->service->supportsNormalization(new Footprint())); + + //Must only be active when export is enabled + $this->assertFalse($this->service->supportsNormalization(new Category())); + $this->assertTrue($this->service->supportsNormalization(new Category(), null, ['partdb_export' => true])); + $this->assertTrue($this->service->supportsNormalization(new Footprint(), null, ['partdb_export' => true])); } }