Skip to content

Commit c04ce6a

Browse files
committed
Remove tests directory from code coverage. Add test for bad property. Add test for bad class.
1 parent 013d23b commit c04ce6a

File tree

5 files changed

+75
-1
lines changed

5 files changed

+75
-1
lines changed

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</testsuites>
1818
<filter>
1919
<whitelist processUncoveredFilesFromWhitelist="true">
20-
<directory suffix="Test.php">tests</directory>
20+
<directory>src</directory>
2121
</whitelist>
2222
</filter>
2323
</phpunit>

tests/EntityTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Byscripts\StaticEntity\Tests;
44

5+
use Byscripts\StaticEntity\Tests\Fixtures\BadProperty;
56
use Byscripts\StaticEntity\Tests\Fixtures\Civility;
67
use Byscripts\StaticEntity\Tests\Fixtures\WebBrowser;
78
use PHPUnit\Framework\TestCase;
@@ -131,4 +132,13 @@ public function testFindIds()
131132

132133
$this->assertEquals([Civility::MR, Civility::MRS], $ids);
133134
}
135+
136+
/**
137+
* @expectedException \InvalidArgumentException
138+
* @expectedExceptionMessage has no property
139+
*/
140+
public function testBadProperty()
141+
{
142+
BadProperty::getAll();
143+
}
134144
}

tests/Fixtures/BadClass.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Byscripts\StaticEntity\Tests\Fixtures;
4+
5+
class BadClass
6+
{
7+
private $foo;
8+
9+
static function getDataSet(): array
10+
{
11+
return [
12+
1 => [
13+
'foo' => 'bar',
14+
],
15+
2 => [
16+
'foo' => 'bar',
17+
'bar' => 'baz',
18+
],
19+
];
20+
}
21+
}

tests/Fixtures/BadProperty.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Byscripts\StaticEntity\Tests\Fixtures;
4+
5+
use Byscripts\StaticEntity\AbstractStaticEntity;
6+
7+
class BadProperty extends AbstractStaticEntity
8+
{
9+
private $foo;
10+
11+
static function getDataSet(): array
12+
{
13+
return [
14+
1 => [
15+
'foo' => 'bar',
16+
],
17+
2 => [
18+
'foo' => 'bar',
19+
'bar' => 'baz',
20+
],
21+
];
22+
}
23+
}

tests/ProviderTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace Byscripts\StaticEntity\Tests;
44

55
use Byscripts\StaticEntity\Provider;
6+
use Byscripts\StaticEntity\Tests\Fixtures\BadClass;
7+
use Byscripts\StaticEntity\Tests\Fixtures\BadProperty;
68
use Byscripts\StaticEntity\Tests\Fixtures\Civility;
79
use Byscripts\StaticEntity\Tests\Fixtures\WebBrowser;
810
use PHPUnit\Framework\TestCase;
@@ -135,4 +137,22 @@ public function testFindIds()
135137

136138
$this->assertEquals([Civility::MR, Civility::MRS], $ids);
137139
}
140+
141+
/**
142+
* @expectedException \InvalidArgumentException
143+
* @expectedExceptionMessage has no property
144+
*/
145+
public function testBadProperty()
146+
{
147+
Provider::getAll(BadProperty::class);
148+
}
149+
150+
/**
151+
* @expectedException \InvalidArgumentException
152+
* @expectedExceptionMessage must implements
153+
*/
154+
public function testBadClass()
155+
{
156+
Provider::getAll(BadClass::class);
157+
}
138158
}

0 commit comments

Comments
 (0)