diff --git a/app/tests/unit/MockSerializableKVStore.php b/app/tests/unit/MockSerializableKVStore.php index 393e196..7c9faac 100644 --- a/app/tests/unit/MockSerializableKVStore.php +++ b/app/tests/unit/MockSerializableKVStore.php @@ -30,7 +30,10 @@ public function fetch( string $site_id, string $entity_type, array $entity_ids, public function add( string $site_id, string $entity_type, array $entities, int $ttl = -1 ): bool { $this->init_site_entity_type( $site_id, $entity_type ); - $this->data[ $site_id ][ $entity_type ] = array_merge( $this->data[ $site_id ][ $entity_type ], $entities ); + foreach ( $entities as $entity_id => $entity ) { + // merge manually instead of array_merge to not have PHP renumber integer keys. + $this->data[ $site_id ][ $entity_type ][ $entity_id ] = $entity; + } return true; } diff --git a/app/tests/unit/Webhooks/CategoryWebhookControllerTest.php b/app/tests/unit/Webhooks/CategoryWebhookControllerTest.php index 0ab4904..e045b3a 100644 --- a/app/tests/unit/Webhooks/CategoryWebhookControllerTest.php +++ b/app/tests/unit/Webhooks/CategoryWebhookControllerTest.php @@ -52,8 +52,7 @@ public function test_create_category(): void { $this->request->method( 'getPayload' )->willReturn( new InputBag( $request_body ) ); $this->sut->serve(); $categories = $this->kv_store->fetch( $this->site_info->id, 'categories', array( '1' ), array( Category::class ) ); - error_log( print_r( $categories, true ) ); - $category = $categories[1]; + $category = $categories[1]; $this->assertEquals( 1, $category->id ); $this->assertEquals( 'Test Category', $category->name ); $this->assertEquals( 'test-category', $category->slug );