From 53731fa6740b900cf4ef237890df5a8a55f9f9a2 Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Fri, 12 Apr 2024 10:34:52 +0200 Subject: [PATCH] test: add tests for `Ds\Collection` normalization --- .github/workflows/mutation.yml | 2 +- .github/workflows/tests.yml | 2 +- .../Integration/Normalizer/NormalizerTest.php | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mutation.yml b/.github/workflows/mutation.yml index 5e940cb6..08f3917b 100644 --- a/.github/workflows/mutation.yml +++ b/.github/workflows/mutation.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest env: php-version: '8.1' - php-extensions: yaml + php-extensions: ds,yaml steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 63b08279..bda45f1b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,7 +17,7 @@ jobs: - "8.3" env: - php-extensions: yaml + php-extensions: ds,yaml steps: - name: Checkout uses: actions/checkout@v3 diff --git a/tests/Integration/Normalizer/NormalizerTest.php b/tests/Integration/Normalizer/NormalizerTest.php index 68c5afce..7f3183fc 100644 --- a/tests/Integration/Normalizer/NormalizerTest.php +++ b/tests/Integration/Normalizer/NormalizerTest.php @@ -203,6 +203,24 @@ public static function normalize_basic_values_yields_expected_output_data_provid 'expected json' => '{"foo":"foo","bar":"bar"}', ]; + yield 'Ds Map' => [ + 'input' => new \Ds\Map(['foo' => 'foo', 'bar' => 'bar']), + 'expected array' => [ + 'foo' => 'foo', + 'bar' => 'bar', + ], + 'expected json' => '{"foo":"foo","bar":"bar"}', + ]; + + yield 'Ds Set' => [ + 'input' => new \Ds\Set(['foo', 'bar']), + 'expected array' => [ + 0 => 'foo', + 1 => 'bar', + ], + 'expected json' => '["foo","bar"]', + ]; + yield 'class inheriting ArrayObject' => [ 'input' => new class (['foo' => 'foo', 'bar' => 'bar']) extends ArrayObject {}, 'expected array' => [