public function test_mock_get_data_card()
{
$this->mock(downloadCard::class, function ($mock) {
$mock->shouldReceive('createCard')
->once()
->andReturn(new Request(
File::get('tests/test_data/card1.json'),
$status =200,
$headers=[],
));
});
$response = $this->artisan('trello-monitor:sync');
}
i did the following test to mock the command, when i launch it it fails me with the following error:
Mockery\Exception\BadMethodCallException: Received Mockery_0_App_ClassU_downloadCard::_downloadCardsFromBoard(), but no expectations were specified
while if I launch this test it passes without problems:
public function test_mock_get_data()
{
$this->mock(downloadCard::class, function ($mock) {
$mock->shouldReceive('_downloadCardsFromBoard')
->once()
->andReturn(new Request(
File::get('tests/test_data/cards.json'),
$status =200,
$headers=[],
));
});
$response = $this->artisan('trello-monitor:sync');
}
the command that is invoked is the following:
protected $unirest;
public function __construct(downloadCard $unirest)
{
$this->unirest = $unirest;
parent::__construct();
}
public function handle()
{
Log::info("Starting sync");
foreach (TRELLO_BOARDS as $beardName => $boardId) {
$cards = $this->unirest->_downloadCardsFromBoard($boardId);
foreach($cards as $index=>$card) {
echo $index.' of '.count($cards)."\r\n";
$this->unirest->createCard($card);
}
}
Aucun commentaire:
Enregistrer un commentaire