Skip to content

Commit

Permalink
#167 - Short array syntax usage in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocramius committed Dec 14, 2014
1 parent 23ad060 commit eadfe7e
Show file tree
Hide file tree
Showing 48 changed files with 437 additions and 437 deletions.
2 changes: 1 addition & 1 deletion tests/ProxyManagerTest/Factory/AbstractBaseFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function setUp()
->method('getUserClassName')
->will($this->returnValue('stdClass'));

$this->factory = $this->getMockForAbstractClass(AbstractBaseFactory::class, array($configuration));
$this->factory = $this->getMockForAbstractClass(AbstractBaseFactory::class, [$configuration]);

$this->factory->expects($this->any())->method('getGenerator')->will($this->returnValue($this->generator));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ public function testWillSkipAutoGeneration()

$factory = new AccessInterceptorScopeLocalizerFactory($this->config);
/* @var $proxy AccessInterceptorValueHolderMock */
$proxy = $factory->createProxy($instance, array('foo'), array('bar'));
$proxy = $factory->createProxy($instance, ['foo'], ['bar']);

$this->assertInstanceOf(AccessInterceptorValueHolderMock::class, $proxy);
$this->assertSame($instance, $proxy->instance);
$this->assertSame(array('foo'), $proxy->prefixInterceptors);
$this->assertSame(array('bar'), $proxy->suffixInterceptors);
$this->assertSame(['foo'], $proxy->prefixInterceptors);
$this->assertSame(['bar'], $proxy->suffixInterceptors);
}

/**
Expand Down Expand Up @@ -196,11 +196,11 @@ function () use ($proxyClassName) {

$factory = new AccessInterceptorScopeLocalizerFactory($this->config);
/* @var $proxy AccessInterceptorValueHolderMock */
$proxy = $factory->createProxy($instance, array('foo'), array('bar'));
$proxy = $factory->createProxy($instance, ['foo'], ['bar']);

$this->assertInstanceOf($proxyClassName, $proxy);
$this->assertSame($instance, $proxy->instance);
$this->assertSame(array('foo'), $proxy->prefixInterceptors);
$this->assertSame(array('bar'), $proxy->suffixInterceptors);
$this->assertSame(['foo'], $proxy->prefixInterceptors);
$this->assertSame(['bar'], $proxy->suffixInterceptors);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ public function testWillSkipAutoGeneration()

$factory = new AccessInterceptorValueHolderFactory($this->config);
/* @var $proxy AccessInterceptorValueHolderMock */
$proxy = $factory->createProxy($instance, array('foo'), array('bar'));
$proxy = $factory->createProxy($instance, ['foo'], ['bar']);

$this->assertInstanceOf(AccessInterceptorValueHolderMock::class, $proxy);
$this->assertSame($instance, $proxy->instance);
$this->assertSame(array('foo'), $proxy->prefixInterceptors);
$this->assertSame(array('bar'), $proxy->suffixInterceptors);
$this->assertSame(['foo'], $proxy->prefixInterceptors);
$this->assertSame(['bar'], $proxy->suffixInterceptors);
}

/**
Expand Down Expand Up @@ -195,11 +195,11 @@ function () use ($proxyClassName) {

$factory = new AccessInterceptorValueHolderFactory($this->config);
/* @var $proxy AccessInterceptorValueHolderMock */
$proxy = $factory->createProxy($instance, array('foo'), array('bar'));
$proxy = $factory->createProxy($instance, ['foo'], ['bar']);

$this->assertInstanceOf($proxyClassName, $proxy);
$this->assertSame($instance, $proxy->instance);
$this->assertSame(array('foo'), $proxy->prefixInterceptors);
$this->assertSame(array('bar'), $proxy->suffixInterceptors);
$this->assertSame(['foo'], $proxy->prefixInterceptors);
$this->assertSame(['bar'], $proxy->suffixInterceptors);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ public function testBaseAdapter()
{
$client = $this
->getMockBuilder('Zend\Server\Client')
->setMethods(array('call'))
->setMethods(['call'])
->getMock();

$adapter = $this->getMockForAbstractClass(
BaseAdapter::class,
array($client)
[$client]
);

$client
->expects($this->once())
->method('call')
->with('foobarbaz', array('tab' => 'taz'))
->with('foobarbaz', ['tab' => 'taz'])
->will($this->returnValue('baz'));

$adapter
Expand All @@ -63,7 +63,7 @@ public function testBaseAdapter()
->with('foo', 'bar')
->will($this->returnValue('foobarbaz'));

$this->assertSame('baz', $adapter->call('foo', 'bar', array('tab' => 'taz')));
$this->assertSame('baz', $adapter->call('foo', 'bar', ['tab' => 'taz']));
}

/**
Expand All @@ -77,18 +77,18 @@ public function testBaseAdapterWithServiceMap()
{
$client = $this
->getMockBuilder('Zend\Server\Client')
->setMethods(array('call'))
->setMethods(['call'])
->getMock();

$adapter = $this->getMockForAbstractClass(
BaseAdapter::class,
array($client, array('foobarbaz' => 'mapped'))
[$client, ['foobarbaz' => 'mapped']]
);

$client
->expects($this->once())
->method('call')
->with('mapped', array('tab' => 'taz'))
->with('mapped', ['tab' => 'taz'])
->will($this->returnValue('baz'));

$adapter
Expand All @@ -97,6 +97,6 @@ public function testBaseAdapterWithServiceMap()
->with('foo', 'bar')
->will($this->returnValue('foobarbaz'));

$this->assertSame('baz', $adapter->call('foo', 'bar', array('tab' => 'taz')));
$this->assertSame('baz', $adapter->call('foo', 'bar', ['tab' => 'taz']));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ public function testCanBuildAdapterWithJsonRpcClient()
{
$client = $this
->getMockBuilder('Zend\Server\Client')
->setMethods(array('call'))
->setMethods(['call'])
->getMock();

$adapter = new JsonRpc($client);

$client
->expects($this->once())
->method('call')
->with('foo.bar', array('tab' => 'taz'))
->with('foo.bar', ['tab' => 'taz'])
->will($this->returnValue('baz'));

$this->assertSame('baz', $adapter->call('foo', 'bar', array('tab' => 'taz')));
$this->assertSame('baz', $adapter->call('foo', 'bar', ['tab' => 'taz']));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ public function testCanBuildAdapterWithSoapRpcClient()
{
$client = $this
->getMockBuilder('Zend\Server\Client')
->setMethods(array('call'))
->setMethods(['call'])
->getMock();

$adapter = new Soap($client);

$client
->expects($this->once())
->method('call')
->with('bar', array('tab' => 'taz'))
->with('bar', ['tab' => 'taz'])
->will($this->returnValue('baz'));

$this->assertSame('baz', $adapter->call('foo', 'bar', array('tab' => 'taz')));
$this->assertSame('baz', $adapter->call('foo', 'bar', ['tab' => 'taz']));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ public function testCanBuildAdapterWithXmlRpcClient()
{
$client = $this
->getMockBuilder('Zend\Server\Client')
->setMethods(array('call'))
->setMethods(['call'])
->getMock();

$adapter = new XmlRpc($client);

$client
->expects($this->once())
->method('call')
->with('foo.bar', array('tab' => 'taz'))
->with('foo.bar', ['tab' => 'taz'])
->will($this->returnValue('baz'));

$this->assertSame('baz', $adapter->call('foo', 'bar', array('tab' => 'taz')));
$this->assertSame('baz', $adapter->call('foo', 'bar', ['tab' => 'taz']));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public function testMethodCalls($className, $instance, $method, $params, $expect
$proxy = $proxyName::staticProxyConstructor($instance);

$this->assertProxySynchronized($instance, $proxy);
$this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params));
$this->assertSame($expectedValue, call_user_func_array([$proxy, $method], $params));

$listener = $this->getMock('stdClass', array('__invoke'));
$listener = $this->getMock('stdClass', ['__invoke']);
$listener
->expects($this->once())
->method('__invoke')
Expand All @@ -71,7 +71,7 @@ function ($proxy, $instance, $method, $params, & $returnEarly) use ($listener) {
}
);

$this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params));
$this->assertSame($expectedValue, call_user_func_array([$proxy, $method], $params));

$random = uniqid();

Expand All @@ -84,7 +84,7 @@ function ($proxy, $instance, $method, $params, & $returnEarly) use ($random) {
}
);

$this->assertSame($random, call_user_func_array(array($proxy, $method), $params));
$this->assertSame($random, call_user_func_array([$proxy, $method], $params));
$this->assertProxySynchronized($instance, $proxy);
}

Expand All @@ -97,7 +97,7 @@ public function testMethodCallsWithSuffixListener($className, $instance, $method

/* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface */
$proxy = $proxyName::staticProxyConstructor($instance);
$listener = $this->getMock(stdClass::class, array('__invoke'));
$listener = $this->getMock(stdClass::class, ['__invoke']);
$listener
->expects($this->once())
->method('__invoke')
Expand All @@ -110,7 +110,7 @@ function ($proxy, $instance, $method, $params, $returnValue, & $returnEarly) use
}
);

$this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params));
$this->assertSame($expectedValue, call_user_func_array([$proxy, $method], $params));

$random = uniqid();

Expand All @@ -123,7 +123,7 @@ function ($proxy, $instance, $method, $params, $returnValue, & $returnEarly) use
}
);

$this->assertSame($random, call_user_func_array(array($proxy, $method), $params));
$this->assertSame($random, call_user_func_array([$proxy, $method], $params));
$this->assertProxySynchronized($instance, $proxy);
}

Expand All @@ -136,7 +136,7 @@ public function testMethodCallsAfterUnSerialization($className, $instance, $meth
/* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface */
$proxy = unserialize(serialize($proxyName::staticProxyConstructor($instance)));

$this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params));
$this->assertSame($expectedValue, call_user_func_array([$proxy, $method], $params));
$this->assertProxySynchronized($instance, $proxy);
}

Expand All @@ -152,7 +152,7 @@ public function testMethodCallsAfterCloning($className, $instance, $method, $par
$cloned = clone $proxy;

$this->assertProxySynchronized($instance, $proxy);
$this->assertSame($expectedValue, call_user_func_array(array($cloned, $method), $params));
$this->assertSame($expectedValue, call_user_func_array([$cloned, $method], $params));
$this->assertProxySynchronized($instance, $proxy);
}

Expand Down Expand Up @@ -222,9 +222,9 @@ public function testCanWriteToArrayKeysInPublicProperty()

$this->assertSame('bar', $proxy->arrayProperty['foo']);

$proxy->arrayProperty = array('tab' => 'taz');
$proxy->arrayProperty = ['tab' => 'taz'];

$this->assertSame(array('tab' => 'taz'), $proxy->arrayProperty);
$this->assertSame(['tab' => 'taz'], $proxy->arrayProperty);
$this->assertProxySynchronized($instance, $proxy);
}

Expand Down Expand Up @@ -324,39 +324,39 @@ public function getProxyMethods()
{
$selfHintParam = new ClassWithSelfHint();

$data = array(
array(
$data = [
[
BaseClass::class,
new BaseClass(),
'publicMethod',
array(),
[],
'publicMethodDefault'
),
array(
],
[
BaseClass::class,
new BaseClass(),
'publicTypeHintedMethod',
array('param' => new stdClass()),
['param' => new stdClass()],
'publicTypeHintedMethodDefault'
),
array(
],
[
BaseClass::class,
new BaseClass(),
'publicByReferenceMethod',
array(),
[],
'publicByReferenceMethodDefault'
),
);
],
];

if (PHP_VERSION_ID >= 50401) {
// PHP < 5.4.1 misbehaves, throwing strict standards, see https://bugs.php.net/bug.php?id=60573
$data[] = array(
$data[] = [
ClassWithSelfHint::class,
new ClassWithSelfHint(),
'selfHintMethod',
array('parameter' => $selfHintParam),
['parameter' => $selfHintParam],
$selfHintParam
);
];
}

return $data;
Expand All @@ -372,14 +372,14 @@ public function getPropertyAccessProxies()
$instance1 = new BaseClass();
$proxyName1 = $this->generateProxy(get_class($instance1));

return array(
array(
return [
[
$instance1,
$proxyName1::staticProxyConstructor($instance1),
'publicProperty',
'publicPropertyDefault',
),
);
],
];
}

/**
Expand Down
Loading

0 comments on commit eadfe7e

Please sign in to comment.