<?php

namespace tests\goalsModule;

use goals\classes\goals;
use goals\classes\goals_criteria;
use goals\helpers\goals_criteria_type;
use PHPUnit\Framework\TestCase;

class goalsTest extends TestCase
{
    public function testGoalsInitialization()
    {
        $goal = new goals();
        $this->assertInstanceOf(goals::class, $goal);
        $this->assertInstanceOf(goals_criteria::class, $goal->criteria);
    }

    public function testGetResultDefault()
    {
        $goal = new goals();
        $this->assertEquals(0, $goal->getResult());
    }

    public function testGetPercentage()
    {
        $goal = new goals();
        $goal->criteria->setTarget(100);
        
        // Mocking getResult is hard without dependency injection or better structure, 
        // but since we know it returns 0 by default:
        $this->assertEquals(0.0, $goal->getPercentage());

        // Manually setting a result isn't possible as getResult() calculates it.
        // But we can check if it handles target 0 correctly.
        $goal->criteria->setTarget(0);
        $this->assertEquals(0.0, $goal->getPercentage());
    }

    public function testGetRemaining()
    {
        $goal = new goals();
        $goal->criteria->setTarget(50);
        // Result is 0, so remaining should be 50
        $this->assertEquals(50, $goal->getRemaining());
    }
}
