<?php

namespace Tests\Unit\Models;

use App\Jobs\ProjectDownloadTiffJob;
use App\Models\Project;

use App\Models\ProjectReport;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
use Mockery;
use Tests\TestCase;

class ProjectReportTest extends TestCase
{
    use RefreshDatabase;

    protected function setUp(): void
    {
        parent::setUp(); // TODO: Change the autogenerated stub
    }

//    /**
//     * @test
//     * @dataProvider weeksAgoProvider
//     */
//    public function it_can_calculatore_weeksAgo($endDate, $offset, $expected)
//    {
//        Carbon::setTestNow(Carbon::now()->setISODate('2021', '41'));
//        $projectReport = ProjectReport::make([
//            'end_date' => $endDate,
//            'offset' => $offset,
//        ]);
//        $this->assertEquals($expected, $projectReport->weeksAgo());
//    }
//
//    public static function weeksAgoProvider()
//    {
//        return [
//            '1 week ago'  => [2021, 40, 1],
//            '2 weeks ago' => [2021, 39, 2],
//            '3 weeks ago' => [2021, 38, 3],
//        ];
//    }

    /**
     * @test
     */
    public function it_can_get_the_full_path_name()
    {
        $project = Project::create([
            'name'          => 'project_name',
            'download_path' => 'project_download_path',
        ]);
        $projectReport = $project->reports()->create([
            'name'   => 'name',
            'end_date'   => new Carbon('2021-01-01'),
            'offset'   => 10,
            'path'   => 'path/doc.pdf',
        ]);
        $projectReport->setStatusSuccess();
        $this->assertEquals(storage_path('app/project_download_path/path/doc.pdf'), $projectReport->getFullPathName());
    }

    /**
     * @test
     * @dataProvider reportDateProvider
     */
    public function it_can_return_the_reportDate($expected, $mail_day, $endDate, $offset)
    {
        $project = Project::create([
            'name'          => 'project_name',
            'download_path' => 'project_download_path',
            'mail_day'      => $mail_day,
        ]);
        $projectReport = $project->reports()->create([
            'name'   => 'name',
            'end_date'   => $endDate,
            'offset'   => $offset,
            'path'   => 'path/doc.pdf',
        ]);
        $projectReport->setStatusSuccess();
        $this->assertEquals($expected, $projectReport->getReportDate());
    }


    public static function reportDateProvider()
    {
        return [
            'monday'    => ['2023-12-10', 'monday',new Carbon('2023-12-10'),10 ],
            'tuesday'   => ['2023-12-11', 'tuesday',new Carbon('2023-12-11'),10 ],
            'wednesday' => ['2023-12-12', 'wednesday',new Carbon('2023-12-12'),10 ],
            'thursday'  => ['2023-12-13', 'thursday',new Carbon('2023-12-13'),10 ],
            'friday'    => ['2023-12-14', 'friday',new Carbon('2023-12-14'),10 ],
            'saturday'  => ['2023-12-15', 'saturday',new Carbon('2023-12-15'),10 ],
            'sunday'    => ['2023-12-16', 'sunday',new Carbon('2023-12-16'),10 ],
        ];
    }



}


