I have two php files. The first one func.php contains a function, and the second one funcTest.php is for testing the function.
First:
<?php
    function func(int $a, int $b, $data) {
          echo "$a, $b, $data";
          return $a + $b;
    }
Second:
<?php
    require_once "PHPUnit/Autoload.php";
    use PHPUnit\Framework\TestCase;
    
    $data = "Some data";
    var_dump($data);
    
    final class funcTest extends PHPUnit_Framework_TestCase {
        public function testFunc() {
            require "func.php";
            $this->assertEquals(3, func(1, 2, $data));
        }
    }
The problem is when I run test using phpunit in cmd, I get these errors:
There was 1 error:
- funcTest::testFunc Undefined variable: data
C:\xampp\htdocs\someproject\funcTest.php:12
P.S. I've found similar questions on SO and other forums, but none of those helped me. So please DO NOT CLOSE OR DISS MY QUESTION.
 
     
    