Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: news data array adjusted for component loop, and test updated #768

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/Repositories/ModularPageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ public function configureComponents(array $components, array $promos, array $dat
} else {
$articles = $this->article->listing($components['components'][$name]['id'], $limit, 1, $component['topics'] ?? []);
}
$modularComponents[$name]['data'] = $articles['articles'] ?? [];
$modularComponents[$name]['data'] = $articles['articles']['data'] ?? [];
$modularComponents[$name]['meta'] = $articles['articles']['meta'] ?? [];
$modularComponents[$name]['component'] = $components['components'][$name];
} elseif (Str::startsWith($name, 'page-content') || Str::startsWith($name, 'heading')) {
// If there's JSON but no news, events or promo data, assign the component array as data
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Repositories/ModularPageRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function get_modular_page_components_featured_news(): void
// Run the promos through the repository
$modularComponents = app(ModularPageRepository::class, ['wsuApi' => $wsuApi])->getModularComponents($data);

$this->assertCount(count($return['data']), $modularComponents['news-row-1']['data']['data']);
$this->assertCount(count($return['data']), $modularComponents['news-row-1']['data']);
}

#[Test]
Expand Down Expand Up @@ -226,7 +226,7 @@ public function get_modular_page_components_news(): void
// Run the promos through the repository
$modularComponents = app(ModularPageRepository::class, ['wsuApi' => $wsuApi])->getModularComponents($data);

$this->assertCount(count($return['data']), $modularComponents['news-column-1']['data']['data']);
$this->assertCount(count($return['data']), $modularComponents['news-column-1']['data']);
}

#[Test]
Expand Down
Loading