nafiesl/SimpleCrudGenerator

Let's add a strategy for filling data automatically

Opened this issue · 4 comments

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...

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.

@nafiesl

Exactly!
You put the nail on the head.

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.

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