I am creating a class with some unit tests, but i am not able to pass few tests. Example is shown below.
Unit Test
class OffsetTest extends \PHPUnit\Framework\TestCase
{
/**
* @dataProvider getIllegalOffsets
* @expectedException \InvalidArgumentException
* @param $offset
*/
public function testIllegalParameters($offset)
{
new \OffsetEncodingAlgorithm($offset);
$this->fail('Exception should be thrown');
}
/**
* Data provider for {@link OffsetTest::testIllegalParameters()}
* @return array
*/
public function getIllegalOffsets()
{
return [
[-1],
];
}
}
My Class
<?php
class Offset
{
public function __construct(int $offset = 13)
{
try {
if ($offset < 0) {
throw new Exception('Exception should be thrown');
}
} catch (Exception $e) {
return $e->getMessage();
}
$this->offset = $offset;
}
}
I want all to be passed