From eb9130f920aab057957bf72ab0a471ad42541b11 Mon Sep 17 00:00:00 2001 From: Stakovicz Date: Wed, 23 Oct 2024 20:44:21 +0200 Subject: [PATCH] afup#1437 fix test --- sources/AppBundle/Event/Model/Speaker.php | 8 ++++++-- sources/AppBundle/Event/Model/Talk.php | 13 ++++++------- sources/AppBundle/Payment/Paybox.php | 5 +++-- .../AppBundle/Indexation/Talks/Transformer.php | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/sources/AppBundle/Event/Model/Speaker.php b/sources/AppBundle/Event/Model/Speaker.php index d79573584..7677ff886 100644 --- a/sources/AppBundle/Event/Model/Speaker.php +++ b/sources/AppBundle/Event/Model/Speaker.php @@ -260,7 +260,7 @@ public function setLastname($lastname) */ public function getLabel() { - return $this->getFirstname() . " " . mb_strtoupper($this->getLastname()); + return $this->getFirstname() . " " . ($this->getLastname() ? mb_strtoupper($this->getLastname()) : null); } /** @@ -413,10 +413,14 @@ public function getMastodon() public function getCleanedTwitter() { $twitter = $this->getTwitter(); + if (!$twitter) { + return null; + } + $twitter = trim($twitter, '@'); $twitter = preg_replace('!^https?://twitter.com/!', '', $twitter); - if (0 === strlen(trim($twitter))) { + if (!$twitter) { return null; } diff --git a/sources/AppBundle/Event/Model/Talk.php b/sources/AppBundle/Event/Model/Talk.php index fc86bac24..26be09e95 100644 --- a/sources/AppBundle/Event/Model/Talk.php +++ b/sources/AppBundle/Event/Model/Talk.php @@ -430,7 +430,7 @@ public function setNeedsMentoring($needsMentoring) */ public function getYoutubeId() { - if (0 === strlen($this->youTubeId)) { + if (empty($this->youTubeId)) { return null; } @@ -475,7 +475,7 @@ public function getYoutubeUrl() */ public function getSlidesUrl() { - if (0 === strlen($this->slidesUrl)) { + if (empty($this->slidesUrl)) { return null; } @@ -591,7 +591,7 @@ public function getOpenfeedbackUrl() */ public function getBlogPostUrl() { - if (0 === strlen($this->blogPostUrl)) { + if (empty($this->blogPostUrl)) { return null; } @@ -624,7 +624,7 @@ public function hasBlogPostUrl() */ public function getInterviewUrl() { - if (0 === strlen($this->interviewUrl)) { + if (empty($this->interviewUrl)) { return null; } @@ -895,12 +895,11 @@ public function getTweetsHasArray() $explodedTweets = explode(PHP_EOL, $this->getTweets()); $returnedTweets = []; foreach ($explodedTweets as $explodedTweet) { - $explodedTweet = trim($explodedTweet); - if (0 === strlen($explodedTweet)) { + if (empty($explodedTweet)) { continue; } - $returnedTweets[] = $explodedTweet; + $returnedTweets[] = trim($explodedTweet); } return $returnedTweets; diff --git a/sources/AppBundle/Payment/Paybox.php b/sources/AppBundle/Payment/Paybox.php index ff406d10a..0d3a186ee 100644 --- a/sources/AppBundle/Payment/Paybox.php +++ b/sources/AppBundle/Payment/Paybox.php @@ -167,12 +167,13 @@ private function generatePbxBiling(PayboxBilling $payboxBilling) private function preparePbxBillingValue($value, $maxLength, $default) { - $value = trim($value); + $value = $value ? trim($value) : ''; - if (0 === strlen($value)) { + if ($value === '') { $value = $default; } + $value = (string) $value; if (strlen($value) > $maxLength) { $value = substr($value, 0, $maxLength); } diff --git a/tests/units/AppBundle/Indexation/Talks/Transformer.php b/tests/units/AppBundle/Indexation/Talks/Transformer.php index ad9d97ebc..a31bec0f5 100644 --- a/tests/units/AppBundle/Indexation/Talks/Transformer.php +++ b/tests/units/AppBundle/Indexation/Talks/Transformer.php @@ -72,7 +72,7 @@ public function testTransform() ->then ->array($transformer->transform($planning, $talk, $event, $speakers)) ->isEqualTo([ - 'planning_id' => "266", + 'planning_id' => 266, 'talk_id' => 1007, 'url_key' => '1007-utiliser-postgresql-en-2014', 'title' => "Utiliser PostgreSQL en 2014",