Skip to content

Commit

Permalink
Changed MemberPledgeTierMapping to include tier ID.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilge committed Aug 6, 2021
1 parent 6bbfd64 commit 8a7230f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/Mapping/MemberPledgeTierMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

use ScriptFUSION\Mapper\Mapping;
use ScriptFUSION\Mapper\Strategy\Copy;
use ScriptFUSION\Mapper\Strategy\Filter;
use ScriptFUSION\Mapper\Strategy\Merge;

class MemberPledgeTierMapping extends Mapping
{
protected function createMapping()
{
return [new Copy('attributes->title')];
return new Merge(new Filter(['id' => new Copy('id')]), new Copy('attributes'));
}
}
12 changes: 8 additions & 4 deletions test/Functional/GetMemberPledgeTiersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function testHasPledge(): void

$firstTier = $tiers->current();

self::assertArrayHasKey('id', $firstTier);
self::assertArrayHasKey('attributes', $firstTier);
self::assertIsArray($attributes = $firstTier['attributes']);
self::assertArrayHasKey('title', $attributes);
Expand All @@ -39,8 +40,10 @@ public function testHasPledgeWithMapping(): void
$firstTier = $tiers->current();

self::assertIsArray($firstTier);
self::assertCount(1, $firstTier);
self::assertNotEmpty($firstTier[0]);
self::assertArrayHasKey('id', $firstTier);
self::assertNotEmpty($firstTier['id']);
self::assertArrayHasKey('title', $firstTier);
self::assertNotEmpty($firstTier['title']);
}

public function testHasNoPledge(): void
Expand All @@ -64,7 +67,8 @@ public function testHasNoPledgeWithMapping(): void
$firstTier = $tiers->current();

self::assertIsArray($firstTier);
self::assertCount(1, $firstTier);
self::assertNull($firstTier[0]);
self::assertCount(0, $firstTier);
self::assertArrayNotHasKey('id', $firstTier);
self::assertArrayNotHasKey('title', $firstTier);
}
}

0 comments on commit 8a7230f

Please sign in to comment.