From b23d1708043b2b48db8431eea8d630b9385b7681 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 20 May 2019 22:38:43 +0100 Subject: [PATCH] Get sponsors by level --- src/Sponsors/src/Model/Sponsor.php | 4 ++++ src/Sponsors/tests/SponsorsTest.php | 28 ++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/Sponsors/src/Model/Sponsor.php b/src/Sponsors/src/Model/Sponsor.php index 979615b..226849f 100644 --- a/src/Sponsors/src/Model/Sponsor.php +++ b/src/Sponsors/src/Model/Sponsor.php @@ -4,6 +4,10 @@ namespace App\Sponsors\Model; class Sponsor { + const LEVEL_GOLD = 'gold'; + const LEVEL_SILVER = 'silver'; + const LEVEL_BRONZE = 'bronze'; + /** @var array */ private $data = []; diff --git a/src/Sponsors/tests/SponsorsTest.php b/src/Sponsors/tests/SponsorsTest.php index b425bfa..bed0c7a 100644 --- a/src/Sponsors/tests/SponsorsTest.php +++ b/src/Sponsors/tests/SponsorsTest.php @@ -2,14 +2,38 @@ namespace App\Tests\Sponsors; +use App\Sponsors\Model\Sponsor; +use App\Sponsors\TwigExtension\SponsorsExtension; use PHPUnit\Framework\TestCase; class SponsorsTest extends TestCase { - /** @test */ + /** @var SponsorsExtension */ + private $extension; + + protected function setUp(): void + { + parent::setUp(); + + $this->extension = new SponsorsExtension(); + } + + /** @test */ public function get_sponsors_by_level() { - $this->markTestIncomplete(); + $data = [ + Sponsor::LEVEL_GOLD => [ + ['name' => 'Microserve', 'confirmed' => true], + ], + Sponsor::LEVEL_SILVER => [ + ['name' => 'Drupalize.me', 'confirmed' => true], + ], + ]; + + $sponsors = $this->extension->getSponsors($data, Sponsor::LEVEL_SILVER); + + $this->assertCount(1, $sponsors); + $this->assertSame('Drupalize.me', $sponsors[0]['name']); } /** @test */