-
Notifications
You must be signed in to change notification settings - Fork 259
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
Tests: ResourceControllerTest store_saves() fails due faulty test method #207
Comments
Proposal for the generated test: /**
* @test
*/
public function store_saves()
{
// Whip up a certificate using the factory
$certificate = factory(Certificate::class)->make();
// Post it to the appropriate route
$response = $this->post(route('certificate.store'), $certificate->toArray());
// Assert the 201 Created status
$response->assertCreated();
$certificates = Certificate::query()
->where('id', $response['data']['id']) // Lookup using the id from the returned Resource
->get();
// Assert that there is only one record
$this->assertCount(1, $certificates);
} That last bit of verifying the count is a bit double up if you ask me. |
I don't think this is an issue in and of itself. However, it is a result of whatever is broken in #209. |
I got notified of the merge and subsequent release that fixed #209, but the generated tests remain broken. |
Yes, that's why this is still open. 👍 |
The fixtures in the test suite also contain the same broken code for the |
@axit-joost, you seem to be pretty familiar with the codebase. Would you care to try and resolve some of these bugs you're reporting? |
@jasonmccreary Sure, I'd like to give it a go, but usually @Pr3d4dor beats me to it by squashing my bugs overnight 😅 (thanks a lot by the way!) |
Yeah, you two and @nathane need to share your Twitter handles so I can give y'all a shout out. ❤️ |
@joostjacobs on twitter. |
My twitter handle is @GianlucaBine |
For those who are interested, I have packaged up the declined PR. Blueprint allows for Generators to be swapped. My package will swap the shipped GitHub repo here: Install it via composer: I will be using that until this issue is properly resolved. Hat tip to @dmason30 for inspiring me with his Blueprint Pest Addon |
Description:
Tests generated for a
resource: api
controller do not use a factory.Also, looking at the other tests, I think that the Test Generator can do with a bit of tender love and care: A lot of tests do not assert anything.
Steps To Reproduce:
draft.yaml
:php artisan blueprint:build
, which will yield:phpunit
, which yields:CertificateControllerTest
, particularly thestore_saves
test:The text was updated successfully, but these errors were encountered: