-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathStdObjectPolyfillTest.php
More file actions
40 lines (30 loc) · 1.06 KB
/
Copy pathStdObjectPolyfillTest.php
File metadata and controls
40 lines (30 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
use PHPUnit\Framework\TestCase;
class StdObjectPolyfillBase
{
}
final class StdObjectPolyfillChild extends StdObjectPolyfillBase
{
}
final class StdObjectPolyfillTest extends TestCase
{
public function testReturnsAnObjectOfTheRequestedClass(): void
{
$object = new StdObjectPolyfillBase();
self::assertSame($object, std::object($object, StdObjectPolyfillBase::class));
$child = new StdObjectPolyfillChild();
self::assertSame($child, std::object($child, StdObjectPolyfillBase::class));
}
public function testRejectsANonObjectValue(): void
{
$this->expectException(TypeError::class);
$this->expectExceptionMessage('must be an object, int given');
std::object(42, StdObjectPolyfillBase::class);
}
public function testRejectsAnUnrelatedObject(): void
{
$this->expectException(TypeError::class);
$this->expectExceptionMessage('must be an instance of StdObjectPolyfillBase, stdClass given');
std::object(new stdClass(), StdObjectPolyfillBase::class);
}
}