예제 #1
0
 public function testRetrieveIP()
 {
     $this->assertEmpty(Helper::getCurrentIP());
     putenv('REMOTE_ADDR=8.8.8.8');
     $this->assertEquals('8.8.8.8', Helper::getCurrentIP());
     putenv('REMOTE_ADDR=');
     putenv('HTTP_CLIENT_IP=8.8.4.4, 8.8.8.8');
     $this->assertEquals('8.8.4.4', Helper::getCurrentIP());
     putenv('REMOTE_ADDR=');
     putenv('HTTP_CLIENT_IP=127.0.0.1');
     $this->assertEmpty(Helper::getCurrentIP());
 }
<?php

/**
 * Get resource access model from a resource key
 * 
 * @author Aaron Saray
 */
/** @var \iMoneza\Connection $connection */
$connection = (require '_build-connection.php');
$options = new \iMoneza\Options\Access\GetResourceFromResourceKey();
$options->setApiBaseURL(getenv('ACCESS_API_URL'));
// only for testing
$options->setResourceKey('x')->setIP(\iMoneza\Helper::getCurrentIP())->setResourceURL('x');
$result = $connection->request($options, $options->getDataObject());
print "Here is the result:\n";
var_dump($result);