Class to test(Example.php):
<?php
namespace Example;
class Example {
    public function doSomething()
    {
         return time();
    }
}
<?php
namespace Example {
    function time()
    {
        return 5;
    }
}
namespace ExampleTest {
    use Example\Example;
    class ExampleTest extends \PHPUnit_Framework_TestCase {
        protected $sut;
        public function setUp()
        {
             $this->sut = new Example();
        }
        public function testDoSomething()
        {
             $this->assertSame(5, $this->sut->doSomething());
        }
    }
}
 
No comments:
Post a Comment