2016-04-27 23:06:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
2016-06-16 01:36:09 +00:00
|
|
|
use App\Models\Event;
|
2016-04-27 23:06:17 +00:00
|
|
|
|
|
|
|
|
class EventTest extends TestCase
|
|
|
|
|
{
|
2016-06-16 01:36:09 +00:00
|
|
|
public function test_event_is_created_successfully()
|
2016-04-27 23:06:17 +00:00
|
|
|
{
|
2016-06-16 01:36:09 +00:00
|
|
|
$this->actingAs($this->test_user);
|
2016-04-27 23:06:17 +00:00
|
|
|
|
2016-06-16 01:36:09 +00:00
|
|
|
$organiser = factory(App\Models\Organiser::class)->create(['account_id' => 1]);
|
|
|
|
|
|
|
|
|
|
$server = array('HTTP_X-Requested-With' => 'XMLHttpRequest');
|
|
|
|
|
|
|
|
|
|
$post = array(
|
|
|
|
|
'organiser_id' => $organiser->id,
|
|
|
|
|
'title' => $this->faker->text,
|
|
|
|
|
'description' => $this->faker->paragraph,
|
|
|
|
|
'location_venue_name' => $this->faker->company,
|
|
|
|
|
'location_address_line_1' => $this->faker->streetAddress,
|
|
|
|
|
'location_address_line_2' => '',
|
|
|
|
|
'location_state' => $this->faker->city,
|
|
|
|
|
'location_post_code' => $this->faker->postcode,
|
|
|
|
|
'start_date' => date('d-m-Y H:i', strtotime('+ 30 days')),
|
|
|
|
|
'end_date' => date('d-m-Y H:i', strtotime('+ 60 days')),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->call('post', route('postCreateEvent'), $post, $server);
|
|
|
|
|
|
|
|
|
|
$this->seeJson([
|
|
|
|
|
'status' => 'success',
|
|
|
|
|
'id' => 1,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function test_event_is_not_created_and_validation_error_messages_show()
|
|
|
|
|
{
|
|
|
|
|
$this->actingAs($this->test_user);
|
|
|
|
|
|
|
|
|
|
$organiser = factory(App\Models\Organiser::class)->create(['account_id' => 1]);
|
|
|
|
|
|
|
|
|
|
$server = array('HTTP_X-Requested-With' => 'XMLHttpRequest');
|
|
|
|
|
|
|
|
|
|
$post = array(
|
|
|
|
|
'organiser_id' => $organiser->id,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->call('post', route('postCreateEvent'), $post, $server);
|
|
|
|
|
|
|
|
|
|
$this->seeJson([
|
|
|
|
|
'status' => 'error',
|
|
|
|
|
]);
|
2016-04-27 23:06:17 +00:00
|
|
|
}
|
|
|
|
|
|
2016-06-16 01:36:09 +00:00
|
|
|
public function test_event_can_be_edited()
|
|
|
|
|
{
|
|
|
|
|
$organiser = factory(App\Models\Organiser::class)->create(['account_id' => 1]);
|
|
|
|
|
$event = factory(App\Models\Event::class)->create([
|
|
|
|
|
'account_id' => $organiser->account_id,
|
|
|
|
|
'organiser_id' => $organiser->id,
|
|
|
|
|
'user_id' => $this->test_user->id,
|
|
|
|
|
]);
|
2016-04-27 23:06:17 +00:00
|
|
|
|
2016-06-16 01:36:09 +00:00
|
|
|
$this->actingAs($this->test_user)
|
|
|
|
|
->visit(route('showEventCustomize', ['event_id' => $event->id]))
|
|
|
|
|
->type($this->faker->text, 'title')
|
|
|
|
|
->type($this->faker->paragraph, 'description')
|
|
|
|
|
->press('Save Changes')
|
|
|
|
|
->seeJson([
|
|
|
|
|
'status' => 'success',
|
|
|
|
|
]);
|
|
|
|
|
}
|
2016-04-27 23:06:17 +00:00
|
|
|
}
|