Skip to content

Commit 5b7cf95

Browse files
test(jusibe): Test some private methods
1 parent 55313e7 commit 5b7cf95

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/JusibeTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Unicodeveloper\Jusibe\Test;
1313

1414
use StdClass;
15+
use ReflectionClass;
1516
use PHPUnit_Framework_TestCase;
1617
use Unicodeveloper\Jusibe\Helper;
1718
use Unicodeveloper\Jusibe\Jusibe;
@@ -255,4 +256,37 @@ public function testInvalidMessageIDWhenCheckingDeliveryStatus()
255256
$this->assertObjectHasAttribute('invalid_message_id', $result);
256257
$this->assertEquals("Invalid message ID", $result->invalid_message_id);
257258
}
259+
260+
/**
261+
* Invoke testPrepareRequest
262+
*/
263+
public function testPrepareRequest()
264+
{
265+
$this->invokeMethod($this->jusibe, 'prepareRequest', []);
266+
}
267+
268+
/**
269+
* Invoke testPerformGetRequest
270+
*/
271+
public function testPerformGetRequest()
272+
{
273+
$this->invokeMethod($this->jusibe, 'performGetRequest', ['/smsapi/get_credits']);
274+
}
275+
276+
/**
277+
* Call protected/private method of a class.
278+
*
279+
* @param object &$object Instantiated object that we will run method on.
280+
* @param string $methodName Method name to call
281+
* @param array $parameters Array of parameters to pass into method.
282+
*
283+
* @return mixed Method return.
284+
*/
285+
private function invokeMethod(&$object, $methodName, array $parameters = array())
286+
{
287+
$reflection = new ReflectionClass(get_class($object));
288+
$method = $reflection->getMethod($methodName);
289+
$method->setAccessible(true);
290+
return $method->invokeArgs($object, $parameters);
291+
}
258292
}

0 commit comments

Comments
 (0)