Skip to content
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

Let's add a strategy for filling data automatically #48

Open
Mdhesari opened this issue Mar 17, 2022 · 4 comments
Open

Let's add a strategy for filling data automatically #48

Mdhesari opened this issue Mar 17, 2022 · 4 comments

Comments

@Mdhesari
Copy link

I have a scenario in my mind let's see how it works :

  1. I wanna write TDD tests for a book store management.
  2. Let's start with the Book entity & CRUD
  3. I start by creating a BookTest and try to store a new book with POST method.
    $this->get(route('books.store'), [ 'name' => 'Programming', 'publisher' => 'Laravel', 'author' => 'Taylor Outwell', ]);
  4. Now I start to enter CRUD generator command for my book, when the command executes, it will go through its tests and if there is an available test, it will look for POST method and the data we are passing to that route, it will collect the data we are passing and replace it to Form Request & Model fillables property.

Now we just need to add validation and most of the work is done by the command generator...

@nafiesl
Copy link
Owner

nafiesl commented Mar 17, 2022

Hi @Mdhesari I am not sure if I get your point correctly, here are my understanding:

  1. We create a Feature/ManageBookTest and create 1 method user_can_create_book()
  2. We run an artisan command with the test class name as an argument
  3. The command will check the test method and see what attributes are given on the request
  4. The command will collect the attributes, then push them into the FormRequest class and fillable attributes on the model.

Are those correct @Mdhesari?

In general, I was thinking your idea is:

  1. We provide tests (with attributes)
  2. The command will generate the feature code for us (Model, Controller, Model Factory, DB Migration file, Policy Object, etc).

Not sure my understandings are correct, let me know, @Mdhesari.

Thanks.

@Mdhesari
Copy link
Author

@nafiesl

Exactly!
You put the nail on the head.

@nafiesl
Copy link
Owner

nafiesl commented Mar 20, 2022

Hi @Mdhesari, currently I have no time to try to dig it further to start implementing it. If you wailing to write the plan in more detail, or even submit a pull request, that will be very helpful. We can review them together.

Meanwhile, I will keep this issue open as a feature suggestion.

Thanks.

@Mdhesari
Copy link
Author

sure, I will try to do it when there was a chance to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants