Level 23
@dschu did you solve this? i am having a hardtime with this?
The title says it all.. I need to mock a repository and then run a selenium test, because I'm interacting with a third party API. Is this possible? Any advice for me how to achieve my goal?
The test itself does nothing special at the moment. Just opens the page and waits so I can check manually, if the mocked data was submitted.
ReportsTest.php
<?php
class ReportsTest extends SeleniumTestCase
{
public function setUp()
{
parent::setup();
$this->reportRepo = Mockery::mock('App\Repositories\ReportRepository');
//$this->app->instance('App\Repositories\ReportRepository', $this->reportRepo);
App::instance('App\Repositories\ReportRepository', $this->reportRepo);
}
/** @test */
public function select_a_specific_rule_report()
{
$user = $this->initUser();
$this->reportRepo->shouldReceive('getRulesListByRegions')
//->with( $user->client->id, null )
->andReturn( json_decode( file_get_contents( base_path('tests/acceptance/raw/ReportRepository/getRulesListByRegions.json') ), true ) );
$this->logIn()
->seePageIs( route( 'dashboard' ) )
->waitForElement( '#lnk-nav-reports', 2000 )
->clickCss( '#lnk-nav-reports' )
->waitForElement( '#lnk-reports-rules', 2000 )
->clickCss( '#lnk-reports-rules' )
->wait( 20000 );
}
}
Please or to participate in this conversation.