Consider the following test:
public function it_should_contain_a_list_of_investors_who_belong_to_one_or_more_investment() {
$this->createInvestment();
$investor = factory(User::class)->create([
'role_id' => 4
]);
$response = $this->actingAs($investor)
->call('GET', 'api/v1/investors?include=investments');
dd(json_decode($response->getContent()));
$this->assertNotEmpty(json_decode($response->getContent()));
}
Now consider the following action this test is calling:
public function getAllInvestorsForCompany($slug)
{
$users = $this->investorEntity->usersForCompany($slug);
$resource = new Collection($users, new InvestorTransformer, 'investor');
dd($_GET);
if (isset($_GET['include'])) {
$usersData = $this->manager->parseIncludes($_GET['include'])->createData($resource)->toArray();
} else {
$usersData = $this->manager->createData($resource)->toArray();
}
return response()->json($usersData);
}
Note the dd
, the $_GET
returns []
Lets do the same test in the browser:
array:1 [▼
"include" => "investments.offering.company"
]
Ok so in the browser I get back investments.offering.company, because that is what I am passing in as the ?include=
But in the test its like laravel ignores the ?include and moves on.
is this a default behaviour of laravel 5.1 tests and if so how do I shut it off?
Aucun commentaire:
Enregistrer un commentaire