Skip to content

Commit

Permalink
Fixes typo in MockPublicationRepository class name
Browse files Browse the repository at this point in the history
Adds docblocks to MockPublicationRepository methods.
Comments out the calls to the output() method, intended to print to the console the publications mocked to test sync process.
  • Loading branch information
betsyecastro committed Apr 25, 2024
1 parent 52096a4 commit 46131ed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
6 changes: 3 additions & 3 deletions tests/Feature/PublicationsRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\Feature\Traits\LoginWithRole;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\Feature\Traits\mockPublicationsRepository;
use Tests\Feature\Traits\MockPublicationsRepository;
use App\Repositories\OrcidPublicationsRepository;
use Tests\Feature\Traits\HasJson;

class PublicationsRepositoryTest extends TestCase
{
use mockPublicationsRepository;
use MockPublicationsRepository;
use RefreshDatabase;
use WithFaker;
use LoginWithRole;
Expand Down Expand Up @@ -59,7 +59,7 @@ public function testImportOrcidPublications()
$this->assertCount(5, $this->profile->publications);
$this->assertDatabaseCount('profile_data', 6);

$this->output("PROFILE PUBLICATIONS CREATED", $this->profile->publications, ['profile_id', 'sort_order', 'title']);
// $this->output("PROFILE PUBLICATIONS CREATED", $this->profile->publications, ['profile_id', 'sort_order', 'title']);

$publications_edit_route = route('profiles.edit', [
'profile' => $this->profile,
Expand Down
15 changes: 12 additions & 3 deletions tests/Feature/Traits/MockPublicationsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
use App\ProfileData;
use App\Repositories\OrcidPublicationsRepository;

trait mockPublicationsRepository
trait MockPublicationsRepository
{

/**
* Partial mock to return the orcid API response containing publications (ProfileData collection)
*
* @return OrcidPublicationsRepository
*/
public function mockPublicationsRepository()
{
$publications = $this->makePublications();

$this->output("API PUBLICATIONS TO SYNC", $publications, ['profile_id', 'sort_order', 'title']);
// $this->output("API PUBLICATIONS TO SYNC", $publications, ['profile_id', 'sort_order', 'title']);

$pubs_mock = mock(OrcidPublicationsRepository::class)->makePartial();

Expand All @@ -23,6 +27,11 @@ public function mockPublicationsRepository()
return $pubs_mock;
}

/**
* Returns a ProfileDataFactory collection of publications exisisting in the DB and new publications
*
* @return \Illuminate\Support\Collection<ProfileDataFactory>
*/
public function makePublications()
{
$orcid_api_new_pubs =
Expand Down

0 comments on commit 46131ed

Please sign in to comment.