Skip to content

Commit 519e8d4

Browse files
committed
Added context tests
1 parent 65b14f5 commit 519e8d4

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

test/TUnit/ErrorTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,30 @@ public function testApiDestructor_DoesNotThrowError()
3838
unset($ex);
3939
}
4040

41+
/**
42+
*
43+
*/
44+
public function testApiSetContext_SetsContext()
45+
{
46+
$ex = $this->createError('Error');
47+
48+
$ex->setContext($context = [ 5, 'ABC', new \StdClass ]);
49+
50+
$this->assertSame($context, $this->getProtectedProperty($ex, 'context'));
51+
}
52+
53+
/**
54+
*
55+
*/
56+
public function testApiGetContext_GetsContext()
57+
{
58+
$ex = $this->createError('Error');
59+
60+
$ex->setContext($context = [ 5, 'ABC', new \StdClass ]);
61+
62+
$this->assertSame($context, $ex->getContext());
63+
}
64+
4165
/**
4266
*
4367
*/

test/TUnit/ExceptionTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,30 @@ public function testApiDestructor_DoesNotThrowException()
3838
unset($ex);
3939
}
4040

41+
/**
42+
*
43+
*/
44+
public function testApiSetContext_SetsContext()
45+
{
46+
$ex = $this->createException('Exception');
47+
48+
$ex->setContext($context = [ 5, 'ABC', new \StdClass ]);
49+
50+
$this->assertSame($context, $this->getProtectedProperty($ex, 'context'));
51+
}
52+
53+
/**
54+
*
55+
*/
56+
public function testApiGetContext_GetsContext()
57+
{
58+
$ex = $this->createException('Exception');
59+
60+
$ex->setContext($context = [ 5, 'ABC', new \StdClass ]);
61+
62+
$this->assertSame($context, $ex->getContext());
63+
}
64+
4165
/**
4266
*
4367
*/

test/TUnit/ThrowableProxyTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,30 @@ public function testApiDestructor_DoesNotThrowException()
132132
unset($proxy);
133133
}
134134

135+
/**
136+
*
137+
*/
138+
public function testApiSetContext_SetsContext()
139+
{
140+
$ex = $this->createThrowableProxy('');
141+
142+
$ex->setContext($context = [ 5, 'ABC', new \StdClass ]);
143+
144+
$this->assertSame($context, $this->getProtectedProperty($ex, 'context'));
145+
}
146+
147+
/**
148+
*
149+
*/
150+
public function testApiGetContext_GetsContext()
151+
{
152+
$ex = $this->createThrowableProxy('');
153+
154+
$ex->setContext($context = [ 5, 'ABC', new \StdClass ]);
155+
156+
$this->assertSame($context, $ex->getContext());
157+
}
158+
135159
/**
136160
*
137161
*/

0 commit comments

Comments
 (0)