<?php
use App\Activity;
use App\User;

class ActivityTest extends TestCase
{
    /**
     * Test to check get activities
     *
     * @return void
     */
    public function testActivities()
    {
       $response = $this->call('GET', 'api/v1/activity/');
       $this->assertEquals(200, $response->status());
    }
    
    /**
     * Test to check get activity of sub admin
     *
     * @return void
     */
    public function testGetActivity()
    {
       
        $this->get('api/v1/activity/0000')->seeJson([
                'status' => 'fail',
             ]);

        $last = User::max('id');
        $activity           = new Activity();
        $activity->name = str_random(5);
        $activity->user_id = 1;
        $activity->description = str_random(5);
        $activity->type = 'sample';
        $date               = new \DateTime();
        $ddf                = $date->format('Y-m-d');
        $activity->created  = $ddf;
        $activity->save();

        $lastId = $activity->id;

        $response = $this->call('GET', "api/v1/activity/$lastId");
        $this->assertEquals(200, $response->status());

    }
    
    /**
     * Test to check get activity by filter dates
     *
     * @return void
     */
    public function testGetActivityFilter()
    {
       $response = $this->call('POST', 'api/v1/activity/filter', ['startDate' => '2015/01/01', 'endDate' => '2017/01/01']); 
       $this->assertEquals(200, $response->status());
       
       $response1 = $this->call('POST', 'api/v1/activity/filter', ['startDate' => '', 'endDate' => '']); 
       $this->assertNotEquals(200, $response1->status());
       
    }
}
