From bddb6e615e98aea98cd6bc089e5370ee3e599906 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 25 Jan 2022 13:44:53 +0100 Subject: [PATCH] CS: Autofix. --- .../PhoneNumberTypeDataTransformer.php | 2 + .../Form/Type/PersonPhoneType.php | 1 - .../Form/Type/PhoneNumberType.php | 2 + .../Tests/Form/Type/PhoneNumberTypeTest.php | 27 +++++----- .../migrations/Version20210518135515.php | 49 +++++++++++-------- 5 files changed, 48 insertions(+), 33 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Form/DataTransformer/PhoneNumberTypeDataTransformer.php b/src/Bundle/ChillPersonBundle/Form/DataTransformer/PhoneNumberTypeDataTransformer.php index 2ccaaf7bb..05d86beed 100644 --- a/src/Bundle/ChillPersonBundle/Form/DataTransformer/PhoneNumberTypeDataTransformer.php +++ b/src/Bundle/ChillPersonBundle/Form/DataTransformer/PhoneNumberTypeDataTransformer.php @@ -1,6 +1,8 @@ parameterBag); - - return [ - new PreloadedExtension([$type], []), - ]; - } - public function singleFieldProvider() { yield ['abc', [], '']; @@ -61,7 +57,6 @@ final class PhoneNumberTypeTest extends TypeTestCase yield ['0486/540.660', ['default_country_prefix' => '+36'], '+36486540660']; } - /** * @dataProvider singleFieldProvider */ @@ -81,4 +76,14 @@ final class PhoneNumberTypeTest extends TypeTestCase self::assertSame($output, $view->vars['value']); } + + protected function getExtensions() + { + // create a type instance with the mocked dependencies + $type = new PhoneNumberType($this->parameterBag); + + return [ + new PreloadedExtension([$type], []), + ]; + } } diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20210518135515.php b/src/Bundle/ChillPersonBundle/migrations/Version20210518135515.php index 5471fc92e..a0bc731d6 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20210518135515.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20210518135515.php @@ -1,5 +1,12 @@ addSql('UPDATE chill_person_person SET phonenumber = :pn WHERE phonenumber IS NULL', ['pn' => '']); + $this->addSql('UPDATE chill_person_person SET mobilenumber = :pn WHERE mobilenumber IS NULL', ['pn' => '']); + + $this->addSql('ALTER TABLE chill_person_person ALTER phonenumber TYPE TEXT'); + $this->addSql('ALTER TABLE chill_person_person ALTER phonenumber DROP DEFAULT'); + $this->addSql('ALTER TABLE chill_person_person ALTER phonenumber SET NOT NULL'); + $this->addSql('COMMENT ON COLUMN chill_person_person.phonenumber IS NULL'); + + $this->addSql('ALTER TABLE chill_person_phone ALTER phonenumber TYPE TEXT'); + $this->addSql('ALTER TABLE chill_person_phone ALTER phonenumber DROP DEFAULT'); + $this->addSql('COMMENT ON COLUMN chill_person_phone.phonenumber IS NULL'); + + $this->addSql('ALTER TABLE chill_person_person ALTER mobilenumber TYPE TEXT'); + $this->addSql('ALTER TABLE chill_person_person ALTER mobilenumber DROP DEFAULT'); + $this->addSql('COMMENT ON COLUMN chill_person_person.mobilenumber IS NULL'); + } + public function getDescription(): string { return ''; @@ -32,26 +58,7 @@ final class Version20210518135515 extends AbstractMigration $this->addSql('ALTER TABLE chill_person_person ALTER mobilenumber DROP DEFAULT'); $this->addSql('COMMENT ON COLUMN chill_person_person.mobilenumber IS \'(DC2Type:phone_number)\''); - $this->addSql('UPDATE chill_person_person SET phonenumber = NULL WHERE phonenumber=:pn', array('pn' => '')); - $this->addSql('UPDATE chill_person_person SET mobilenumber = NULL WHERE mobilenumber=:pn', array('pn' => '')); - } - - public function down(Schema $schema): void - { - $this->addSql('UPDATE chill_person_person SET phonenumber = :pn WHERE phonenumber IS NULL', array('pn' => '')); - $this->addSql('UPDATE chill_person_person SET mobilenumber = :pn WHERE mobilenumber IS NULL', array('pn' => '')); - - $this->addSql('ALTER TABLE chill_person_person ALTER phonenumber TYPE TEXT'); - $this->addSql('ALTER TABLE chill_person_person ALTER phonenumber DROP DEFAULT'); - $this->addSql('ALTER TABLE chill_person_person ALTER phonenumber SET NOT NULL'); - $this->addSql('COMMENT ON COLUMN chill_person_person.phonenumber IS NULL'); - - $this->addSql('ALTER TABLE chill_person_phone ALTER phonenumber TYPE TEXT'); - $this->addSql('ALTER TABLE chill_person_phone ALTER phonenumber DROP DEFAULT'); - $this->addSql('COMMENT ON COLUMN chill_person_phone.phonenumber IS NULL'); - - $this->addSql('ALTER TABLE chill_person_person ALTER mobilenumber TYPE TEXT'); - $this->addSql('ALTER TABLE chill_person_person ALTER mobilenumber DROP DEFAULT'); - $this->addSql('COMMENT ON COLUMN chill_person_person.mobilenumber IS NULL'); + $this->addSql('UPDATE chill_person_person SET phonenumber = NULL WHERE phonenumber=:pn', ['pn' => '']); + $this->addSql('UPDATE chill_person_person SET mobilenumber = NULL WHERE mobilenumber=:pn', ['pn' => '']); } }