From 7fdd8ead253381896e45f97dc079d82e204da5d0 Mon Sep 17 00:00:00 2001 From: Jefersson Nathan Date: Wed, 27 Feb 2019 13:40:41 +0100 Subject: [PATCH] Improve usage of phpunit * Remove unnecessary assertions * Avoid using deprecated assertions (https://github.com/sebastianbergmann/phpunit/issues/3338) * Add more entropy when needed * Use static methods whenever possible (providers, test cases that don't access object context) Signed-off-by: Jefersson Nathan --- .../Autoloader/AutoloaderTest.php | 12 +++--- tests/ProxyManagerTest/ConfigurationTest.php | 12 ++++-- .../FileNotWritableExceptionTest.php | 2 - .../Factory/AbstractBaseFactoryTest.php | 23 ++++------ ...ssInterceptorScopeLocalizerFactoryTest.php | 21 +++++----- ...ccessInterceptorValueHolderFactoryTest.php | 19 ++++----- .../Factory/LazyLoadingGhostFactoryTest.php | 20 ++++----- .../LazyLoadingValueHolderFactoryTest.php | 21 +++++----- .../Factory/NullObjectFactoryTest.php | 24 ++++------- .../RemoteObject/Adapter/BaseAdapterTest.php | 8 ++-- .../RemoteObject/Adapter/JsonRpcTest.php | 2 +- .../Factory/RemoteObject/Adapter/SoapTest.php | 2 +- .../RemoteObject/Adapter/XmlRpcTest.php | 2 +- .../Factory/RemoteObjectFactoryTest.php | 23 ++++------ ...nterceptorScopeLocalizerFunctionalTest.php | 12 +++--- ...ssInterceptorValueHolderFunctionalTest.php | 9 ++-- .../FatalPreventionFunctionalTest.php | 6 +-- .../LazyLoadingGhostFunctionalTest.php | 16 +++---- .../LazyLoadingValueHolderFunctionalTest.php | 8 ++-- .../Functional/NullObjectFunctionalTest.php | 2 +- .../Functional/RemoteObjectFunctionalTest.php | 10 ++--- .../Generator/MethodGeneratorTest.php | 2 +- .../Generator/Util/IdentifierSuffixerTest.php | 4 +- .../Util/UniqueIdentifierGeneratorTest.php | 2 +- .../FileWriterGeneratorStrategyTest.php | 13 +++--- .../Inflector/ClassNameInflectorTest.php | 4 +- .../Inflector/Util/ParameterEncoderTest.php | 2 +- .../Inflector/Util/ParameterHasherTest.php | 2 +- .../SetMethodPrefixInterceptorTest.php | 2 +- .../SetMethodSuffixInterceptorTest.php | 2 +- .../BindProxyPropertiesTest.php | 4 +- .../MethodGenerator/InterceptedMethodTest.php | 4 +- .../MethodGenerator/MagicCloneTest.php | 8 ++-- .../MethodGenerator/MagicGetTest.php | 8 ++-- .../MethodGenerator/MagicIssetTest.php | 8 ++-- .../MethodGenerator/MagicSetTest.php | 8 ++-- .../MethodGenerator/MagicSleepTest.php | 8 ++-- .../MethodGenerator/MagicUnsetTest.php | 8 ++-- .../StaticProxyConstructorTest.php | 4 +- .../Util/InterceptorGeneratorTest.php | 36 ++++++++-------- .../MethodGenerator/InterceptedMethodTest.php | 6 +-- .../MethodGenerator/MagicCloneTest.php | 6 +-- .../MethodGenerator/MagicGetTest.php | 8 ++-- .../MethodGenerator/MagicIssetTest.php | 8 ++-- .../MethodGenerator/MagicSetTest.php | 8 ++-- .../MethodGenerator/MagicUnsetTest.php | 8 ++-- .../StaticProxyConstructorTest.php | 18 ++++---- .../Util/InterceptorGeneratorTest.php | 42 +++++++++---------- .../StaticProxyConstructorTest.php | 2 +- .../MethodGenerator/CallInitializerTest.php | 8 ++-- .../GetProxyInitializerTest.php | 2 +- .../MethodGenerator/InitializeProxyTest.php | 4 +- .../IsProxyInitializedTest.php | 2 +- .../MethodGenerator/MagicCloneTest.php | 4 +- .../MethodGenerator/MagicGetTest.php | 14 +++---- .../MethodGenerator/MagicIssetTest.php | 12 +++--- .../MethodGenerator/MagicSetTest.php | 12 +++--- .../MethodGenerator/MagicSleepTest.php | 4 +- .../MethodGenerator/MagicUnsetTest.php | 12 +++--- .../SetProxyInitializerTest.php | 2 +- .../GetProxyInitializerTest.php | 2 +- .../MethodGenerator/InitializeProxyTest.php | 4 +- .../IsProxyInitializedTest.php | 2 +- .../LazyLoadingMethodInterceptorTest.php | 10 ++--- .../MethodGenerator/MagicCloneTest.php | 4 +- .../MethodGenerator/MagicGetTest.php | 16 +++---- .../MethodGenerator/MagicIssetTest.php | 8 ++-- .../MethodGenerator/MagicSetTest.php | 16 +++---- .../MethodGenerator/MagicSleepTest.php | 4 +- .../MethodGenerator/MagicUnsetTest.php | 16 +++---- .../SetProxyInitializerTest.php | 2 +- .../NullObjectGeneratorTest.php | 2 +- .../PublicPropertiesMapTest.php | 4 +- .../MethodGenerator/MagicGetTest.php | 2 +- .../MethodGenerator/MagicIssetTest.php | 2 +- .../MethodGenerator/MagicSetTest.php | 2 +- .../MethodGenerator/MagicUnsetTest.php | 2 +- .../RemoteObjectMethodTest.php | 6 +-- .../StaticProxyConstructorTest.php | 2 +- .../MethodGenerator/ConstructorTest.php | 8 ++-- .../GetWrappedValueHolderValueTest.php | 2 +- .../MethodGenerator/MagicSleepTest.php | 2 +- .../Signature/ClassSignatureGeneratorTest.php | 6 +-- .../InvalidSignatureExceptionTest.php | 2 - .../MissingSignatureExceptionTest.php | 2 - .../Signature/SignatureCheckerTest.php | 17 ++++---- .../Signature/SignatureGeneratorTest.php | 4 +- tests/ProxyManagerTest/VersionTest.php | 4 +- 88 files changed, 340 insertions(+), 378 deletions(-) diff --git a/tests/ProxyManagerTest/Autoloader/AutoloaderTest.php b/tests/ProxyManagerTest/Autoloader/AutoloaderTest.php index bc5c87b6f..4f2268c07 100644 --- a/tests/ProxyManagerTest/Autoloader/AutoloaderTest.php +++ b/tests/ProxyManagerTest/Autoloader/AutoloaderTest.php @@ -56,7 +56,7 @@ public function testWillNotAutoloadUserClasses() : void ->expects(self::once()) ->method('isProxyClassName') ->with($className) - ->will(self::returnValue(false)); + ->willReturn(false); self::assertFalse($this->autoloadWithoutFurtherAutoloaders($className)); } @@ -72,12 +72,12 @@ public function testWillNotAutoloadNonExistingClass() : void ->expects(self::once()) ->method('isProxyClassName') ->with($className) - ->will(self::returnValue(true)); + ->willReturn(true); $this ->fileLocator ->expects(self::once()) ->method('getProxyFileName') - ->will(self::returnValue(__DIR__ . '/non-existing')); + ->willReturn(__DIR__ . '/non-existing'); self::assertFalse($this->autoloadWithoutFurtherAutoloaders($className)); } @@ -98,7 +98,7 @@ public function testWillAutoloadExistingFile() : void $namespace = 'Foo'; $className = UniqueIdentifierGenerator::getIdentifier('Bar'); $fqcn = $namespace . '\\' . $className; - $fileName = sys_get_temp_dir() . '/foo_' . uniqid() . '.php'; + $fileName = sys_get_temp_dir() . '/foo_' . uniqid('file', true) . '.php'; file_put_contents($fileName, 'expects(self::once()) ->method('isProxyClassName') ->with($fqcn) - ->will(self::returnValue(true)); + ->willReturn(true); $this ->fileLocator ->expects(self::once()) ->method('getProxyFileName') - ->will(self::returnValue($fileName)); + ->willReturn($fileName); self::assertTrue($this->autoloadWithoutFurtherAutoloaders($fqcn)); self::assertTrue(class_exists($fqcn, false)); diff --git a/tests/ProxyManagerTest/ConfigurationTest.php b/tests/ProxyManagerTest/ConfigurationTest.php index 1751d9a39..7af69b603 100644 --- a/tests/ProxyManagerTest/ConfigurationTest.php +++ b/tests/ProxyManagerTest/ConfigurationTest.php @@ -13,7 +13,6 @@ use ProxyManager\Signature\ClassSignatureGeneratorInterface; use ProxyManager\Signature\SignatureCheckerInterface; use ProxyManager\Signature\SignatureGeneratorInterface; -use function is_dir; /** * Tests for {@see \ProxyManager\Configuration} @@ -55,6 +54,7 @@ public function testGetSetProxiesNamespace() : void */ public function testSetGetClassNameInflector() : void { + /** @noinspection UnnecessaryAssertionInspection */ self::assertInstanceOf(ClassNameInflectorInterface::class, $this->configuration->getClassNameInflector()); /** @var ClassNameInflectorInterface $inflector */ @@ -78,6 +78,7 @@ public function testDefaultGeneratorStrategyNeedToBeAInstanceOfEvaluatingGenerat */ public function testSetGetGeneratorStrategy() : void { + /** @noinspection UnnecessaryAssertionInspection */ self::assertInstanceOf(GeneratorStrategyInterface::class, $this->configuration->getGeneratorStrategy()); /** @var GeneratorStrategyInterface $strategy */ @@ -93,7 +94,7 @@ public function testSetGetGeneratorStrategy() : void */ public function testSetGetProxiesTargetDir() : void { - self::assertTrue(is_dir($this->configuration->getProxiesTargetDir())); + self::assertDirectoryExists($this->configuration->getProxiesTargetDir()); $this->configuration->setProxiesTargetDir(__DIR__); self::assertSame(__DIR__, $this->configuration->getProxiesTargetDir()); @@ -105,6 +106,7 @@ public function testSetGetProxiesTargetDir() : void */ public function testSetGetProxyAutoloader() : void { + /** @noinspection UnnecessaryAssertionInspection */ self::assertInstanceOf(AutoloaderInterface::class, $this->configuration->getProxyAutoloader()); /** @var AutoloaderInterface $autoloader */ @@ -120,7 +122,8 @@ public function testSetGetProxyAutoloader() : void */ public function testSetGetSignatureGenerator() : void { - self::assertInstanceOf(SignatureGeneratorInterface::class, $this->configuration->getSignatureGenerator()); + /** @noinspection UnnecessaryAssertionInspection */ + self::assertInstanceOf(SignatureCheckerInterface::class, $this->configuration->getSignatureChecker()); /** @var SignatureGeneratorInterface $signatureGenerator */ $signatureGenerator = $this->createMock(SignatureGeneratorInterface::class); @@ -135,6 +138,7 @@ public function testSetGetSignatureGenerator() : void */ public function testSetGetSignatureChecker() : void { + /** @noinspection UnnecessaryAssertionInspection */ self::assertInstanceOf(SignatureCheckerInterface::class, $this->configuration->getSignatureChecker()); /** @var SignatureCheckerInterface $signatureChecker */ @@ -150,11 +154,11 @@ public function testSetGetSignatureChecker() : void */ public function testSetGetClassSignatureGenerator() : void { + /** @noinspection UnnecessaryAssertionInspection */ self::assertInstanceOf( ClassSignatureGeneratorInterface::class, $this->configuration->getClassSignatureGenerator() ); - /** @var ClassSignatureGeneratorInterface $classSignatureGenerator */ $classSignatureGenerator = $this->createMock(ClassSignatureGeneratorInterface::class); diff --git a/tests/ProxyManagerTest/Exception/FileNotWritableExceptionTest.php b/tests/ProxyManagerTest/Exception/FileNotWritableExceptionTest.php index 5fc8a8bbe..afa51df48 100644 --- a/tests/ProxyManagerTest/Exception/FileNotWritableExceptionTest.php +++ b/tests/ProxyManagerTest/Exception/FileNotWritableExceptionTest.php @@ -19,7 +19,6 @@ public function testFromInvalidMoveOperation() : void { $exception = FileNotWritableException::fromInvalidMoveOperation('/tmp/a', '/tmp/b'); - self::assertInstanceOf(FileNotWritableException::class, $exception); self::assertSame( 'Could not move file "/tmp/a" to location "/tmp/b": either the source file is not readable,' . ' or the destination is not writable', @@ -31,7 +30,6 @@ public function testFromNotWritableDirectory() : void { $exception = FileNotWritableException::fromNotWritableDirectory('/tmp/a'); - self::assertInstanceOf(FileNotWritableException::class, $exception); self::assertSame( 'Could not create temp file in directory "/tmp/a" ' . 'either the directory does not exist, or it is not writable', diff --git a/tests/ProxyManagerTest/Factory/AbstractBaseFactoryTest.php b/tests/ProxyManagerTest/Factory/AbstractBaseFactoryTest.php index ff847c996..bc6211005 100644 --- a/tests/ProxyManagerTest/Factory/AbstractBaseFactoryTest.php +++ b/tests/ProxyManagerTest/Factory/AbstractBaseFactoryTest.php @@ -68,39 +68,33 @@ protected function setUp() : void $this->classSignatureGenerator = $this->createMock(ClassSignatureGeneratorInterface::class); $configuration - ->expects(self::any()) ->method('getClassNameInflector') - ->will(self::returnValue($this->classNameInflector)); + ->willReturn($this->classNameInflector); $configuration - ->expects(self::any()) ->method('getGeneratorStrategy') - ->will(self::returnValue($this->generatorStrategy)); + ->willReturn($this->generatorStrategy); $configuration - ->expects(self::any()) ->method('getProxyAutoloader') - ->will(self::returnValue($this->proxyAutoloader)); + ->willReturn($this->proxyAutoloader); $configuration - ->expects(self::any()) ->method('getSignatureChecker') - ->will(self::returnValue($this->signatureChecker)); + ->willReturn($this->signatureChecker); $configuration - ->expects(self::any()) ->method('getClassSignatureGenerator') - ->will(self::returnValue($this->classSignatureGenerator)); + ->willReturn($this->classSignatureGenerator); $this ->classNameInflector - ->expects(self::any()) ->method('getUserClassName') - ->will(self::returnValue('stdClass')); + ->willReturn('stdClass'); $this->factory = $this->getMockForAbstractClass(AbstractBaseFactory::class, [$configuration]); - $this->factory->expects(self::any())->method('getGenerator')->will(self::returnValue($this->generator)); + $this->factory->method('getGenerator')->willReturn($this->generator); } public function testGeneratesClass() : void @@ -112,10 +106,9 @@ public function testGeneratesClass() : void $this ->classNameInflector - ->expects(self::any()) ->method('getProxyClassName') ->with('stdClass') - ->will(self::returnValue($generatedClass)); + ->willReturn($generatedClass); $this ->generatorStrategy diff --git a/tests/ProxyManagerTest/Factory/AccessInterceptorScopeLocalizerFactoryTest.php b/tests/ProxyManagerTest/Factory/AccessInterceptorScopeLocalizerFactoryTest.php index db9160587..83e2763fd 100644 --- a/tests/ProxyManagerTest/Factory/AccessInterceptorScopeLocalizerFactoryTest.php +++ b/tests/ProxyManagerTest/Factory/AccessInterceptorScopeLocalizerFactoryTest.php @@ -51,21 +51,18 @@ protected function setUp() : void $this ->config - ->expects(self::any()) ->method('getClassNameInflector') - ->will(self::returnValue($this->inflector)); + ->willReturn($this->inflector); $this ->config - ->expects(self::any()) ->method('getSignatureChecker') - ->will(self::returnValue($this->signatureChecker)); + ->willReturn($this->signatureChecker); $this ->config - ->expects(self::any()) ->method('getClassSignatureGenerator') - ->will(self::returnValue($this->classSignatureGenerator)); + ->willReturn($this->classSignatureGenerator); } /** @@ -96,7 +93,7 @@ public function testWillSkipAutoGeneration() : void ->expects(self::once()) ->method('getProxyClassName') ->with('stdClass') - ->will(self::returnValue(AccessInterceptorValueHolderMock::class)); + ->willReturn(AccessInterceptorValueHolderMock::class); $factory = new AccessInterceptorScopeLocalizerFactory($this->config); $prefixInterceptors = [static function () : void { @@ -132,8 +129,8 @@ public function testWillTryAutoGeneration() : void $generator = $this->createMock(GeneratorStrategyInterface::class); $autoloader = $this->createMock(AutoloaderInterface::class); - $this->config->expects(self::any())->method('getGeneratorStrategy')->will(self::returnValue($generator)); - $this->config->expects(self::any())->method('getProxyAutoloader')->will(self::returnValue($autoloader)); + $this->config->method('getGeneratorStrategy')->willReturn($generator); + $this->config->method('getProxyAutoloader')->willReturn($autoloader); $generator ->expects(self::once()) @@ -165,14 +162,14 @@ static function (ClassGenerator $targetClass) use ($proxyClassName) : bool { ->expects(self::once()) ->method('getProxyClassName') ->with('stdClass') - ->will(self::returnValue($proxyClassName)); + ->willReturn($proxyClassName); $this ->inflector ->expects(self::once()) ->method('getUserClassName') ->with('stdClass') - ->will(self::returnValue(LazyLoadingMock::class)); + ->willReturn(LazyLoadingMock::class); $this->signatureChecker->expects(self::atLeastOnce())->method('checkSignature'); $this->classSignatureGenerator->expects(self::once())->method('addSignature')->will(self::returnArgument(0)); @@ -189,7 +186,9 @@ static function (ClassGenerator $targetClass) use ($proxyClassName) : bool { /** @var AccessInterceptorValueHolderMock $proxy */ $proxy = $factory->createProxy($instance, $prefixInterceptors, $suffixInterceptors); + /** @noinspection UnnecessaryAssertionInspection */ self::assertInstanceOf($proxyClassName, $proxy); + self::assertSame($instance, $proxy->instance); self::assertSame($prefixInterceptors, $proxy->prefixInterceptors); self::assertSame($suffixInterceptors, $proxy->suffixInterceptors); diff --git a/tests/ProxyManagerTest/Factory/AccessInterceptorValueHolderFactoryTest.php b/tests/ProxyManagerTest/Factory/AccessInterceptorValueHolderFactoryTest.php index 361e1b08b..59ed7279d 100644 --- a/tests/ProxyManagerTest/Factory/AccessInterceptorValueHolderFactoryTest.php +++ b/tests/ProxyManagerTest/Factory/AccessInterceptorValueHolderFactoryTest.php @@ -50,21 +50,18 @@ protected function setUp() : void $this ->config - ->expects(self::any()) ->method('getClassNameInflector') - ->will(self::returnValue($this->inflector)); + ->willReturn($this->inflector); $this ->config - ->expects(self::any()) ->method('getSignatureChecker') - ->will(self::returnValue($this->signatureChecker)); + ->willReturn($this->signatureChecker); $this ->config - ->expects(self::any()) ->method('getClassSignatureGenerator') - ->will(self::returnValue($this->classSignatureGenerator)); + ->willReturn($this->classSignatureGenerator); } /** @@ -95,7 +92,7 @@ public function testWillSkipAutoGeneration() : void ->expects(self::once()) ->method('getProxyClassName') ->with('stdClass') - ->will(self::returnValue(AccessInterceptorValueHolderMock::class)); + ->willReturn(AccessInterceptorValueHolderMock::class); $factory = new AccessInterceptorValueHolderFactory($this->config); $prefixInterceptors = [static function () : void { @@ -131,8 +128,8 @@ public function testWillTryAutoGeneration() : void $generator = $this->createMock(GeneratorStrategyInterface::class); $autoloader = $this->createMock(AutoloaderInterface::class); - $this->config->expects(self::any())->method('getGeneratorStrategy')->will(self::returnValue($generator)); - $this->config->expects(self::any())->method('getProxyAutoloader')->will(self::returnValue($autoloader)); + $this->config->method('getGeneratorStrategy')->will(self::returnValue($generator)); + $this->config->method('getProxyAutoloader')->will(self::returnValue($autoloader)); $generator ->expects(self::once()) @@ -164,14 +161,14 @@ static function (ClassGenerator $targetClass) use ($proxyClassName) : bool { ->expects(self::once()) ->method('getProxyClassName') ->with('stdClass') - ->will(self::returnValue($proxyClassName)); + ->willReturn($proxyClassName); $this ->inflector ->expects(self::once()) ->method('getUserClassName') ->with('stdClass') - ->will(self::returnValue(EmptyClass::class)); + ->willReturn(EmptyClass::class); $this->signatureChecker->expects(self::atLeastOnce())->method('checkSignature'); $this->classSignatureGenerator->expects(self::once())->method('addSignature')->will(self::returnArgument(0)); diff --git a/tests/ProxyManagerTest/Factory/LazyLoadingGhostFactoryTest.php b/tests/ProxyManagerTest/Factory/LazyLoadingGhostFactoryTest.php index 421b1afb6..354440bbd 100644 --- a/tests/ProxyManagerTest/Factory/LazyLoadingGhostFactoryTest.php +++ b/tests/ProxyManagerTest/Factory/LazyLoadingGhostFactoryTest.php @@ -48,21 +48,18 @@ protected function setUp() : void $this ->config - ->expects(self::any()) ->method('getClassNameInflector') - ->will(self::returnValue($this->inflector)); + ->willReturn($this->inflector); $this ->config - ->expects(self::any()) ->method('getSignatureChecker') - ->will(self::returnValue($this->signatureChecker)); + ->willReturn($this->signatureChecker); $this ->config - ->expects(self::any()) ->method('getClassSignatureGenerator') - ->will(self::returnValue($this->classSignatureGenerator)); + ->willReturn($this->classSignatureGenerator); } /** @@ -92,7 +89,7 @@ public function testWillSkipAutoGeneration() : void ->expects(self::once()) ->method('getProxyClassName') ->with($className) - ->will(self::returnValue(LazyLoadingMock::class)); + ->willReturn(LazyLoadingMock::class); $factory = new LazyLoadingGhostFactory($this->config); $initializer = static function () : void { @@ -120,8 +117,8 @@ public function testWillTryAutoGeneration() : void $generator = $this->createMock(GeneratorStrategyInterface::class); $autoloader = $this->createMock(AutoloaderInterface::class); - $this->config->expects(self::any())->method('getGeneratorStrategy')->will(self::returnValue($generator)); - $this->config->expects(self::any())->method('getProxyAutoloader')->will(self::returnValue($autoloader)); + $this->config->method('getGeneratorStrategy')->willReturn($generator); + $this->config->method('getProxyAutoloader')->willReturn($autoloader); $generator ->expects(self::once()) @@ -150,14 +147,14 @@ static function (ClassGenerator $targetClass) use ($proxyClassName) : bool { ->expects(self::once()) ->method('getProxyClassName') ->with($className) - ->will(self::returnValue($proxyClassName)); + ->willReturn($proxyClassName); $this ->inflector ->expects(self::once()) ->method('getUserClassName') ->with($className) - ->will(self::returnValue(LazyLoadingMock::class)); + ->willReturn(LazyLoadingMock::class); $this->signatureChecker->expects(self::atLeastOnce())->method('checkSignature'); $this->classSignatureGenerator->expects(self::once())->method('addSignature')->will(self::returnArgument(0)); @@ -168,7 +165,6 @@ static function (ClassGenerator $targetClass) use ($proxyClassName) : bool { /** @var LazyLoadingMock $proxy */ $proxy = $factory->createProxy($className, $initializer); - self::assertInstanceOf($proxyClassName, $proxy); self::assertSame($initializer, $proxy->initializer); } } diff --git a/tests/ProxyManagerTest/Factory/LazyLoadingValueHolderFactoryTest.php b/tests/ProxyManagerTest/Factory/LazyLoadingValueHolderFactoryTest.php index 2143325fe..68f30141d 100644 --- a/tests/ProxyManagerTest/Factory/LazyLoadingValueHolderFactoryTest.php +++ b/tests/ProxyManagerTest/Factory/LazyLoadingValueHolderFactoryTest.php @@ -50,21 +50,18 @@ protected function setUp() : void $this ->config - ->expects(self::any()) ->method('getClassNameInflector') - ->will(self::returnValue($this->inflector)); + ->willReturn($this->inflector); $this ->config - ->expects(self::any()) ->method('getSignatureChecker') - ->will(self::returnValue($this->signatureChecker)); + ->willReturn($this->signatureChecker); $this ->config - ->expects(self::any()) ->method('getClassSignatureGenerator') - ->will(self::returnValue($this->classSignatureGenerator)); + ->willReturn($this->classSignatureGenerator); } /** @@ -94,7 +91,7 @@ public function testWillSkipAutoGeneration() : void ->expects(self::once()) ->method('getProxyClassName') ->with($className) - ->will(self::returnValue(LazyLoadingMock::class)); + ->willReturn(LazyLoadingMock::class); $factory = new LazyLoadingValueHolderFactory($this->config); $initializer = static function () : void { @@ -122,8 +119,8 @@ public function testWillTryAutoGeneration() : void $generator = $this->createMock(GeneratorStrategyInterface::class); $autoloader = $this->createMock(AutoloaderInterface::class); - $this->config->expects(self::any())->method('getGeneratorStrategy')->will(self::returnValue($generator)); - $this->config->expects(self::any())->method('getProxyAutoloader')->will(self::returnValue($autoloader)); + $this->config->method('getGeneratorStrategy')->will(self::returnValue($generator)); + $this->config->method('getProxyAutoloader')->will(self::returnValue($autoloader)); $generator ->expects(self::once()) @@ -152,14 +149,14 @@ static function (ClassGenerator $targetClass) use ($proxyClassName) : bool { ->expects(self::once()) ->method('getProxyClassName') ->with($className) - ->will(self::returnValue($proxyClassName)); + ->willReturn($proxyClassName); $this ->inflector ->expects(self::once()) ->method('getUserClassName') ->with($className) - ->will(self::returnValue(EmptyClass::class)); + ->willReturn(EmptyClass::class); $this->signatureChecker->expects(self::atLeastOnce())->method('checkSignature'); $this->classSignatureGenerator->expects(self::once())->method('addSignature')->will(self::returnArgument(0)); @@ -170,7 +167,9 @@ static function (ClassGenerator $targetClass) use ($proxyClassName) : bool { /** @var LazyLoadingMock $proxy */ $proxy = $factory->createProxy($className, $initializer); + /** @noinspection UnnecessaryAssertionInspection */ self::assertInstanceOf($proxyClassName, $proxy); + self::assertSame($proxyClassName, get_class($proxy)); self::assertSame($initializer, $proxy->initializer); } diff --git a/tests/ProxyManagerTest/Factory/NullObjectFactoryTest.php b/tests/ProxyManagerTest/Factory/NullObjectFactoryTest.php index 080243ce7..5e88b15f7 100644 --- a/tests/ProxyManagerTest/Factory/NullObjectFactoryTest.php +++ b/tests/ProxyManagerTest/Factory/NullObjectFactoryTest.php @@ -49,21 +49,18 @@ protected function setUp() : void $this ->config - ->expects(self::any()) ->method('getClassNameInflector') - ->will(self::returnValue($this->inflector)); + ->willReturn($this->inflector); $this ->config - ->expects(self::any()) ->method('getSignatureChecker') - ->will(self::returnValue($this->signatureChecker)); + ->willReturn($this->signatureChecker); $this ->config - ->expects(self::any()) ->method('getClassSignatureGenerator') - ->will(self::returnValue($this->classSignatureGenerator)); + ->willReturn($this->classSignatureGenerator); } /** @@ -82,7 +79,7 @@ public function testWillSkipAutoGeneration() : void ->expects(self::once()) ->method('getProxyClassName') ->with('stdClass') - ->will(self::returnValue(NullObjectMock::class)); + ->willReturn(NullObjectMock::class); $factory = new NullObjectFactory($this->config); /** @var NullObjectMock $proxy */ @@ -107,8 +104,8 @@ public function testWillTryAutoGeneration() : void $generator = $this->createMock(GeneratorStrategyInterface::class); $autoloader = $this->createMock(AutoloaderInterface::class); - $this->config->expects(self::any())->method('getGeneratorStrategy')->will(self::returnValue($generator)); - $this->config->expects(self::any())->method('getProxyAutoloader')->will(self::returnValue($autoloader)); + $this->config->method('getGeneratorStrategy')->will(self::returnValue($generator)); + $this->config->method('getProxyAutoloader')->will(self::returnValue($autoloader)); $generator ->expects(self::once()) @@ -137,22 +134,19 @@ static function (ClassGenerator $targetClass) use ($proxyClassName) : bool { ->expects(self::once()) ->method('getProxyClassName') ->with('stdClass') - ->will(self::returnValue($proxyClassName)); + ->willReturn($proxyClassName); $this ->inflector ->expects(self::once()) ->method('getUserClassName') ->with('stdClass') - ->will(self::returnValue(NullObjectMock::class)); + ->willReturn(NullObjectMock::class); $this->signatureChecker->expects(self::atLeastOnce())->method('checkSignature'); $this->classSignatureGenerator->expects(self::once())->method('addSignature')->will(self::returnArgument(0)); $factory = new NullObjectFactory($this->config); - /** @var NullObjectMock $proxy */ - $proxy = $factory->createProxy($instance); - - self::assertInstanceOf($proxyClassName, $proxy); + $factory->createProxy($instance); } } diff --git a/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/BaseAdapterTest.php b/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/BaseAdapterTest.php index 93e290387..25dce2d71 100644 --- a/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/BaseAdapterTest.php +++ b/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/BaseAdapterTest.php @@ -40,13 +40,13 @@ public function testBaseAdapter() : void ->expects(self::once()) ->method('call') ->with('foobarbaz', ['tab' => 'taz']) - ->will(self::returnValue('baz')); + ->willReturn('baz'); $adapter ->expects(self::once()) ->method('getServiceName') ->with('foo', 'bar') - ->will(self::returnValue('foobarbaz')); + ->willReturn('foobarbaz'); self::assertSame('baz', $adapter->call('foo', 'bar', ['tab' => 'taz'])); } @@ -75,13 +75,13 @@ public function testBaseAdapterWithServiceMap() : void ->expects(self::once()) ->method('call') ->with('mapped', ['tab' => 'taz']) - ->will(self::returnValue('baz')); + ->willReturn('baz'); $adapter ->expects(self::once()) ->method('getServiceName') ->with('foo', 'bar') - ->will(self::returnValue('foobarbaz')); + ->willReturn('foobarbaz'); self::assertSame('baz', $adapter->call('foo', 'bar', ['tab' => 'taz'])); } diff --git a/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/JsonRpcTest.php b/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/JsonRpcTest.php index a248bfcbc..c46e6a12e 100644 --- a/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/JsonRpcTest.php +++ b/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/JsonRpcTest.php @@ -33,7 +33,7 @@ public function testCanBuildAdapterWithJsonRpcClient() : void ->expects(self::once()) ->method('call') ->with('foo.bar', ['tab' => 'taz']) - ->will(self::returnValue('baz')); + ->willReturn('baz'); self::assertSame('baz', $adapter->call('foo', 'bar', ['tab' => 'taz'])); } diff --git a/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/SoapTest.php b/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/SoapTest.php index ce8dca229..998d5cdcd 100644 --- a/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/SoapTest.php +++ b/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/SoapTest.php @@ -33,7 +33,7 @@ public function testCanBuildAdapterWithSoapRpcClient() : void ->expects(self::once()) ->method('call') ->with('bar', ['tab' => 'taz']) - ->will(self::returnValue('baz')); + ->willReturn('baz'); self::assertSame('baz', $adapter->call('foo', 'bar', ['tab' => 'taz'])); } diff --git a/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/XmlRpcTest.php b/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/XmlRpcTest.php index 2f10714b4..43e174323 100644 --- a/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/XmlRpcTest.php +++ b/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/XmlRpcTest.php @@ -33,7 +33,7 @@ public function testCanBuildAdapterWithXmlRpcClient() : void ->expects(self::once()) ->method('call') ->with('foo.bar', ['tab' => 'taz']) - ->will(self::returnValue('baz')); + ->willReturn('baz'); self::assertSame('baz', $adapter->call('foo', 'bar', ['tab' => 'taz'])); } diff --git a/tests/ProxyManagerTest/Factory/RemoteObjectFactoryTest.php b/tests/ProxyManagerTest/Factory/RemoteObjectFactoryTest.php index ea9d29606..9c1adb406 100644 --- a/tests/ProxyManagerTest/Factory/RemoteObjectFactoryTest.php +++ b/tests/ProxyManagerTest/Factory/RemoteObjectFactoryTest.php @@ -51,21 +51,18 @@ protected function setUp() : void $this ->config - ->expects(self::any()) ->method('getClassNameInflector') - ->will(self::returnValue($this->inflector)); + ->willReturn($this->inflector); $this ->config - ->expects(self::any()) ->method('getSignatureChecker') - ->will(self::returnValue($this->signatureChecker)); + ->willReturn($this->signatureChecker); $this ->config - ->expects(self::any()) ->method('getClassSignatureGenerator') - ->will(self::returnValue($this->classSignatureGenerator)); + ->willReturn($this->classSignatureGenerator); } /** @@ -82,7 +79,7 @@ public function testWillSkipAutoGeneration() : void ->expects(self::once()) ->method('getProxyClassName') ->with(BaseInterface::class) - ->will(self::returnValue(RemoteObjectMock::class)); + ->willReturn(RemoteObjectMock::class); /** @var AdapterInterface|MockObject $adapter */ $adapter = $this->createMock(AdapterInterface::class); @@ -108,8 +105,8 @@ public function testWillTryAutoGeneration() : void $generator = $this->createMock(GeneratorStrategyInterface::class); $autoloader = $this->createMock(AutoloaderInterface::class); - $this->config->expects(self::any())->method('getGeneratorStrategy')->will(self::returnValue($generator)); - $this->config->expects(self::any())->method('getProxyAutoloader')->will(self::returnValue($autoloader)); + $this->config->method('getGeneratorStrategy')->willReturn($generator); + $this->config->method('getProxyAutoloader')->willReturn($autoloader); $generator ->expects(self::once()) @@ -142,14 +139,14 @@ static function (ClassGenerator $targetClass) use ($proxyClassName) : bool { ->expects(self::once()) ->method('getProxyClassName') ->with(BaseInterface::class) - ->will(self::returnValue($proxyClassName)); + ->willReturn($proxyClassName); $this ->inflector ->expects(self::once()) ->method('getUserClassName') ->with(BaseInterface::class) - ->will(self::returnValue('stdClass')); + ->willReturn('stdClass'); $this->signatureChecker->expects(self::atLeastOnce())->method('checkSignature'); $this->classSignatureGenerator->expects(self::once())->method('addSignature')->will(self::returnArgument(0)); @@ -157,8 +154,6 @@ static function (ClassGenerator $targetClass) use ($proxyClassName) : bool { /** @var AdapterInterface $adapter */ $adapter = $this->createMock(AdapterInterface::class); $factory = new RemoteObjectFactory($adapter, $this->config); - $proxy = $factory->createProxy(BaseInterface::class); - - self::assertInstanceOf($proxyClassName, $proxy); + $factory->createProxy(BaseInterface::class); } } diff --git a/tests/ProxyManagerTest/Functional/AccessInterceptorScopeLocalizerFunctionalTest.php b/tests/ProxyManagerTest/Functional/AccessInterceptorScopeLocalizerFunctionalTest.php index 01f5de426..ff6a64c8d 100644 --- a/tests/ProxyManagerTest/Functional/AccessInterceptorScopeLocalizerFunctionalTest.php +++ b/tests/ProxyManagerTest/Functional/AccessInterceptorScopeLocalizerFunctionalTest.php @@ -62,7 +62,7 @@ public function testMethodCalls(string $className, object $instance, string $met $callback = [$proxy, $method]; - self::assertInternalType('callable', $callback); + self::assertIsCallable($callback); self::assertSame($expectedValue, $callback(...array_values($params))); /** @var callable|MockObject $listener */ @@ -116,7 +116,7 @@ public function testMethodCallsWithSuffixListener( $proxy = $proxyName::staticProxyConstructor($instance); $callback = [$proxy, $method]; - self::assertInternalType('callable', $callback); + self::assertIsCallable($callback); /** @var callable|MockObject $listener */ $listener = $this->getMockBuilder(stdClass::class)->setMethods(['__invoke'])->getMock(); @@ -169,7 +169,7 @@ public function testMethodCallsAfterUnSerialization( $callback = [$proxy, $method]; - self::assertInternalType('callable', $callback); + self::assertIsCallable($callback); self::assertSame($expectedValue, $callback(...array_values($params))); $this->assertProxySynchronized($instance, $proxy); } @@ -195,7 +195,7 @@ public function testMethodCallsAfterCloning( $callback = [$cloned, $method]; $this->assertProxySynchronized($instance, $proxy); - self::assertInternalType('callable', $callback); + self::assertIsCallable($callback); self::assertSame($expectedValue, $callback(...array_values($params))); $this->assertProxySynchronized($instance, $proxy); } @@ -221,7 +221,7 @@ public function testPropertyReadAccess( public function testPropertyWriteAccess(object $instance, AccessInterceptorInterface $proxy, string $publicProperty ) : void { - $newValue = uniqid(); + $newValue = uniqid('value', true); $proxy->$publicProperty = $newValue; self::assertSame($newValue, $proxy->$publicProperty); @@ -385,7 +385,7 @@ private function generateProxy(string $parentClassName) : string * * @return string[][]|object[][]|mixed[][][] */ - public function getProxyMethods() : array + public static function getProxyMethods() : array { $selfHintParam = new ClassWithSelfHint(); $empty = new EmptyClass(); diff --git a/tests/ProxyManagerTest/Functional/AccessInterceptorValueHolderFunctionalTest.php b/tests/ProxyManagerTest/Functional/AccessInterceptorValueHolderFunctionalTest.php index 21c6c1c82..e9ec0be38 100644 --- a/tests/ProxyManagerTest/Functional/AccessInterceptorValueHolderFunctionalTest.php +++ b/tests/ProxyManagerTest/Functional/AccessInterceptorValueHolderFunctionalTest.php @@ -59,7 +59,7 @@ public function testMethodCalls(string $className, object $instance, string $met $proxy = $proxyName::staticProxyConstructor($instance); $callback = [$proxy, $method]; - self::assertInternalType('callable', $callback); + self::assertIsCallable($callback); self::assertSame($instance, $proxy->getWrappedValueHolderValue()); self::assertSame($expectedValue, $callback(...array_values($params))); @@ -112,7 +112,7 @@ public function testMethodCallsWithSuffixListener( $proxy = $proxyName::staticProxyConstructor($instance); $callback = [$proxy, $method]; - self::assertInternalType('callable', $callback); + self::assertIsCallable($callback); /** @var callable|MockObject $listener */ $listener = $this->getMockBuilder(stdClass::class)->setMethods(['__invoke'])->getMock(); @@ -162,7 +162,7 @@ public function testMethodCallsAfterUnSerialization( $proxy = unserialize(serialize($proxyName::staticProxyConstructor($instance))); $callback = [$proxy, $method]; - self::assertInternalType('callable', $callback); + self::assertIsCallable($callback); self::assertSame($expectedValue, $callback(...array_values($params))); self::assertEquals($instance, $proxy->getWrappedValueHolderValue()); } @@ -187,7 +187,7 @@ public function testMethodCallsAfterCloning( $cloned = clone $proxy; $callback = [$cloned, $method]; - self::assertInternalType('callable', $callback); + self::assertIsCallable($callback); self::assertNotSame($proxy->getWrappedValueHolderValue(), $cloned->getWrappedValueHolderValue()); self::assertSame($expectedValue, $callback(...array_values($params))); self::assertEquals($instance, $cloned->getWrappedValueHolderValue()); @@ -698,6 +698,7 @@ public function testWillInterceptAndReturnEarlyOnVoidMethod() : void return; } + /** @noinspection IncrementDecrementOperationEquivalentInspection */ $instance->counter += 1; }, ] diff --git a/tests/ProxyManagerTest/Functional/FatalPreventionFunctionalTest.php b/tests/ProxyManagerTest/Functional/FatalPreventionFunctionalTest.php index 3e242530c..4e529d80b 100644 --- a/tests/ProxyManagerTest/Functional/FatalPreventionFunctionalTest.php +++ b/tests/ProxyManagerTest/Functional/FatalPreventionFunctionalTest.php @@ -47,7 +47,7 @@ class FatalPreventionFunctionalTest extends TestCase */ public function testCodeGeneration(string $generatorClass, string $className) : void { - $generatedClass = new ClassGenerator(uniqid('generated')); + $generatedClass = new ClassGenerator(uniqid('generated', true)); $generatorStrategy = new EvaluatingGeneratorStrategy(); /** @var ProxyGeneratorInterface $classGenerator */ $classGenerator = new $generatorClass(); @@ -125,10 +125,10 @@ static function ($className) use ($skippedPaths) : bool { $realPath = realpath($fileName); - self::assertInternalType('string', $realPath); + self::assertIsString($realPath); foreach ($skippedPaths as $skippedPath) { - self::assertInternalType('string', $skippedPath); + self::assertIsString($skippedPath); if (strpos($realPath, $skippedPath) === 0) { // skip classes defined within ProxyManager, vendor or the test suite diff --git a/tests/ProxyManagerTest/Functional/LazyLoadingGhostFunctionalTest.php b/tests/ProxyManagerTest/Functional/LazyLoadingGhostFunctionalTest.php index cb03a537a..f2d56f5f0 100644 --- a/tests/ProxyManagerTest/Functional/LazyLoadingGhostFunctionalTest.php +++ b/tests/ProxyManagerTest/Functional/LazyLoadingGhostFunctionalTest.php @@ -79,7 +79,7 @@ public function testMethodCallsThatLazyLoadTheObject( $callProxyMethod = [$proxy, $method]; $parameterValues = array_values($params); - self::assertInternalType('callable', $callProxyMethod); + self::assertIsCallable($callProxyMethod); self::assertSame($expectedValue, $callProxyMethod(...$parameterValues)); self::assertTrue($proxy->isProxyInitialized()); } @@ -113,7 +113,7 @@ public function testMethodCallsThatDoNotLazyLoadTheObject( $callProxyMethod = [$proxy, $method]; $parameterValues = array_values($params); - self::assertInternalType('callable', $callProxyMethod); + self::assertIsCallable($callProxyMethod); self::assertSame($expectedValue, $callProxyMethod(...$parameterValues)); self::assertFalse($proxy->isProxyInitialized()); } @@ -144,7 +144,7 @@ public function testMethodCallsAfterUnSerialization( $callProxyMethod = [$proxy, $method]; $parameterValues = array_values($params); - self::assertInternalType('callable', $callProxyMethod); + self::assertIsCallable($callProxyMethod); self::assertSame($expectedValue, $callProxyMethod(...$parameterValues)); } @@ -173,7 +173,7 @@ public function testMethodCallsAfterCloning( $callProxyMethod = [$proxy, $method]; $parameterValues = array_values($params); - self::assertInternalType('callable', $callProxyMethod); + self::assertIsCallable($callProxyMethod); self::assertSame($expectedValue, $callProxyMethod(...$parameterValues)); } @@ -748,7 +748,7 @@ private function createInitializer(string $className, object $realInstance, ?Moc )); } - self::assertInternalType('callable', $initializerMatcher); + self::assertIsCallable($initializerMatcher); return static function ( GhostObjectInterface $proxy, @@ -1102,7 +1102,7 @@ static function ($proxy, $method, $params, & $initializer, array $props) use ($p $accessor = [$callerObject, $method]; - self::assertInternalType('callable', $accessor); + self::assertIsCallable($accessor); self::assertFalse($proxy->isProxyInitialized()); self::assertSame($expectedValue, $accessor($proxy)); @@ -1134,7 +1134,7 @@ static function ($proxy, $method, $params, & $initializer, array $props) use ($p $accessor = [$callerObject, $method]; - self::assertInternalType('callable', $accessor); + self::assertIsCallable($accessor); self::assertTrue($proxy->isProxyInitialized()); self::assertSame($expectedValue, $accessor($proxy)); @@ -1165,7 +1165,7 @@ static function ($proxy, $method, $params, & $initializer, array $props) use ($p $accessor = [$callerObject, $method]; - self::assertInternalType('callable', $accessor); + self::assertIsCallable($accessor); self::assertTrue($proxy->isProxyInitialized()); self::assertSame($expectedValue, $accessor($proxy)); diff --git a/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php b/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php index 4219074a7..d324cfa07 100644 --- a/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php +++ b/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php @@ -97,7 +97,7 @@ public function testMethodCallsAfterUnSerialization( $callProxyMethod = [$proxy, $method]; $parameterValues = array_values($params); - self::assertInternalType('callable', $callProxyMethod); + self::assertIsCallable($callProxyMethod); self::assertSame($expectedValue, $callProxyMethod(...$parameterValues)); self::assertEquals($instance, $proxy->getWrappedValueHolderValue()); @@ -129,7 +129,7 @@ public function testMethodCallsAfterCloning( $callProxyMethod = [$cloned, $method]; $parameterValues = array_values($params); - self::assertInternalType('callable', $callProxyMethod); + self::assertIsCallable($callProxyMethod); self::assertSame($expectedValue, $callProxyMethod(...$parameterValues)); self::assertEquals($instance, $cloned->getWrappedValueHolderValue()); @@ -385,7 +385,7 @@ private function createInitializer(string $className, object $realInstance, ?Moc ); } - self::assertInternalType('callable', $initializerMatcher); + self::assertIsCallable($initializerMatcher); return static function ( & $wrappedObject, @@ -557,7 +557,7 @@ public function testWillLazyLoadMembersOfOtherProxiesWithTheSamePrivateScope( $accessor = [$callerObject, $method]; - self::assertInternalType('callable', $accessor); + self::assertIsCallable($accessor); self::assertFalse($proxy->isProxyInitialized()); self::assertSame($expectedValue, $accessor($proxy)); self::assertTrue($proxy->isProxyInitialized()); diff --git a/tests/ProxyManagerTest/Functional/NullObjectFunctionalTest.php b/tests/ProxyManagerTest/Functional/NullObjectFunctionalTest.php index cf0a80cf5..9cf10c140 100644 --- a/tests/ProxyManagerTest/Functional/NullObjectFunctionalTest.php +++ b/tests/ProxyManagerTest/Functional/NullObjectFunctionalTest.php @@ -231,7 +231,7 @@ private function assertNullMethodCall(NullObjectInterface $proxy, string $method /** @var callable $method */ $method = [$proxy, $methodName]; - self::assertInternalType('callable', $method); + self::assertIsCallable($method); $parameterValues = array_values($parameters); diff --git a/tests/ProxyManagerTest/Functional/RemoteObjectFunctionalTest.php b/tests/ProxyManagerTest/Functional/RemoteObjectFunctionalTest.php index de4fdb7ef..2b3e4eb83 100644 --- a/tests/ProxyManagerTest/Functional/RemoteObjectFunctionalTest.php +++ b/tests/ProxyManagerTest/Functional/RemoteObjectFunctionalTest.php @@ -47,10 +47,9 @@ protected function getXmlRpcAdapter($expectedValue, string $method, array $param $client = $this->getMockBuilder(Client::class)->setMethods(['call'])->getMock(); $client - ->expects(self::any()) ->method('call') ->with(self::stringEndsWith($method), $params) - ->will(self::returnValue($expectedValue)); + ->willReturn($expectedValue); return new XmlRpcAdapter( $client, @@ -68,10 +67,9 @@ protected function getJsonRpcAdapter($expectedValue, string $method, array $para $client = $this->getMockBuilder(Client::class)->setMethods(['call'])->getMock(); $client - ->expects(self::any()) ->method('call') ->with(self::stringEndsWith($method), $params) - ->will(self::returnValue($expectedValue)); + ->willReturn($expectedValue); return new JsonRpcAdapter( $client, @@ -94,7 +92,7 @@ public function testXmlRpcMethodCalls($instanceOrClassName, string $method, arra $proxy = $proxyName::staticProxyConstructor($this->getXmlRpcAdapter($expectedValue, $method, $params)); $callback = [$proxy, $method]; - self::assertInternalType('callable', $callback); + self::assertIsCallable($callback); self::assertSame($expectedValue, $callback(...$params)); } @@ -113,7 +111,7 @@ public function testJsonRpcMethodCalls($instanceOrClassName, string $method, arr $proxy = $proxyName::staticProxyConstructor($this->getJsonRpcAdapter($expectedValue, $method, $params)); $callback = [$proxy, $method]; - self::assertInternalType('callable', $callback); + self::assertIsCallable($callback); self::assertSame($expectedValue, $callback(...$params)); } diff --git a/tests/ProxyManagerTest/Generator/MethodGeneratorTest.php b/tests/ProxyManagerTest/Generator/MethodGeneratorTest.php index 0745f7390..9574f56fe 100644 --- a/tests/ProxyManagerTest/Generator/MethodGeneratorTest.php +++ b/tests/ProxyManagerTest/Generator/MethodGeneratorTest.php @@ -162,7 +162,7 @@ public function testReturnTypeHintGeneration(string $methodName, string $expecte /** * @return string[][] */ - public function returnTypeHintsProvider() : array + public static function returnTypeHintsProvider() : array { return [ ['returnString', 'string'], diff --git a/tests/ProxyManagerTest/Generator/Util/IdentifierSuffixerTest.php b/tests/ProxyManagerTest/Generator/Util/IdentifierSuffixerTest.php index b316ae36c..fb44527cf 100644 --- a/tests/ProxyManagerTest/Generator/Util/IdentifierSuffixerTest.php +++ b/tests/ProxyManagerTest/Generator/Util/IdentifierSuffixerTest.php @@ -56,7 +56,7 @@ public function testGeneratesValidIdentifiers(string $name) : void /** * @dataProvider getBaseIdentifierNames */ - public function testGeneratedIdentifierSuffix(string $name) : void + public static function testGeneratedIdentifierSuffix(string $name) : void { // 5 generated characters are enough to keep idiots from tampering with these properties "the easy way" self::assertGreaterThan(5, strlen(IdentifierSuffixer::getIdentifier($name))); @@ -67,7 +67,7 @@ public function testGeneratedIdentifierSuffix(string $name) : void * * @return string[][] */ - public function getBaseIdentifierNames() : array + public static function getBaseIdentifierNames() : array { return [ [''], diff --git a/tests/ProxyManagerTest/Generator/Util/UniqueIdentifierGeneratorTest.php b/tests/ProxyManagerTest/Generator/Util/UniqueIdentifierGeneratorTest.php index 36b9fcd30..f897bddb4 100644 --- a/tests/ProxyManagerTest/Generator/Util/UniqueIdentifierGeneratorTest.php +++ b/tests/ProxyManagerTest/Generator/Util/UniqueIdentifierGeneratorTest.php @@ -51,7 +51,7 @@ public function testGeneratedIdentifierEntropy(string $name) : void * * @return string[][] */ - public function getBaseIdentifierNames() : array + public static function getBaseIdentifierNames() : array { return [ [''], diff --git a/tests/ProxyManagerTest/GeneratorStrategy/FileWriterGeneratorStrategyTest.php b/tests/ProxyManagerTest/GeneratorStrategy/FileWriterGeneratorStrategyTest.php index 23ea661cf..00cb3edc1 100644 --- a/tests/ProxyManagerTest/GeneratorStrategy/FileWriterGeneratorStrategyTest.php +++ b/tests/ProxyManagerTest/GeneratorStrategy/FileWriterGeneratorStrategyTest.php @@ -12,6 +12,7 @@ use ProxyManager\Generator\Util\UniqueIdentifierGenerator; use ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy; use const PATH_SEPARATOR; +use const SCANDIR_SORT_ASCENDING; use function class_exists; use function clearstatcache; use function decoct; @@ -62,7 +63,6 @@ public function testGenerate() : void $fqcn = $namespace . '\\' . $className; $locator - ->expects(self::any()) ->method('getProxyFileName') ->with($fqcn) ->will(self::returnValue($tmpFile)); @@ -103,10 +103,9 @@ public function testGenerateWillFailIfTmpFileCannotBeWrittenToDisk() : void $fqcn = $namespace . '\\' . $className; $locator - ->expects(self::any()) ->method('getProxyFileName') ->with($fqcn) - ->will(self::returnValue($tmpFile)); + ->willReturn($tmpFile); $this->expectException(FileNotWritableException::class); $generator->generate(new ClassGenerator($fqcn)); @@ -123,10 +122,9 @@ public function testGenerateWillFailIfTmpFileCannotBeMovedToFinalDestination() : $fqcn = $namespace . '\\' . $className; $locator - ->expects(self::any()) ->method('getProxyFileName') ->with($fqcn) - ->will(self::returnValue($tmpFile)); + ->willReturn($tmpFile); mkdir($tmpFile); @@ -149,10 +147,9 @@ public function testWhenFailingAllTemporaryFilesAreRemoved() : void $fqcn = $namespace . '\\' . $className; $locator - ->expects(self::any()) ->method('getProxyFileName') ->with($fqcn) - ->will(self::returnValue($tmpFile)); + ->willReturn($tmpFile); mkdir($tmpFile); @@ -163,7 +160,7 @@ public function testWhenFailingAllTemporaryFilesAreRemoved() : void } catch (FileNotWritableException $exception) { rmdir($tmpFile); - self::assertEquals(['.', '..'], scandir($tmpDirPath)); + self::assertEquals(['.', '..'], scandir($tmpDirPath, SCANDIR_SORT_ASCENDING)); } } } diff --git a/tests/ProxyManagerTest/Inflector/ClassNameInflectorTest.php b/tests/ProxyManagerTest/Inflector/ClassNameInflectorTest.php index c0eee4c4f..57a08ebe8 100644 --- a/tests/ProxyManagerTest/Inflector/ClassNameInflectorTest.php +++ b/tests/ProxyManagerTest/Inflector/ClassNameInflectorTest.php @@ -97,7 +97,7 @@ public function testClassNameIsValidClassIdentifier(string $className, array $pa * * @return string[][] */ - public function getClassNames() : array + public static function getClassNames() : array { return [ ['Foo', 'ProxyNS\\' . ClassNameInflectorInterface::PROXY_MARKER . '\\Foo\\%s'], @@ -110,7 +110,7 @@ public function getClassNames() : array * * @return mixed[][] */ - public function getClassAndParametersCombinations() : array + public static function getClassAndParametersCombinations() : array { return [ ['Foo', []], diff --git a/tests/ProxyManagerTest/Inflector/Util/ParameterEncoderTest.php b/tests/ProxyManagerTest/Inflector/Util/ParameterEncoderTest.php index f3ea340eb..cd65163b7 100644 --- a/tests/ProxyManagerTest/Inflector/Util/ParameterEncoderTest.php +++ b/tests/ProxyManagerTest/Inflector/Util/ParameterEncoderTest.php @@ -32,7 +32,7 @@ public function testGeneratesValidClassName(array $parameters) : void } /** @return mixed[][] */ - public function getParameters() : array + public static function getParameters() : array { return [ [[]], diff --git a/tests/ProxyManagerTest/Inflector/Util/ParameterHasherTest.php b/tests/ProxyManagerTest/Inflector/Util/ParameterHasherTest.php index e29720443..4f40ddfb7 100644 --- a/tests/ProxyManagerTest/Inflector/Util/ParameterHasherTest.php +++ b/tests/ProxyManagerTest/Inflector/Util/ParameterHasherTest.php @@ -28,7 +28,7 @@ public function testGeneratesValidClassName(array $parameters, string $expectedH } /** @return mixed[][][]|string[][] */ - public function getParameters() : array + public static function getParameters() : array { return [ [[], '40cd750bba9870f18aada2478b24840a'], diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodPrefixInterceptorTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodPrefixInterceptorTest.php index 4169666f3..8884d2d49 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodPrefixInterceptorTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodPrefixInterceptorTest.php @@ -25,7 +25,7 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $suffix */ $suffix = $this->createMock(PropertyGenerator::class); - $suffix->expects(self::once())->method('getName')->will(self::returnValue('foo')); + $suffix->expects(self::once())->method('getName')->willReturn('foo'); $setter = new SetMethodPrefixInterceptor($suffix); diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodSuffixInterceptorTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodSuffixInterceptorTest.php index 7a4fe560c..330401d0f 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodSuffixInterceptorTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodSuffixInterceptorTest.php @@ -25,7 +25,7 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $suffix */ $suffix = $this->createMock(PropertyGenerator::class); - $suffix->expects(self::once())->method('getName')->will(self::returnValue('foo')); + $suffix->expects(self::once())->method('getName')->willReturn('foo'); $setter = new SetMethodSuffixInterceptor($suffix); diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/BindProxyPropertiesTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/BindProxyPropertiesTest.php index b2beb202a..438440bc8 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/BindProxyPropertiesTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/BindProxyPropertiesTest.php @@ -36,8 +36,8 @@ protected function setUp() : void $this->prefixInterceptors = $this->createMock(PropertyGenerator::class); $this->suffixInterceptors = $this->createMock(PropertyGenerator::class); - $this->prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $this->suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $this->prefixInterceptors->method('getName')->willReturn('pre'); + $this->suffixInterceptors->method('getName')->willReturn('post'); } public function testSignature() : void diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/InterceptedMethodTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/InterceptedMethodTest.php index d302dc0be..e9025f277 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/InterceptedMethodTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/InterceptedMethodTest.php @@ -37,8 +37,8 @@ protected function setUp() : void $this->prefixInterceptors = $this->createMock(PropertyGenerator::class); $this->suffixInterceptors = $this->createMock(PropertyGenerator::class); - $this->prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $this->suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $this->prefixInterceptors->method('getName')->willReturn('pre'); + $this->suffixInterceptors->method('getName')->willReturn('post'); } public function testBodyStructure() : void diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicCloneTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicCloneTest.php index bc7e83db8..e1b274978 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicCloneTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicCloneTest.php @@ -30,8 +30,8 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); $magicClone = new MagicClone($reflection, $prefixInterceptors, $suffixInterceptors); @@ -51,8 +51,8 @@ public function testBodyStructureWithInheritedMethod() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); $magicClone = new MagicClone($reflection, $prefixInterceptors, $suffixInterceptors); diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicGetTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicGetTest.php index a7ab315c3..b8760d752 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicGetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicGetTest.php @@ -30,8 +30,8 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); $magicGet = new MagicGet( $reflection, @@ -55,8 +55,8 @@ public function testBodyStructureWithInheritedMethod() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); $magicGet = new MagicGet( $reflection, diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicIssetTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicIssetTest.php index 47209dfc9..76ae18678 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicIssetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicIssetTest.php @@ -30,8 +30,8 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); $magicIsset = new MagicIsset( $reflection, @@ -55,8 +55,8 @@ public function testBodyStructureWithInheritedMethod() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); $magicIsset = new MagicIsset( $reflection, diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSetTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSetTest.php index 4e71bed11..a4f2ca74d 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSetTest.php @@ -30,8 +30,8 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); $magicGet = new MagicSet( $reflection, @@ -55,8 +55,8 @@ public function testBodyStructureWithInheritedMethod() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); $magicGet = new MagicSet( $reflection, diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSleepTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSleepTest.php index 290296430..8c2979c68 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSleepTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSleepTest.php @@ -30,8 +30,8 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); $magicGet = new MagicSleep( $reflection, @@ -55,8 +55,8 @@ public function testBodyStructureWithInheritedMethod() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); $magicGet = new MagicSleep( $reflection, diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicUnsetTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicUnsetTest.php index 3add7dde2..e231dfa31 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicUnsetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicUnsetTest.php @@ -30,8 +30,8 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); $magicGet = new MagicUnset( $reflection, @@ -55,8 +55,8 @@ public function testBodyStructureWithInheritedMethod() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); $magicGet = new MagicUnset( $reflection, diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/StaticProxyConstructorTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/StaticProxyConstructorTest.php index d6c84834b..bb9331b2f 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/StaticProxyConstructorTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/StaticProxyConstructorTest.php @@ -34,8 +34,8 @@ protected function setUp() : void $this->prefixInterceptors = $this->createMock(PropertyGenerator::class); $this->suffixInterceptors = $this->createMock(PropertyGenerator::class); - $this->prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $this->suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $this->prefixInterceptors->method('getName')->willReturn('pre'); + $this->suffixInterceptors->method('getName')->willReturn('post'); } public function testSignature() : void diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Util/InterceptorGeneratorTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Util/InterceptorGeneratorTest.php index ec539c3f0..e1d003b84 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Util/InterceptorGeneratorTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Util/InterceptorGeneratorTest.php @@ -35,12 +35,12 @@ public function testInterceptorGenerator() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $bar->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $baz->expects(self::any())->method('getName')->will(self::returnValue('baz')); - $method->expects(self::any())->method('getName')->will(self::returnValue('fooMethod')); - $method->expects(self::any())->method('getParameters')->will(self::returnValue([$bar, $baz])); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $bar->method('getName')->willReturn('bar'); + $baz->method('getName')->willReturn('baz'); + $method->method('getName')->willReturn('fooMethod'); + $method->method('getParameters')->will(self::returnValue([$bar, $baz])); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); // @codingStandardsIgnoreStart $expected = <<<'PHP' @@ -93,12 +93,12 @@ public function testInterceptorGeneratorWithVoidReturnType() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $bar->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $baz->expects(self::any())->method('getName')->will(self::returnValue('baz')); - $method->expects(self::any())->method('getName')->will(self::returnValue('fooMethod')); - $method->expects(self::any())->method('getParameters')->will(self::returnValue([$bar, $baz])); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $bar->method('getName')->willReturn('bar'); + $baz->method('getName')->willReturn('baz'); + $method->method('getName')->willReturn('fooMethod'); + $method->method('getParameters')->will(self::returnValue([$bar, $baz])); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); // @codingStandardsIgnoreStart $expected = <<<'PHP' @@ -154,12 +154,12 @@ public function testInterceptorGeneratorWithExistingNonVoidMethod() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $bar->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $baz->expects(self::any())->method('getName')->will(self::returnValue('baz')); - $method->expects(self::any())->method('getName')->will(self::returnValue('fooMethod')); - $method->expects(self::any())->method('getParameters')->will(self::returnValue([$bar, $baz])); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $bar->method('getName')->willReturn('bar'); + $baz->method('getName')->willReturn('baz'); + $method->method('getName')->willReturn('fooMethod'); + $method->method('getParameters')->will(self::returnValue([$bar, $baz])); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); // @codingStandardsIgnoreStart $expected = <<<'PHP' diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/InterceptedMethodTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/InterceptedMethodTest.php index 0a8c8bf6e..f0dba7b12 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/InterceptedMethodTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/InterceptedMethodTest.php @@ -30,9 +30,9 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $valueHolder->method('getName')->willReturn('foo'); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); $method = InterceptedMethod::generateMethod( new MethodReflection(BaseClass::class, 'publicByReferenceParameterMethod'), diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicCloneTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicCloneTest.php index 07b2ab53c..017660c7d 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicCloneTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicCloneTest.php @@ -31,9 +31,9 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $valueHolder->method('getName')->willReturn('bar'); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); $magicClone = new MagicClone($reflection, $valueHolder, $prefixInterceptors, $suffixInterceptors); diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicGetTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicGetTest.php index 6a4085077..f4aa83cda 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicGetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicGetTest.php @@ -37,10 +37,10 @@ public function testBodyStructure() : void ->disableOriginalConstructor() ->getMock(); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); - $publicProperties->expects(self::any())->method('isEmpty')->will(self::returnValue(false)); + $valueHolder->method('getName')->willReturn('bar'); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); + $publicProperties->method('isEmpty')->willReturn(false); $magicGet = new MagicGet( $reflection, diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicIssetTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicIssetTest.php index d3f49e70e..9379d591b 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicIssetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicIssetTest.php @@ -38,10 +38,10 @@ public function testBodyStructure() : void ->disableOriginalConstructor() ->getMock(); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); - $publicProperties->expects(self::any())->method('isEmpty')->will(self::returnValue(false)); + $valueHolder->method('getName')->willReturn('bar'); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); + $publicProperties->method('isEmpty')->willReturn(false); $magicIsset = new MagicIsset( $reflection, diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicSetTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicSetTest.php index 5aa16e039..9719a8512 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicSetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicSetTest.php @@ -38,10 +38,10 @@ public function testBodyStructure() : void ->disableOriginalConstructor() ->getMock(); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); - $publicProperties->expects(self::any())->method('isEmpty')->will(self::returnValue(false)); + $valueHolder->method('getName')->willReturn('bar'); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); + $publicProperties->method('isEmpty')->willReturn(false); $magicSet = new MagicSet( $reflection, diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicUnsetTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicUnsetTest.php index 9b24b8613..6643b35bf 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicUnsetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicUnsetTest.php @@ -38,10 +38,10 @@ public function testBodyStructure() : void ->disableOriginalConstructor() ->getMock(); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); - $publicProperties->expects(self::any())->method('isEmpty')->will(self::returnValue(false)); + $valueHolder->method('getName')->willReturn('bar'); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); + $publicProperties->method('isEmpty')->willReturn(false); $magicUnset = new MagicUnset( $reflection, diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/StaticProxyConstructorTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/StaticProxyConstructorTest.php index 9d81318c4..dcfc332a2 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/StaticProxyConstructorTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/StaticProxyConstructorTest.php @@ -30,9 +30,9 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $valueHolder->method('getName')->willReturn('foo'); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); $constructor = new StaticProxyConstructor( new ReflectionClass( @@ -73,9 +73,9 @@ public function testBodyStructureWithoutPublicProperties() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $valueHolder->method('getName')->willReturn('foo'); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); $constructor = new StaticProxyConstructor( new ReflectionClass(EmptyClass::class), @@ -111,9 +111,9 @@ public function testUnsetsPrivatePropertiesAsWell() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $valueHolder->method('getName')->willReturn('foo'); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); $constructor = new StaticProxyConstructor( new ReflectionClass(ClassWithMixedProperties::class), diff --git a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Util/InterceptorGeneratorTest.php b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Util/InterceptorGeneratorTest.php index c3fd23469..49cd1fd66 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Util/InterceptorGeneratorTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Util/InterceptorGeneratorTest.php @@ -37,13 +37,13 @@ public function testInterceptorGenerator() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $bar->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $baz->expects(self::any())->method('getName')->will(self::returnValue('baz')); - $method->expects(self::any())->method('getName')->will(self::returnValue('fooMethod')); - $method->expects(self::any())->method('getParameters')->will(self::returnValue([$bar, $baz])); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $bar->method('getName')->willReturn('bar'); + $baz->method('getName')->willReturn('baz'); + $method->method('getName')->willReturn('fooMethod'); + $method->method('getParameters')->will(self::returnValue([$bar, $baz])); + $valueHolder->method('getName')->willReturn('foo'); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); // @codingStandardsIgnoreStart $expected = <<<'PHP' @@ -99,13 +99,13 @@ public function testInterceptorGeneratorWithVoidMethod() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $bar->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $baz->expects(self::any())->method('getName')->will(self::returnValue('baz')); - $method->expects(self::any())->method('getName')->will(self::returnValue('fooMethod')); - $method->expects(self::any())->method('getParameters')->will(self::returnValue([$bar, $baz])); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $bar->method('getName')->willReturn('bar'); + $baz->method('getName')->willReturn('baz'); + $method->method('getName')->willReturn('fooMethod'); + $method->method('getParameters')->will(self::returnValue([$bar, $baz])); + $valueHolder->method('getName')->willReturn('foo'); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); // @codingStandardsIgnoreStart $expected = <<<'PHP' @@ -164,13 +164,13 @@ public function testInterceptorGeneratorWithNonVoidOriginalMethod() : void /** @var PropertyGenerator|MockObject $suffixInterceptors */ $suffixInterceptors = $this->createMock(PropertyGenerator::class); - $bar->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $baz->expects(self::any())->method('getName')->will(self::returnValue('baz')); - $method->expects(self::any())->method('getName')->will(self::returnValue('fooMethod')); - $method->expects(self::any())->method('getParameters')->will(self::returnValue([$bar, $baz])); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $prefixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('pre')); - $suffixInterceptors->expects(self::any())->method('getName')->will(self::returnValue('post')); + $bar->method('getName')->willReturn('bar'); + $baz->method('getName')->willReturn('baz'); + $method->method('getName')->willReturn('fooMethod'); + $method->method('getParameters')->will(self::returnValue([$bar, $baz])); + $valueHolder->method('getName')->willReturn('foo'); + $prefixInterceptors->method('getName')->willReturn('pre'); + $suffixInterceptors->method('getName')->willReturn('post'); // @codingStandardsIgnoreStart $expected = <<<'PHP' diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoading/MethodGenerator/StaticProxyConstructorTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoading/MethodGenerator/StaticProxyConstructorTest.php index 2be5a359e..6384383a1 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoading/MethodGenerator/StaticProxyConstructorTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoading/MethodGenerator/StaticProxyConstructorTest.php @@ -25,7 +25,7 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $initializer */ $initializer = $this->createMock(PropertyGenerator::class); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); + $initializer->method('getName')->willReturn('foo'); $constructor = new StaticProxyConstructor( $initializer, diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/CallInitializerTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/CallInitializerTest.php index 162d60168..3f97293b1 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/CallInitializerTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/CallInitializerTest.php @@ -28,8 +28,8 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $initializationTracker */ $initializationTracker = $this->createMock(PropertyGenerator::class); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('init')); - $initializationTracker->expects(self::any())->method('getName')->will(self::returnValue('track')); + $initializer->method('getName')->willReturn('init'); + $initializationTracker->method('getName')->willReturn('track'); $callInitializer = new CallInitializer( $initializer, @@ -105,8 +105,8 @@ public function testBodyStructureWithTypedProperties() : void /** @var PropertyGenerator|MockObject $initializationTracker */ $initializationTracker = $this->createMock(PropertyGenerator::class); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('init')); - $initializationTracker->expects(self::any())->method('getName')->will(self::returnValue('track')); + $initializer->method('getName')->willReturn('init'); + $initializationTracker->method('getName')->willReturn('track'); $callInitializer = new CallInitializer( $initializer, diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/GetProxyInitializerTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/GetProxyInitializerTest.php index 234c31cf1..264a97b4b 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/GetProxyInitializerTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/GetProxyInitializerTest.php @@ -25,7 +25,7 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $initializer */ $initializer = $this->createMock(PropertyGenerator::class); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); + $initializer->method('getName')->willReturn('foo'); $getter = new GetProxyInitializer($initializer); diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/InitializeProxyTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/InitializeProxyTest.php index 3855d07b0..e294c52b3 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/InitializeProxyTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/InitializeProxyTest.php @@ -27,8 +27,8 @@ public function testBodyStructure() : void /** @var MethodGenerator|MockObject $initCall */ $initCall = $this->createMock(MethodGenerator::class); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $initCall->expects(self::any())->method('getName')->will(self::returnValue('bar')); + $initializer->method('getName')->willReturn('foo'); + $initCall->method('getName')->willReturn('bar'); $initializeProxy = new InitializeProxy($initializer, $initCall); diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/IsProxyInitializedTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/IsProxyInitializedTest.php index d105c4345..317310a81 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/IsProxyInitializedTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/IsProxyInitializedTest.php @@ -24,7 +24,7 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $initializer */ $initializer = $this->createMock(PropertyGenerator::class); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); + $initializer->method('getName')->willReturn('foo'); $isProxyInitialized = new IsProxyInitialized($initializer); diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicCloneTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicCloneTest.php index 5e4051c4c..2509f79cc 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicCloneTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicCloneTest.php @@ -30,8 +30,8 @@ public function testBodyStructure() : void /** @var MethodGenerator|MockObject $initCall */ $initCall = $this->createMock(MethodGenerator::class); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $initCall->expects(self::any())->method('getName')->will(self::returnValue('bar')); + $initializer->method('getName')->willReturn('foo'); + $initCall->method('getName')->willReturn('bar'); $magicClone = new MagicClone($reflection, $initializer, $initCall); diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicGetTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicGetTest.php index 51ffff3d0..030385c5b 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicGetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicGetTest.php @@ -129,13 +129,13 @@ protected function setUp() : void ->disableOriginalConstructor() ->getMock(); - $this->initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $this->initMethod->expects(self::any())->method('getName')->will(self::returnValue('baz')); - $this->publicProperties->expects(self::any())->method('isEmpty')->will(self::returnValue(false)); - $this->publicProperties->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $this->protectedProperties->expects(self::any())->method('getName')->will(self::returnValue('baz')); - $this->privateProperties->expects(self::any())->method('getName')->will(self::returnValue('tab')); - $this->initializationTracker->expects(self::any())->method('getName')->will(self::returnValue('init')); + $this->initializer->method('getName')->willReturn('foo'); + $this->initMethod->method('getName')->willReturn('baz'); + $this->publicProperties->method('isEmpty')->willReturn(false); + $this->publicProperties->method('getName')->willReturn('bar'); + $this->protectedProperties->method('getName')->willReturn('baz'); + $this->privateProperties->method('getName')->willReturn('tab'); + $this->initializationTracker->method('getName')->willReturn('init'); } /** diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicIssetTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicIssetTest.php index 3f2be2fa5..e31af0eb7 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicIssetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicIssetTest.php @@ -116,12 +116,12 @@ protected function setUp() : void ->disableOriginalConstructor() ->getMock(); - $this->initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $this->initMethod->expects(self::any())->method('getName')->will(self::returnValue('baz')); - $this->publicProperties->expects(self::any())->method('isEmpty')->will(self::returnValue(false)); - $this->publicProperties->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $this->protectedProperties->expects(self::any())->method('getName')->will(self::returnValue('baz')); - $this->privateProperties->expects(self::any())->method('getName')->will(self::returnValue('tab')); + $this->initializer->method('getName')->willReturn('foo'); + $this->initMethod->method('getName')->willReturn('baz'); + $this->publicProperties->method('isEmpty')->willReturn(false); + $this->publicProperties->method('getName')->willReturn('bar'); + $this->protectedProperties->method('getName')->willReturn('baz'); + $this->privateProperties->method('getName')->willReturn('tab'); } /** diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSetTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSetTest.php index 856fa2a92..1f491f52c 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSetTest.php @@ -117,12 +117,12 @@ protected function setUp() : void ->disableOriginalConstructor() ->getMock(); - $this->initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $this->initMethod->expects(self::any())->method('getName')->will(self::returnValue('baz')); - $this->publicProperties->expects(self::any())->method('isEmpty')->will(self::returnValue(false)); - $this->publicProperties->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $this->protectedProperties->expects(self::any())->method('getName')->will(self::returnValue('baz')); - $this->privateProperties->expects(self::any())->method('getName')->will(self::returnValue('tab')); + $this->initializer->method('getName')->willReturn('foo'); + $this->initMethod->method('getName')->willReturn('baz'); + $this->publicProperties->method('isEmpty')->willReturn(false); + $this->publicProperties->method('getName')->willReturn('bar'); + $this->protectedProperties->method('getName')->willReturn('baz'); + $this->privateProperties->method('getName')->willReturn('tab'); } /** diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSleepTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSleepTest.php index 48cf5ef31..bf1808973 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSleepTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSleepTest.php @@ -30,8 +30,8 @@ public function testBodyStructure() : void /** @var MethodGenerator|MockObject $initMethod */ $initMethod = $this->createMock(MethodGenerator::class); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $initMethod->expects(self::any())->method('getName')->will(self::returnValue('bar')); + $initializer->method('getName')->willReturn('foo'); + $initMethod->method('getName')->willReturn('bar'); $magicSleep = new MagicSleep($reflection, $initializer, $initMethod); diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicUnsetTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicUnsetTest.php index 9d8230320..dc7dd247f 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicUnsetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicUnsetTest.php @@ -122,12 +122,12 @@ protected function setUp() : void ->disableOriginalConstructor() ->getMock(); - $this->initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $this->initMethod->expects(self::any())->method('getName')->will(self::returnValue('baz')); - $this->publicProperties->expects(self::any())->method('isEmpty')->will(self::returnValue(false)); - $this->publicProperties->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $this->protectedProperties->expects(self::any())->method('getName')->will(self::returnValue('baz')); - $this->privateProperties->expects(self::any())->method('getName')->will(self::returnValue('tab')); + $this->initializer->method('getName')->willReturn('foo'); + $this->initMethod->method('getName')->willReturn('baz'); + $this->publicProperties->method('isEmpty')->willReturn(false); + $this->publicProperties->method('getName')->willReturn('bar'); + $this->protectedProperties->method('getName')->willReturn('baz'); + $this->privateProperties->method('getName')->willReturn('tab'); } /** diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/SetProxyInitializerTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/SetProxyInitializerTest.php index 439fb4f2b..f8cf672f5 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/SetProxyInitializerTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/SetProxyInitializerTest.php @@ -26,7 +26,7 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $initializer */ $initializer = $this->createMock(PropertyGenerator::class); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); + $initializer->method('getName')->willReturn('foo'); $setter = new SetProxyInitializer($initializer); $parameters = $setter->getParameters(); diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/GetProxyInitializerTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/GetProxyInitializerTest.php index 5136f8207..d1013dbfa 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/GetProxyInitializerTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/GetProxyInitializerTest.php @@ -25,7 +25,7 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $initializer */ $initializer = $this->createMock(PropertyGenerator::class); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); + $initializer->method('getName')->willReturn('foo'); $getter = new GetProxyInitializer($initializer); diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/InitializeProxyTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/InitializeProxyTest.php index bcbee1280..55b9619fd 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/InitializeProxyTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/InitializeProxyTest.php @@ -26,8 +26,8 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $valueHolder */ $valueHolder = $this->createMock(PropertyGenerator::class); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); + $initializer->method('getName')->willReturn('foo'); + $valueHolder->method('getName')->willReturn('bar'); $initializeProxy = new InitializeProxy($initializer, $valueHolder); diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/IsProxyInitializedTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/IsProxyInitializedTest.php index 8dc5d07f5..cda2a3bf2 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/IsProxyInitializedTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/IsProxyInitializedTest.php @@ -24,7 +24,7 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $valueHolder */ $valueHolder = $this->createMock(PropertyGenerator::class); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); + $valueHolder->method('getName')->willReturn('bar'); $isProxyInitialized = new IsProxyInitialized($valueHolder); diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/LazyLoadingMethodInterceptorTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/LazyLoadingMethodInterceptorTest.php index 83a825c4b..d617363b8 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/LazyLoadingMethodInterceptorTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/LazyLoadingMethodInterceptorTest.php @@ -28,8 +28,8 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $valueHolder */ $valueHolder = $this->createMock(PropertyGenerator::class); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); + $initializer->method('getName')->willReturn('foo'); + $valueHolder->method('getName')->willReturn('bar'); $reflection = new MethodReflection(BaseClass::class, 'publicByReferenceParameterMethod'); $method = LazyLoadingMethodInterceptor::generateMethod($reflection, $initializer, $valueHolder); @@ -55,10 +55,10 @@ public function testBodyStructureWithoutParameters() : void /** @var PropertyGenerator|MockObject $valueHolder */ $valueHolder = $this->createMock(PropertyGenerator::class); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); + $initializer->method('getName')->willReturn('foo'); + $valueHolder->method('getName')->willReturn('bar'); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); + $initializer->method('getName')->willReturn('foo'); $method = LazyLoadingMethodInterceptor::generateMethod($reflectionMethod, $initializer, $valueHolder); diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicCloneTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicCloneTest.php index 5d399b850..731ebc44b 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicCloneTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicCloneTest.php @@ -29,8 +29,8 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $valueHolder */ $valueHolder = $this->createMock(PropertyGenerator::class); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); + $initializer->method('getName')->willReturn('foo'); + $valueHolder->method('getName')->willReturn('bar'); $magicClone = new MagicClone($reflection, $initializer, $valueHolder); diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicGetTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicGetTest.php index 1dec83527..af4b8a8e8 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicGetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicGetTest.php @@ -36,10 +36,10 @@ public function testBodyStructure() : void ->disableOriginalConstructor() ->getMock(); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $publicProperties->expects(self::any())->method('isEmpty')->will(self::returnValue(false)); - $publicProperties->expects(self::any())->method('getName')->will(self::returnValue('bar')); + $initializer->method('getName')->willReturn('foo'); + $valueHolder->method('getName')->willReturn('bar'); + $publicProperties->method('isEmpty')->willReturn(false); + $publicProperties->method('getName')->willReturn('bar'); $magicGet = new MagicGet($reflection, $initializer, $valueHolder, $publicProperties); @@ -71,10 +71,10 @@ public function testBodyStructureWithPreExistingGetMethod() : void ->disableOriginalConstructor() ->getMock(); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $publicProperties->expects(self::any())->method('isEmpty')->will(self::returnValue(false)); - $publicProperties->expects(self::any())->method('getName')->will(self::returnValue('bar')); + $initializer->method('getName')->willReturn('foo'); + $valueHolder->method('getName')->willReturn('bar'); + $publicProperties->method('isEmpty')->willReturn(false); + $publicProperties->method('getName')->willReturn('bar'); $magicGet = new MagicGet($reflection, $initializer, $valueHolder, $publicProperties); diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicIssetTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicIssetTest.php index c63b9b694..2814bf899 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicIssetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicIssetTest.php @@ -35,10 +35,10 @@ public function testBodyStructure() : void ->disableOriginalConstructor() ->getMock(); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $publicProperties->expects(self::any())->method('isEmpty')->will(self::returnValue(false)); - $publicProperties->expects(self::any())->method('getName')->will(self::returnValue('bar')); + $initializer->method('getName')->willReturn('foo'); + $valueHolder->method('getName')->willReturn('bar'); + $publicProperties->method('isEmpty')->willReturn(false); + $publicProperties->method('getName')->willReturn('bar'); $magicIsset = new MagicIsset($reflection, $initializer, $valueHolder, $publicProperties); diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSetTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSetTest.php index 6346cfc12..beadc7054 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSetTest.php @@ -34,10 +34,10 @@ public function testBodyStructure() : void ->disableOriginalConstructor() ->getMock(); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $publicProperties->expects(self::any())->method('isEmpty')->will(self::returnValue(false)); - $publicProperties->expects(self::any())->method('getName')->will(self::returnValue('bar')); + $initializer->method('getName')->willReturn('foo'); + $valueHolder->method('getName')->willReturn('bar'); + $publicProperties->method('isEmpty')->willReturn(false); + $publicProperties->method('getName')->willReturn('bar'); $magicSet = new MagicSet($reflection, $initializer, $valueHolder, $publicProperties); @@ -68,10 +68,10 @@ public function testBodyStructureWithPreExistingMagicMethod() : void ->disableOriginalConstructor() ->getMock(); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $publicProperties->expects(self::any())->method('isEmpty')->will(self::returnValue(false)); - $publicProperties->expects(self::any())->method('getName')->will(self::returnValue('bar')); + $initializer->method('getName')->willReturn('foo'); + $valueHolder->method('getName')->willReturn('bar'); + $publicProperties->method('isEmpty')->willReturn(false); + $publicProperties->method('getName')->willReturn('bar'); $magicSet = new MagicSet($reflection, $initializer, $valueHolder, $publicProperties); diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSleepTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSleepTest.php index db0ed1aaf..531eea472 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSleepTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSleepTest.php @@ -29,8 +29,8 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $valueHolder */ $valueHolder = $this->createMock(PropertyGenerator::class); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); + $initializer->method('getName')->willReturn('foo'); + $valueHolder->method('getName')->willReturn('bar'); $magicSleep = new MagicSleep($reflection, $initializer, $valueHolder); diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicUnsetTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicUnsetTest.php index 30e59d9f0..d3ce5e66e 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicUnsetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicUnsetTest.php @@ -34,10 +34,10 @@ public function testBodyStructure() : void ->disableOriginalConstructor() ->getMock(); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $publicProperties->expects(self::any())->method('isEmpty')->will(self::returnValue(false)); - $publicProperties->expects(self::any())->method('getName')->will(self::returnValue('bar')); + $initializer->method('getName')->willReturn('foo'); + $valueHolder->method('getName')->willReturn('bar'); + $publicProperties->method('isEmpty')->willReturn(false); + $publicProperties->method('getName')->willReturn('bar'); $magicIsset = new MagicUnset($reflection, $initializer, $valueHolder, $publicProperties); @@ -68,10 +68,10 @@ public function testBodyStructureWithPreExistingMagicMethod() : void ->disableOriginalConstructor() ->getMock(); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); - $publicProperties->expects(self::any())->method('isEmpty')->will(self::returnValue(false)); - $publicProperties->expects(self::any())->method('getName')->will(self::returnValue('bar')); + $initializer->method('getName')->willReturn('foo'); + $valueHolder->method('getName')->willReturn('bar'); + $publicProperties->method('isEmpty')->willReturn(false); + $publicProperties->method('getName')->willReturn('bar'); $magicIsset = new MagicUnset($reflection, $initializer, $valueHolder, $publicProperties); diff --git a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/SetProxyInitializerTest.php b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/SetProxyInitializerTest.php index 4578df1ac..3bfe36cd5 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/SetProxyInitializerTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/SetProxyInitializerTest.php @@ -26,7 +26,7 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $initializer */ $initializer = $this->createMock(PropertyGenerator::class); - $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo')); + $initializer->method('getName')->willReturn('foo'); $setter = new SetProxyInitializer($initializer); $parameters = $setter->getParameters(); diff --git a/tests/ProxyManagerTest/ProxyGenerator/NullObjectGeneratorTest.php b/tests/ProxyManagerTest/ProxyGenerator/NullObjectGeneratorTest.php index 001f78028..c62c1b59c 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/NullObjectGeneratorTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/NullObjectGeneratorTest.php @@ -74,7 +74,7 @@ public function testGeneratesValidCode(string $className) : void $callback = [$proxy, $method->getName()]; - self::assertInternalType('callable', $callback); + self::assertIsCallable($callback); self::assertNull($callback()); } } diff --git a/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/PublicPropertiesMapTest.php b/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/PublicPropertiesMapTest.php index 0b2b13cd4..9f7ae4024 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/PublicPropertiesMapTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/PublicPropertiesMapTest.php @@ -26,7 +26,7 @@ public function testEmptyClass() : void Properties::fromReflectionClass(new ReflectionClass(EmptyClass::class)) ); - self::assertInternalType('array', $publicProperties->getDefaultValue()->getValue()); + self::assertIsArray($publicProperties->getDefaultValue()->getValue()); self::assertEmpty($publicProperties->getDefaultValue()->getValue()); self::assertTrue($publicProperties->isStatic()); self::assertSame('private', $publicProperties->getVisibility()); @@ -39,7 +39,7 @@ public function testClassWithPublicProperties() : void Properties::fromReflectionClass(new ReflectionClass(ClassWithPublicProperties::class)) ); - self::assertInternalType('array', $publicProperties->getDefaultValue()->getValue()); + self::assertIsArray($publicProperties->getDefaultValue()->getValue()); self::assertCount(10, $publicProperties->getDefaultValue()->getValue()); self::assertTrue($publicProperties->isStatic()); self::assertSame('private', $publicProperties->getVisibility()); diff --git a/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicGetTest.php b/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicGetTest.php index 840646993..95b0bb7a4 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicGetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicGetTest.php @@ -26,7 +26,7 @@ public function testBodyStructure() : void $reflection = new ReflectionClass(EmptyClass::class); /** @var PropertyGenerator|MockObject $adapter */ $adapter = $this->createMock(PropertyGenerator::class); - $adapter->expects(self::any())->method('getName')->will(self::returnValue('foo')); + $adapter->method('getName')->willReturn('foo'); $magicGet = new MagicGet($reflection, $adapter); diff --git a/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicIssetTest.php b/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicIssetTest.php index 379700f87..7c9381352 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicIssetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicIssetTest.php @@ -26,7 +26,7 @@ public function testBodyStructure() : void $reflection = new ReflectionClass(EmptyClass::class); /** @var PropertyGenerator|MockObject $adapter */ $adapter = $this->createMock(PropertyGenerator::class); - $adapter->expects(self::any())->method('getName')->will(self::returnValue('foo')); + $adapter->method('getName')->willReturn('foo'); $magicGet = new MagicIsset($reflection, $adapter); diff --git a/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicSetTest.php b/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicSetTest.php index 8f3183163..245a64244 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicSetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicSetTest.php @@ -26,7 +26,7 @@ public function testBodyStructure() : void $reflection = new ReflectionClass(EmptyClass::class); /** @var PropertyGenerator|MockObject $adapter */ $adapter = $this->createMock(PropertyGenerator::class); - $adapter->expects(self::any())->method('getName')->will(self::returnValue('foo')); + $adapter->method('getName')->willReturn('foo'); $magicGet = new MagicSet($reflection, $adapter); diff --git a/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicUnsetTest.php b/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicUnsetTest.php index e7b45abd5..ea80fc851 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicUnsetTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicUnsetTest.php @@ -26,7 +26,7 @@ public function testBodyStructure() : void $reflection = new ReflectionClass(EmptyClass::class); /** @var PropertyGenerator|MockObject $adapter */ $adapter = $this->createMock(PropertyGenerator::class); - $adapter->expects(self::any())->method('getName')->will(self::returnValue('foo')); + $adapter->method('getName')->willReturn('foo'); $magicGet = new MagicUnset($reflection, $adapter); diff --git a/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/RemoteObjectMethodTest.php b/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/RemoteObjectMethodTest.php index 416cc7254..3d85a0e29 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/RemoteObjectMethodTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/RemoteObjectMethodTest.php @@ -26,7 +26,7 @@ public function testBodyStructureWithParameters() : void { /** @var PropertyGenerator|MockObject $adapter */ $adapter = $this->createMock(PropertyGenerator::class); - $adapter->expects(self::any())->method('getName')->will(self::returnValue('adapter')); + $adapter->method('getName')->willReturn('adapter'); $reflectionMethod = new MethodReflection( BaseClass::class, @@ -56,7 +56,7 @@ public function testBodyStructureWithArrayParameter() : void { /** @var PropertyGenerator|MockObject $adapter */ $adapter = $this->createMock(PropertyGenerator::class); - $adapter->expects(self::any())->method('getName')->will(self::returnValue('adapter')); + $adapter->method('getName')->willReturn('adapter'); $reflectionMethod = new MethodReflection(BaseClass::class, 'publicArrayHintedMethod'); @@ -83,7 +83,7 @@ public function testBodyStructureWithoutParameters() : void { /** @var PropertyGenerator|MockObject $adapter */ $adapter = $this->createMock(PropertyGenerator::class); - $adapter->expects(self::any())->method('getName')->will(self::returnValue('adapter')); + $adapter->method('getName')->willReturn('adapter'); $reflectionMethod = new MethodReflection(BaseClass::class, 'publicMethod'); diff --git a/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/StaticProxyConstructorTest.php b/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/StaticProxyConstructorTest.php index 9ba14f833..a6f5a6e15 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/StaticProxyConstructorTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/StaticProxyConstructorTest.php @@ -24,7 +24,7 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $adapter */ $adapter = $this->createMock(PropertyGenerator::class); - $adapter->expects(self::any())->method('getName')->will(self::returnValue('adapter')); + $adapter->method('getName')->willReturn('adapter'); $constructor = new StaticProxyConstructor( new ReflectionClass(ClassWithMixedProperties::class), diff --git a/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/ConstructorTest.php b/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/ConstructorTest.php index dbee39c6e..1b899d3ea 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/ConstructorTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/ConstructorTest.php @@ -27,7 +27,7 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $valueHolder */ $valueHolder = $this->createMock(PropertyGenerator::class); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('foo')); + $valueHolder->method('getName')->willReturn('foo'); $constructor = Constructor::generateMethod( new ReflectionClass( @@ -57,7 +57,7 @@ public function testBodyStructureWithoutPublicProperties() : void /** @var PropertyGenerator|MockObject $valueHolder */ $valueHolder = $this->createMock(PropertyGenerator::class); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('foo')); + $valueHolder->method('getName')->willReturn('foo'); $constructor = Constructor::generateMethod( new ReflectionClass(EmptyClass::class), @@ -82,7 +82,7 @@ public function testBodyStructureWithStaticProperties() : void /** @var PropertyGenerator|MockObject $valueHolder */ $valueHolder = $this->createMock(PropertyGenerator::class); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('foo')); + $valueHolder->method('getName')->willReturn('foo'); $constructor = Constructor::generateMethod(new ReflectionClass(ClassWithMixedProperties::class), $valueHolder); @@ -111,7 +111,7 @@ public function testBodyStructureWithVariadicArguments() : void /** @var PropertyGenerator|MockObject $valueHolder */ $valueHolder = $this->createMock(PropertyGenerator::class); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('foo')); + $valueHolder->method('getName')->willReturn('foo'); $constructor = Constructor::generateMethod( new ReflectionClass(ClassWithVariadicConstructorArgument::class), diff --git a/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/GetWrappedValueHolderValueTest.php b/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/GetWrappedValueHolderValueTest.php index 041207733..b8e8c5b42 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/GetWrappedValueHolderValueTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/GetWrappedValueHolderValueTest.php @@ -25,7 +25,7 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $valueHolder */ $valueHolder = $this->createMock(PropertyGenerator::class); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('foo')); + $valueHolder->method('getName')->willReturn('foo'); $getter = new GetWrappedValueHolderValue($valueHolder); diff --git a/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/MagicSleepTest.php b/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/MagicSleepTest.php index 6e027f8f9..ee08b54e2 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/MagicSleepTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/MagicSleepTest.php @@ -27,7 +27,7 @@ public function testBodyStructure() : void /** @var PropertyGenerator|MockObject $valueHolder */ $valueHolder = $this->createMock(PropertyGenerator::class); - $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar')); + $valueHolder->method('getName')->willReturn('bar'); $magicSleep = new MagicSleep($reflection, $valueHolder); diff --git a/tests/ProxyManagerTest/Signature/ClassSignatureGeneratorTest.php b/tests/ProxyManagerTest/Signature/ClassSignatureGeneratorTest.php index 0fab6221c..f73f9a242 100644 --- a/tests/ProxyManagerTest/Signature/ClassSignatureGeneratorTest.php +++ b/tests/ProxyManagerTest/Signature/ClassSignatureGeneratorTest.php @@ -51,17 +51,15 @@ public function testAddSignature() : void $this ->signatureGenerator - ->expects(self::any()) ->method('generateSignature') ->with(['foo' => 'bar']) - ->will(self::returnValue('valid-signature')); + ->willReturn('valid-signature'); $this ->signatureGenerator - ->expects(self::any()) ->method('generateSignatureKey') ->with(['foo' => 'bar']) - ->will(self::returnValue('PropertyName')); + ->willReturn('PropertyName'); $this->classSignatureGenerator->addSignature($classGenerator, ['foo' => 'bar']); } diff --git a/tests/ProxyManagerTest/Signature/Exception/InvalidSignatureExceptionTest.php b/tests/ProxyManagerTest/Signature/Exception/InvalidSignatureExceptionTest.php index 512aa481f..21c5570e0 100644 --- a/tests/ProxyManagerTest/Signature/Exception/InvalidSignatureExceptionTest.php +++ b/tests/ProxyManagerTest/Signature/Exception/InvalidSignatureExceptionTest.php @@ -25,8 +25,6 @@ public function testFromInvalidSignature() : void 'expected-signature' ); - self::assertInstanceOf(InvalidSignatureException::class, $exception); - self::assertSame( 'Found signature "blah" for class "' . self::class diff --git a/tests/ProxyManagerTest/Signature/Exception/MissingSignatureExceptionTest.php b/tests/ProxyManagerTest/Signature/Exception/MissingSignatureExceptionTest.php index b219fe7f7..2c4082c94 100644 --- a/tests/ProxyManagerTest/Signature/Exception/MissingSignatureExceptionTest.php +++ b/tests/ProxyManagerTest/Signature/Exception/MissingSignatureExceptionTest.php @@ -24,8 +24,6 @@ public function testFromMissingSignature() : void 'expected-signature' ); - self::assertInstanceOf(MissingSignatureException::class, $exception); - self::assertSame( 'No signature found for class "' . self::class diff --git a/tests/ProxyManagerTest/Signature/SignatureCheckerTest.php b/tests/ProxyManagerTest/Signature/SignatureCheckerTest.php index fb899078a..04b500eaf 100644 --- a/tests/ProxyManagerTest/Signature/SignatureCheckerTest.php +++ b/tests/ProxyManagerTest/Signature/SignatureCheckerTest.php @@ -45,13 +45,13 @@ public function testCheckSignatureWithValidKey() : void ->expects(self::atLeastOnce()) ->method('generateSignatureKey') ->with(['foo' => 'bar']) - ->will(self::returnValue('Example')); + ->willReturn('Example'); $this ->signatureGenerator ->expects(self::atLeastOnce()) ->method('generateSignature') ->with(['foo' => 'bar']) - ->will(self::returnValue('valid-signature')); + ->willReturn('valid-signature'); $this->signatureChecker->checkSignature(new ReflectionClass($this), ['foo' => 'bar']); } @@ -60,16 +60,15 @@ public function testCheckSignatureWithInvalidKey() : void { $this ->signatureGenerator - ->expects(self::any()) + ->method('generateSignatureKey') ->with(['foo' => 'bar']) - ->will(self::returnValue('InvalidKey')); + ->willReturn('InvalidKey'); $this ->signatureGenerator - ->expects(self::any()) ->method('generateSignature') ->with(['foo' => 'bar']) - ->will(self::returnValue('valid-signature')); + ->willReturn('valid-signature'); $this->expectException(MissingSignatureException::class); @@ -80,16 +79,14 @@ public function testCheckSignatureWithInvalidValue() : void { $this ->signatureGenerator - ->expects(self::any()) ->method('generateSignatureKey') ->with(['foo' => 'bar']) - ->will(self::returnValue('Example')); + ->willReturn('Example'); $this ->signatureGenerator - ->expects(self::any()) ->method('generateSignature') ->with(['foo' => 'bar']) - ->will(self::returnValue('invalid-signature')); + ->willReturn('invalid-signature'); $this->expectException(InvalidSignatureException::class); diff --git a/tests/ProxyManagerTest/Signature/SignatureGeneratorTest.php b/tests/ProxyManagerTest/Signature/SignatureGeneratorTest.php index 8dd12c511..ce4f99aa4 100644 --- a/tests/ProxyManagerTest/Signature/SignatureGeneratorTest.php +++ b/tests/ProxyManagerTest/Signature/SignatureGeneratorTest.php @@ -47,7 +47,7 @@ public function testGenerateSignatureKey(array $parameters, string $expected) : } /** @return string[][]|string[][][] */ - public function signatures() : array + public static function signatures() : array { return [ [ @@ -74,7 +74,7 @@ public function signatures() : array } /** @return string[][]|string[][][] */ - public function signatureKeys() : array + public static function signatureKeys() : array { return [ [[], '40cd750bba9870f18aada2478b24840a'], diff --git a/tests/ProxyManagerTest/VersionTest.php b/tests/ProxyManagerTest/VersionTest.php index dcb090baf..949a56f6c 100644 --- a/tests/ProxyManagerTest/VersionTest.php +++ b/tests/ProxyManagerTest/VersionTest.php @@ -15,11 +15,11 @@ */ class VersionTest extends TestCase { - public function testGetVersion() : void + public static function testGetVersion() : void { $version = Version::getVersion(); - self::assertInternalType('string', $version); + self::assertIsString($version); self::assertNotEmpty($version); self::assertStringMatchesFormat('%A@%A', $version); }