Closed naimkhalifa closed 7 years ago
Hey @naimkhalifa just taking a look back at that lesson, are you running just the can_add_tickets
test, or the whole file?
In the lesson, I'm just running that one test, so there's a good chance the other test in the file would also fail for me, and that we resolve that a little while after 😊
Let me know if that makes a difference, if not I'll spend some more time looking into it deeper and see if I can figure out what the difference might be.
Yes, that was it! I was running all the tests for ConcertTest and the error message was related to another test.
I wish using phpunit on Windows wasn't such a pain. As a reminder for anyone who might face the same "issue", I used phpunit filter option directly from the command line: ./vendor/bin/phpunit --filter can_add_tickets
By the way, thanks a lot for this amazing course! Getting into TDD feels a lot easier with this kind of resources.
Cheers
Great glad that solved it! Thanks for the great feedback, glad you are enjoying the course 👍
Hi,
I'm following the 'Adding Tickets to Concerts' video but I'm facing an issue that doesnt show up in the course (around 4:00) :
Here's the error summary
Caused by PDOException: SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: tickets.concert_id
Here's my Concert class at that point:
`namespace App;
use Illuminate\Database\Eloquent\Model;
class Concert extends Model { protected $guarded = []; protected $dates = ['date'];
} `
and my migration for the tickets table:
`use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration;
class CreateTicketsTable extends Migration { /**
@return void */ public function up() { Schema::create('tickets', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('concert_id'); $table->unsignedInteger('order_id')->nullable(); $table->timestamps(); }); }
/**
I think that the concert_id field should be automatically filled by Laravel thanks to the tickets() method but for some reason, it's not the case. Does anyone have a clue on this?