Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/7476'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed May 4, 2015
2 parents c91399c + 8bcd81d commit f24562c
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 111 deletions.
5 changes: 2 additions & 3 deletions test/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,8 @@ public function testObjectAsObject()

$encoded = Json\Encoder::encode($value);
$decoded = Json\Decoder::decode($encoded, Json\Json::TYPE_OBJECT);
$this->assertTrue(is_object($decoded), 'Not decoded as an object');
$this->assertTrue($decoded instanceof \stdClass, 'Not a stdClass object');
$this->assertTrue(isset($decoded->one), 'Expected property not set');
$this->assertInstanceOf('stdClass', $decoded);
$this->assertObjectHasAttribute('one', $decoded);
$this->assertEquals($value->one, $decoded->one, 'Unexpected value');
}

Expand Down
16 changes: 8 additions & 8 deletions test/Server/ErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ public function setupError()

public function validateArray($error)
{
$this->assertTrue(is_array($error));
$this->assertTrue(array_key_exists('code', $error));
$this->assertTrue(array_key_exists('message', $error));
$this->assertTrue(array_key_exists('data', $error));

$this->assertTrue(is_int($error['code']));
$this->assertTrue(is_string($error['message']));
$this->assertTrue(is_array($error['data']));
$this->assertInternalType('array', $error);
$this->assertArrayHasKey('code', $error);
$this->assertArrayHasKey('message', $error);
$this->assertArrayHasKey('data', $error);

$this->assertInternalType('integer', $error['code']);
$this->assertInternalType('string', $error['message']);
$this->assertInternalType('array', $error['data']);

$this->assertEquals($this->error->getCode(), $error['code']);
$this->assertEquals($this->error->getMessage(), $error['message']);
Expand Down
24 changes: 12 additions & 12 deletions test/Server/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function tearDown()
public function testShouldHaveNoParamsByDefault()
{
$params = $this->request->getParams();
$this->assertTrue(empty($params));
$this->assertEmpty($params);
}

public function testShouldBeAbleToAddAParamAsValueOnly()
Expand All @@ -58,7 +58,7 @@ public function testShouldBeAbleToAddAParamAsKeyValuePair()
$this->request->addParam('bar', 'foo');
$params = $this->request->getParams();
$this->assertEquals(1, count($params));
$this->assertTrue(array_key_exists('foo', $params));
$this->assertArrayHasKey('foo', $params);
$this->assertEquals('bar', $params['foo']);
}

Expand Down Expand Up @@ -108,9 +108,9 @@ public function testShouldBeAbleToAddMixedIndexedAndNamedParamsAtOnce()
$this->request->addParams($params);
$test = $this->request->getParams();
$this->assertEquals(array_values($params), array_values($test));
$this->assertTrue(array_key_exists('foo', $test));
$this->assertTrue(array_key_exists('baz', $test));
$this->assertTrue(in_array('baz', $test));
$this->assertArrayHasKey('foo', $test);
$this->assertArrayHasKey('baz', $test);
$this->assertContains('baz', $test);
}

public function testSetParamsShouldOverwriteParams()
Expand Down Expand Up @@ -252,15 +252,15 @@ public function getOptions()
public function validateJSON($json, array $options)
{
$test = Json\Json::decode($json, Json\Json::TYPE_ARRAY);
$this->assertTrue(is_array($test), var_export($json, 1));
$this->assertInternalType('array', $test, var_export($json, 1));

$this->assertTrue(array_key_exists('id', $test));
$this->assertTrue(array_key_exists('method', $test));
$this->assertTrue(array_key_exists('params', $test));
$this->assertArrayHasKey('id', $test);
$this->assertArrayHasKey('method', $test);
$this->assertArrayHasKey('params', $test);

$this->assertTrue(is_string($test['id']));
$this->assertTrue(is_string($test['method']));
$this->assertTrue(is_array($test['params']));
$this->assertInternalType('string', $test['id']);
$this->assertInternalType('string', $test['method']);
$this->assertInternalType('array', $test['params']);

$this->assertEquals($options['id'], $test['id']);
$this->assertEquals($options['method'], $test['method']);
Expand Down
30 changes: 15 additions & 15 deletions test/Server/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ public function testResponseShouldBeAbleToCastToJSON()
$json = $this->response->toJSON();
$test = Json\Json::decode($json, Json\Json::TYPE_ARRAY);

$this->assertTrue(is_array($test));
$this->assertTrue(array_key_exists('result', $test));
$this->assertFalse(array_key_exists('error', $test), "'error' may not coexist with 'result'");
$this->assertTrue(array_key_exists('id', $test));
$this->assertTrue(array_key_exists('jsonrpc', $test));
$this->assertInternalType('array', $test);
$this->assertArrayHasKey('result', $test);
$this->assertArrayNotHasKey('error', $test, "'error' may not coexist with 'result'");
$this->assertArrayHasKey('id', $test);
$this->assertArrayHasKey('jsonrpc', $test);

$this->assertTrue($test['result']);
$this->assertEquals($this->response->getId(), $test['id']);
Expand All @@ -145,11 +145,11 @@ public function testResponseShouldCastErrorToJSONIfIsError()
$json = $this->response->toJSON();
$test = Json\Json::decode($json, Json\Json::TYPE_ARRAY);

$this->assertTrue(is_array($test));
$this->assertFalse(array_key_exists('result', $test), "'result' may not coexist with 'error'");
$this->assertTrue(array_key_exists('error', $test));
$this->assertTrue(array_key_exists('id', $test));
$this->assertFalse(array_key_exists('jsonrpc', $test));
$this->assertInternalType('array', $test);
$this->assertArrayNotHasKey('result', $test, "'result' may not coexist with 'error'");
$this->assertArrayHasKey('error', $test);
$this->assertArrayHasKey('id', $test);
$this->assertArrayNotHasKey('jsonrpc', $test);

$this->assertEquals($this->response->getId(), $test['id']);
$this->assertEquals($error->getCode(), $test['error']['code']);
Expand All @@ -163,11 +163,11 @@ public function testCastToStringShouldCastToJSON()
$json = $this->response->__toString();
$test = Json\Json::decode($json, Json\Json::TYPE_ARRAY);

$this->assertTrue(is_array($test));
$this->assertTrue(array_key_exists('result', $test));
$this->assertFalse(array_key_exists('error', $test), "'error' may not coexist with 'result'");
$this->assertTrue(array_key_exists('id', $test));
$this->assertFalse(array_key_exists('jsonrpc', $test));
$this->assertInternalType('array', $test);
$this->assertArrayHasKey('result', $test);
$this->assertArrayNotHasKey('error', $test, "'error' may not coexist with 'result'");
$this->assertArrayHasKey('id', $test);
$this->assertArrayNotHasKey('jsonrpc', $test);

$this->assertTrue($test['result']);
$this->assertEquals($this->response->getId(), $test['id']);
Expand Down
18 changes: 9 additions & 9 deletions test/Server/Smd/ServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function testTargetAccessorsShouldNormalizeToString()
$this->testTargetShouldBeNullInitially();
$this->service->setTarget(123);
$value = $this->service->getTarget();
$this->assertTrue(is_string($value));
$this->assertInternalType('string', $value);
$this->assertEquals((string) 123, $value);
}

Expand All @@ -156,7 +156,7 @@ public function testEnvelopeShouldOnlyComplyWithJSONRpc1And2()
public function testShouldHaveNoParamsByDefault()
{
$params = $this->service->getParams();
$this->assertTrue(empty($params));
$this->assertEmpty($params);
}

public function testShouldBeAbleToAddParamsByTypeOnly()
Expand All @@ -175,7 +175,7 @@ public function testParamsShouldAcceptArrayOfTypes()
$params = $this->service->getParams();
$param = array_shift($params);
$test = $param['type'];
$this->assertTrue(is_array($test));
$this->assertInternalType('array', $test);
$this->assertEquals($type, $test);
}

Expand Down Expand Up @@ -296,8 +296,8 @@ public function testTojsonShouldEmitJSON()
$json = $this->service->toJSON();
$smd = \Zend\Json\Json::decode($json, \Zend\Json\Json::TYPE_ARRAY);

$this->assertTrue(array_key_exists('foo', $smd));
$this->assertTrue(is_array($smd['foo']));
$this->assertArrayHasKey('foo', $smd);
$this->assertInternalType('array', $smd['foo']);

$this->validateSmdArray($smd['foo']);
}
Expand All @@ -316,13 +316,13 @@ public function setupSmdValidationObject()

public function validateSmdArray(array $smd)
{
$this->assertTrue(array_key_exists('transport', $smd));
$this->assertArrayHasKey('transport', $smd);
$this->assertEquals('POST', $smd['transport']);

$this->assertTrue(array_key_exists('envelope', $smd));
$this->assertArrayHasKey('envelope', $smd);
$this->assertEquals(Server\Smd::ENV_JSONRPC_2, $smd['envelope']);

$this->assertTrue(array_key_exists('parameters', $smd));
$this->assertArrayHasKey('parameters', $smd);
$params = $smd['parameters'];
$this->assertEquals(3, count($params));
$param = array_shift($params);
Expand All @@ -332,7 +332,7 @@ public function validateSmdArray(array $smd)
$param = array_shift($params);
$this->assertEquals('object', $param['type']);

$this->assertTrue(array_key_exists('returns', $smd));
$this->assertArrayHasKey('returns', $smd);
$this->assertEquals('boolean', $smd['returns']);
}
}
50 changes: 25 additions & 25 deletions test/Server/SmdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ public function testDojoCompatibilityFlagShouldBeMutable()
public function testServicesShouldBeEmptyByDefault()
{
$services = $this->smd->getServices();
$this->assertTrue(is_array($services));
$this->assertTrue(empty($services));
$this->assertInternalType('array', $services);
$this->assertEmpty($services);
}

public function testShouldBeAbleToUseServiceObjectToAddService()
Expand All @@ -178,7 +178,7 @@ public function testShouldBeAbleToUseArrayToAddService()
);
$this->smd->addService($service);
$foo = $this->smd->getService('foo');
$this->assertTrue($foo instanceof Smd\Service);
$this->assertInstanceOf('Zend\Json\Server\Smd\Service', $foo);
$this->assertEquals('foo', $foo->getName());
}

Expand Down Expand Up @@ -285,33 +285,33 @@ public function testShouldBeAbleToCastToDojoArray()
$this->smd->setOptions($options);
$smd = $this->smd->toDojoArray();

$this->assertTrue(is_array($smd));
$this->assertInternalType('array', $smd);

$this->assertTrue(array_key_exists('SMDVersion', $smd));
$this->assertTrue(array_key_exists('serviceType', $smd));
$this->assertTrue(array_key_exists('methods', $smd));
$this->assertArrayHasKey('SMDVersion', $smd);
$this->assertArrayHasKey('serviceType', $smd);
$this->assertArrayHasKey('methods', $smd);

$this->assertEquals('.1', $smd['SMDVersion']);
$this->assertEquals('JSON-RPC', $smd['serviceType']);
$methods = $smd['methods'];
$this->assertEquals(2, count($methods));

$foo = array_shift($methods);
$this->assertTrue(array_key_exists('name', $foo));
$this->assertTrue(array_key_exists('serviceURL', $foo));
$this->assertTrue(array_key_exists('parameters', $foo));
$this->assertArrayHasKey('name', $foo);
$this->assertArrayHasKey('serviceURL', $foo);
$this->assertArrayHasKey('parameters', $foo);
$this->assertEquals('foo', $foo['name']);
$this->assertEquals($this->smd->getTarget(), $foo['serviceURL']);
$this->assertTrue(is_array($foo['parameters']));
$this->assertInternalType('array', $foo['parameters']);
$this->assertEquals(1, count($foo['parameters']));

$bar = array_shift($methods);
$this->assertTrue(array_key_exists('name', $bar));
$this->assertTrue(array_key_exists('serviceURL', $bar));
$this->assertTrue(array_key_exists('parameters', $bar));
$this->assertArrayHasKey('name', $bar);
$this->assertArrayHasKey('serviceURL', $bar);
$this->assertArrayHasKey('parameters', $bar);
$this->assertEquals('bar', $bar['name']);
$this->assertEquals($this->smd->getTarget(), $bar['serviceURL']);
$this->assertTrue(is_array($bar['parameters']));
$this->assertInternalType('array', $bar['parameters']);
$this->assertEquals(1, count($bar['parameters']));
}

Expand Down Expand Up @@ -359,15 +359,15 @@ public function getOptions()

public function validateServiceArray(array $smd, array $options)
{
$this->assertTrue(is_array($smd));
$this->assertInternalType('array', $smd);

$this->assertTrue(array_key_exists('SMDVersion', $smd));
$this->assertTrue(array_key_exists('target', $smd));
$this->assertTrue(array_key_exists('id', $smd));
$this->assertTrue(array_key_exists('transport', $smd));
$this->assertTrue(array_key_exists('envelope', $smd));
$this->assertTrue(array_key_exists('contentType', $smd));
$this->assertTrue(array_key_exists('services', $smd));
$this->assertArrayHasKey('SMDVersion', $smd);
$this->assertArrayHasKey('target', $smd);
$this->assertArrayHasKey('id', $smd);
$this->assertArrayHasKey('transport', $smd);
$this->assertArrayHasKey('envelope', $smd);
$this->assertArrayHasKey('contentType', $smd);
$this->assertArrayHasKey('services', $smd);

$this->assertEquals(Smd::SMD_VERSION, $smd['SMDVersion']);
$this->assertEquals($options['target'], $smd['target']);
Expand All @@ -377,8 +377,8 @@ public function validateServiceArray(array $smd, array $options)
$this->assertEquals($this->smd->getContentType(), $smd['contentType']);
$services = $smd['services'];
$this->assertEquals(2, count($services));
$this->assertTrue(array_key_exists('foo', $services));
$this->assertTrue(array_key_exists('bar', $services));
$this->assertArrayHasKey('foo', $services);
$this->assertArrayHasKey('bar', $services);
}

/**
Expand Down
Loading

0 comments on commit f24562c

Please sign in to comment.