From e7e230960254f0f2b3f65440c2f0f0e0b3391d4f Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Sun, 14 Nov 2021 03:41:37 -0500 Subject: [PATCH] Minor: Format code --- src/CoreBundle/Entity/SocialPostFeedback.php | 1 + src/CoreBundle/Entity/User.php | 3 ++- .../Schema/V200/Version20200821224242.php | 14 +++++++------- src/CoreBundle/Repository/SocialPostRepository.php | 6 ++++-- .../Repository/SocialPostRepositoryTest.php | 9 ++++++--- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/CoreBundle/Entity/SocialPostFeedback.php b/src/CoreBundle/Entity/SocialPostFeedback.php index e557f93f78..39e5995337 100644 --- a/src/CoreBundle/Entity/SocialPostFeedback.php +++ b/src/CoreBundle/Entity/SocialPostFeedback.php @@ -1,4 +1,5 @@ getSocialPostsFeedbacks() - ->filter(fn(SocialPostFeedback $postFeedback) => $postFeedback->getSocialPost() === $post); + ->filter(fn (SocialPostFeedback $postFeedback) => $postFeedback->getSocialPost() === $post) + ; if ($filtered->count() > 0) { return $filtered->first(); diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20200821224242.php b/src/CoreBundle/Migrations/Schema/V200/Version20200821224242.php index 9ecc0b515e..b0783fe015 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20200821224242.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20200821224242.php @@ -167,7 +167,7 @@ final class Version20200821224242 extends AbstractMigrationChamilo $this->addSql("CREATE TABLE social_post (id BIGINT AUTO_INCREMENT NOT NULL, sender_id INT NOT NULL, user_receiver_id INT DEFAULT NULL, group_receiver_id INT DEFAULT NULL, parent_id BIGINT DEFAULT NULL, content LONGTEXT NOT NULL, type SMALLINT NOT NULL, status SMALLINT NOT NULL, send_date DATETIME NOT NULL COMMENT '(DC2Type:datetime)', updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', INDEX IDX_159BBFE9727ACA70 (parent_id), INDEX idx_social_post_sender (sender_id), INDEX idx_social_post_user (user_receiver_id), INDEX idx_social_post_group (group_receiver_id), INDEX idx_social_post_type (type), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC"); - $sql = "INSERT INTO social_post (id, sender_id, user_receiver_id, group_receiver_id, parent_id, content, type, status, send_date, updated_at) + $sql = 'INSERT INTO social_post (id, sender_id, user_receiver_id, group_receiver_id, parent_id, content, type, status, send_date, updated_at) SELECT DISTINCT m.id, m.user_sender_id, m.user_receiver_id, @@ -194,15 +194,15 @@ final class Version20200821224242 extends AbstractMigrationChamilo m.update_date FROM message m INNER JOIN message_feedback mf ON m.id = mf.message_id - WHERE m.msg_type IN (1, 8, 9, 10, 13)"; + WHERE m.msg_type IN (1, 8, 9, 10, 13)'; $this->addSql($sql); $this->addSql('DELETE FROM social_post WHERE parent_id NOT IN (SELECT id FROM social_post)'); - $this->addSql("ALTER TABLE social_post ADD CONSTRAINT FK_159BBFE9F624B39D FOREIGN KEY (sender_id) REFERENCES user (id)"); - $this->addSql("ALTER TABLE social_post ADD CONSTRAINT FK_159BBFE964482423 FOREIGN KEY (user_receiver_id) REFERENCES user (id)"); - $this->addSql("ALTER TABLE social_post ADD CONSTRAINT FK_159BBFE9E8EBF277 FOREIGN KEY (group_receiver_id) REFERENCES usergroup (id) ON DELETE CASCADE"); - $this->addSql("ALTER TABLE social_post ADD CONSTRAINT FK_159BBFE9727ACA70 FOREIGN KEY (parent_id) REFERENCES social_post (id) ON DELETE CASCADE"); + $this->addSql('ALTER TABLE social_post ADD CONSTRAINT FK_159BBFE9F624B39D FOREIGN KEY (sender_id) REFERENCES user (id)'); + $this->addSql('ALTER TABLE social_post ADD CONSTRAINT FK_159BBFE964482423 FOREIGN KEY (user_receiver_id) REFERENCES user (id)'); + $this->addSql('ALTER TABLE social_post ADD CONSTRAINT FK_159BBFE9E8EBF277 FOREIGN KEY (group_receiver_id) REFERENCES usergroup (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE social_post ADD CONSTRAINT FK_159BBFE9727ACA70 FOREIGN KEY (parent_id) REFERENCES social_post (id) ON DELETE CASCADE'); if ($schema->hasTable('message_feedback')) { $this->addSql('DELETE FROM message_feedback WHERE user_id IS NULL OR user_id = 0'); @@ -227,7 +227,7 @@ final class Version20200821224242 extends AbstractMigrationChamilo $this->addSql('ALTER TABLE message_feedback CHANGE message_id social_post_id BIGINT NOT NULL'); $this->addSql('RENAME TABLE message_feedback TO social_post_feedback'); - $this->addSql("DELETE FROM social_post_feedback WHERE social_post_id NOT IN (SELECT id FROM social_post)"); + $this->addSql('DELETE FROM social_post_feedback WHERE social_post_id NOT IN (SELECT id FROM social_post)'); } else { $this->addSql("CREATE TABLE social_post_feedback (id BIGINT AUTO_INCREMENT NOT NULL, social_post_id BIGINT NOT NULL, user_id INT NOT NULL, liked TINYINT(1) DEFAULT '0' NOT NULL, disliked TINYINT(1) DEFAULT '0' NOT NULL, updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', INDEX IDX_DB7E436DC4F2D6B1 (social_post_id), INDEX IDX_DB7E436DA76ED395 (user_id), INDEX idx_social_post_uid_spid (social_post_id, user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC"); } diff --git a/src/CoreBundle/Repository/SocialPostRepository.php b/src/CoreBundle/Repository/SocialPostRepository.php index 40dd832bc5..905266cdc4 100644 --- a/src/CoreBundle/Repository/SocialPostRepository.php +++ b/src/CoreBundle/Repository/SocialPostRepository.php @@ -1,5 +1,7 @@ getEntityManager(); $em->persist($post); @@ -30,7 +32,7 @@ class SocialPostRepository extends ServiceEntityRepository * @throws OptimisticLockException * @throws ORMException */ - public function delete(SocialPost $post) + public function delete(SocialPost $post): void { $em = $this->getEntityManager(); $em->remove($post); diff --git a/tests/CoreBundle/Repository/SocialPostRepositoryTest.php b/tests/CoreBundle/Repository/SocialPostRepositoryTest.php index f16d017dd8..a1ac7f3e5c 100644 --- a/tests/CoreBundle/Repository/SocialPostRepositoryTest.php +++ b/tests/CoreBundle/Repository/SocialPostRepositoryTest.php @@ -30,7 +30,8 @@ class SocialPostRepositoryTest extends AbstractApiTest $em = $this->getEntityManager(); $socialPostRepo = self::getContainer() - ->get(SocialPostRepository::class); + ->get(SocialPostRepository::class) + ; $socialPostFeedbackRepo = $em->getRepository(SocialPostFeedback::class); $admin = $this->getUser('admin'); @@ -39,7 +40,8 @@ class SocialPostRepositoryTest extends AbstractApiTest $post = (new SocialPost()) ->setContent('content') ->setSender($admin) - ->setUserReceiver($testUser); + ->setUserReceiver($testUser) + ; $socialPostRepo->update($post); // 1. Message exists in the inbox. @@ -50,7 +52,8 @@ class SocialPostRepositoryTest extends AbstractApiTest ->setUser($testUser) ->setUpdatedAt(new DateTime()) ->setDisliked(true) - ->setLiked(true); + ->setLiked(true) + ; $em->persist($feedback); $em->flush(); $em->clear();