public function run() { Eloquent::unguard(); DB::table('slots')->truncate(); Slot::create(array('session_id' => 1, 'track_id' => 1, 'from' => '2014-01-01 00:00:00', 'to' => '2014-01-01 01:00:00')); Slot::create(array('session_id' => 2, 'track_id' => 3, 'from' => '2014-01-01 00:00:00', 'to' => '2014-01-01 01:00:00')); Slot::create(array('session_id' => 2, 'track_id' => 3, 'from' => '2014-01-01 01:00:00', 'to' => '2014-01-01 02:00:00')); Slot::create(array('session_id' => 2, 'track_id' => 1, 'from' => '2014-01-01 02:00:00', 'to' => '2014-01-01 03:00:00')); Slot::create(array('session_id' => 1, 'track_id' => 2, 'from' => '2014-01-01 00:00:00', 'to' => '2014-01-01 01:00:00')); Slot::create(array('session_id' => 1, 'track_id' => 2, 'from' => '2014-01-01 01:00:00', 'to' => '2014-01-01 02:00:00')); }
/** * @test * @large */ public function testTrack() { $slot = Slot::find(1); $assert = $slot->track; $this->assertInstanceOf('Trails\\Models\\Track', $assert); $this->assertEquals(1, $assert->id); $this->assertEquals('git at it\'s best', $assert->name); $this->assertEquals(TrackStatus::PENDING, $assert->status); $this->assertEquals('A little course for all n3wbs on how to use git.', $assert->description); }
/** * The users tracks associated slots * * @return \Illuminate\Database\Eloquent\Collection */ public function getSlots() { $slots = Slot::whereIn('track_id', $this->tracks->modelKeys())->distinct()->get(); return $slots; }