From f0575128780dd6b634adbf4e2cb7f26d60226c8f Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Thu, 28 Mar 2019 20:12:59 +0100 Subject: [PATCH] test on phpunit 8 + some minor improvements --- .gitignore | 2 +- Resources/doc/form/vich_file_type.md | 4 ++-- Resources/doc/form/vich_image_type.md | 6 +++--- Tests/DependencyInjection/VichUploaderExtensionTest.php | 4 ++-- Tests/Form/Type/VichFileTypeTest.php | 6 +++--- Tests/Form/Type/VichImageTypeTest.php | 2 +- Tests/Naming/CurrentDateTimeDirectoryNamerTest.php | 1 + composer.json | 4 ++-- 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 5b3da3dd..4763aa01 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -.php_cs.cache +.*.cache phpunit.xml composer.lock vendor/ diff --git a/Resources/doc/form/vich_file_type.md b/Resources/doc/form/vich_file_type.md index 11ca2039..c3becf9a 100644 --- a/Resources/doc/form/vich_file_type.md +++ b/Resources/doc/form/vich_file_type.md @@ -54,7 +54,7 @@ Can be callable use Vich\UploaderBundle\Form\Type\VichFileType; $builder->add('genericFile', VichFileType::class, [ - 'download_uri' => function (Product $product) use ($router) { + 'download_uri' => static function (Product $product) use ($router) { return $router->generateUrl('acme_download_image', $product->getId()); }, ]); @@ -83,7 +83,7 @@ Can be callable use Vich\UploaderBundle\Form\Type\VichFileType; $builder->add('genericFile', VichFileType::class, [ - 'download_label' => function (Product $product) { + 'download_label' => static function (Product $product) { return $product->getTitle(); }, ]); diff --git a/Resources/doc/form/vich_image_type.md b/Resources/doc/form/vich_image_type.md index 3d331231..a035bafc 100644 --- a/Resources/doc/form/vich_image_type.md +++ b/Resources/doc/form/vich_image_type.md @@ -56,7 +56,7 @@ Can be callable use Vich\UploaderBundle\Form\Type\VichImageType; $builder->add('genericFile', VichImageType::class, [ - 'download_uri' => function (Product $product) use ($router) { + 'download_uri' => static function (Product $product) use ($router) { return $router->generateUrl('acme_download_image', $product->getId()); }, ]); @@ -85,7 +85,7 @@ Can be callable use Vich\UploaderBundle\Form\Type\VichImageType; $builder->add('genericFile', VichImageType::class, [ - 'download_label' => function (Product $product) { + 'download_label' => static function (Product $product) { return $product->getTitle(); }, ]); @@ -126,7 +126,7 @@ Can be callable use Vich\UploaderBundle\Form\Type\VichImageType; $builder->add('genericFile', VichImageType::class, [ - 'image_uri' => function (Photo $photo, $resolvedUri) use ($cacheManager) { + 'image_uri' => static function (Photo $photo, $resolvedUri) use ($cacheManager) { // $cacheManager is LiipImagine cache manager return $cacheManager->getBrowserPath( $resolvedUri, diff --git a/Tests/DependencyInjection/VichUploaderExtensionTest.php b/Tests/DependencyInjection/VichUploaderExtensionTest.php index 32b12aa4..60ccea2b 100644 --- a/Tests/DependencyInjection/VichUploaderExtensionTest.php +++ b/Tests/DependencyInjection/VichUploaderExtensionTest.php @@ -10,14 +10,14 @@ class VichUploaderExtensionTest extends AbstractExtensionTestCase { - protected function getContainerExtensions() + protected function getContainerExtensions(): array { return [ new VichUploaderExtension(), ]; } - protected function getMinimalConfiguration() + protected function getMinimalConfiguration(): array { return [ 'db_driver' => 'propel', diff --git a/Tests/Form/Type/VichFileTypeTest.php b/Tests/Form/Type/VichFileTypeTest.php index ae83aa9b..f207924e 100644 --- a/Tests/Form/Type/VichFileTypeTest.php +++ b/Tests/Form/Type/VichFileTypeTest.php @@ -180,7 +180,7 @@ public function buildViewDataProvider(): array $object, [ 'download_label' => 'download', - 'download_uri' => function (Product $product) { + 'download_uri' => static function (Product $product) { return '/download/'.$product->getImageOriginalName(); }, ], @@ -218,7 +218,7 @@ public function buildViewDataProvider(): array [ $object, [ - 'download_label' => function (Product $product) { + 'download_label' => static function (Product $product) { return 'prefix-'.$product->getImageOriginalName(); }, 'download_uri' => true, @@ -235,7 +235,7 @@ public function buildViewDataProvider(): array [ $object, [ - 'download_label' => function (Product $product) { + 'download_label' => static function (Product $product) { return [ 'download_label' => 'prefix-'.$product->getImageOriginalName(), 'translation_domain' => 'messages', diff --git a/Tests/Form/Type/VichImageTypeTest.php b/Tests/Form/Type/VichImageTypeTest.php index dba3adb7..5f237519 100644 --- a/Tests/Form/Type/VichImageTypeTest.php +++ b/Tests/Form/Type/VichImageTypeTest.php @@ -116,7 +116,7 @@ public function buildViewDataProvider(): array [ 'download_label' => 'download', 'download_uri' => 'custom-uri', - 'image_uri' => function (Product $product, $resolvedUri) { + 'image_uri' => static function (Product $product, $resolvedUri) { return 'prefix-'.$resolvedUri; }, 'imagine_pattern' => null, diff --git a/Tests/Naming/CurrentDateTimeDirectoryNamerTest.php b/Tests/Naming/CurrentDateTimeDirectoryNamerTest.php index 55f3d2bd..ebf424f4 100644 --- a/Tests/Naming/CurrentDateTimeDirectoryNamerTest.php +++ b/Tests/Naming/CurrentDateTimeDirectoryNamerTest.php @@ -35,6 +35,7 @@ public function directoryNameDataProvider(): array */ public function testNameReturnsTheRightName(int $timestamp, ?string $dateTimeFormat, string $expectedName): void { + \date_default_timezone_set('UTC'); $entity = new DummyEntity(); $mapping = $this->getPropertyMappingMock(); diff --git a/composer.json b/composer.json index 937c2023..3658cca1 100644 --- a/composer.json +++ b/composer.json @@ -40,10 +40,10 @@ "doctrine/mongodb-odm": "^1.2", "doctrine/orm": "^2.5", "knplabs/knp-gaufrette-bundle": "^0.5", - "matthiasnoback/symfony-dependency-injection-test": "^2.3|^3.0", + "matthiasnoback/symfony-dependency-injection-test": "^4.0", "mikey179/vfsstream": "^1.6", "oneup/flysystem-bundle": "^3.0", - "phpunit/phpunit": "^6.5|^7.0", + "phpunit/phpunit": "^7.0|^8.0", "symfony/browser-kit": "^3.4|^4.0", "symfony/css-selector": "^3.4|^4.0", "symfony/doctrine-bridge": "^3.4|^4.0",