public function setUp() { //This is the record that model A will belong to in order to test the scope $foo = new $this->modelB(); $foo->name = 'BelongsToExample'; $foo->save(); $this->foreignKeyId = $foo->id; $this->belongsToFunction = 'foo_with_belongsto_scope_b'; $this->belongsToObject = $foo; parent::setUp(); //Now we setup the secondary records which will be out of scope and should remain unchanged throughout modification for ($i = 1; $i <= 10; $i++) { $foo = new $this->model(); $foo->name = $this->model . '-test-' . $i; $foo->foo_with_belongsto_scope_b_id = 99; $foo->save(); } }
public function tearDown() { parent::tearDown(); $modelB = $this->modelB; $modelB::flushEventListeners(); }