Skip to content

Commit

Permalink
Add page_id as a parameter to getHomepagePromos since its needed often.
Browse files Browse the repository at this point in the history
Move the getHomepagePromos method to the top of the styleguide repository file to mirror how the actual repository is.
  • Loading branch information
robertvrabel committed Sep 25, 2018
1 parent a4798b2 commit 62f3191
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/Repositories/PromoRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ public function __construct(Connector $wsuApi, ParsePromos $parsePromos, Reposit
/**
* {@inheritdoc}
*/
public function getHomepagePromos()
public function getHomepagePromos(int $page_id = 0)
{
$group_reference = [
123 => 'example',
];

$group_config = [
'example' => 'first',
'example' => 'page_id:'.$page_id.'|randomize|first',
];

$params = [
Expand Down
2 changes: 1 addition & 1 deletion contracts/Repositories/PromoRepositoryContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ interface PromoRepositoryContract
*
* @return array
*/
public function getHomepagePromos();
public function getHomepagePromos(int $page_id);
}
22 changes: 11 additions & 11 deletions styleguide/Repositories/PromoRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@

class PromoRepository extends Repository
{
/**
* {@inheritdoc}
*/
public function getHomepagePromos(int $page_id = null)
{
return [
// Example Group
//'key' => app('Factories\YourFactory')->create(5),
];
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -80,15 +91,4 @@ public function getRequestData(array $data)
'accordion_page' => $accordion,
];
}

/**
* {@inheritdoc}
*/
public function getHomepagePromos()
{
return [
// Example Group
//'key' => app('Factories\YourFactory')->create(5),
];
}
}
2 changes: 1 addition & 1 deletion tests/Unit/Repositories/PromoRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function getting_homepage_promos_should_return_array()
$wsuApi->shouldReceive('sendRequest')->with('cms.promotions.listing', Mockery::type('array'))->once()->andReturn($return);

// Get the promos
$promos = app('App\Repositories\PromoRepository', ['wsuApi' => $wsuApi])->getHomepagePromos();
$promos = app('App\Repositories\PromoRepository', ['wsuApi' => $wsuApi])->getHomepagePromos($this->faker->randomDigit);

$this->assertTrue(is_array($promos));
}
Expand Down

0 comments on commit 62f3191

Please sign in to comment.