/** * @author Andreas Glaser * * @todo Complete this method! */ public function testAnonymousLeadSubmissionToCityLevel() { $courseClasses = [null, 1, 2]; $response = $this->leadPubRes->create(['lead' => ['userCreatedBy' => ['email' => $this->faker->safeEmail, 'profile' => ['firstName' => $this->faker->firstName, 'lastName' => $this->faker->lastName, 'phone' => $this->faker->phoneNumber, 'country' => ['id' => 1], 'city' => ['id' => 1]]], 'durationWeeks' => rand(4, 56), 'studentNote' => $this->faker->sentence(), 'countryDest' => ['id' => 1], 'cityDest' => ['id' => 1], 'courseType' => ['id' => 1], 'courseClass' => ['id' => $courseClasses[array_rand($courseClasses)]], 'leadDateStart' => ['id' => rand(1, 4)]]]); $payload = $response->getBodyDecoded(); $this->assertEquals(201, $response->getStatusCode()); $this->assertTrue(ValueHelper::isInteger($payload['id'])); $this->assertTrue(ValueHelper::isDateTime($payload['created_at'])); }
/** * Tries to format given input. * * @param string|\DateTime $dateTime * @param string $format * @param null $null * * @return null|string * @author Andreas Glaser */ public static function formatOrNull($dateTime, $format = 'Y-m-d H:i:s', $null = null) { if ($dateTime instanceof \DateTime) { return $dateTime->format($format); } elseif (ValueHelper::isDateTime($dateTime)) { return static::stringToDateTime($dateTime)->format($format); } else { return $null; } }
/** * @author Andreas Glaser */ public function testIsDateTime() { $this->assertTrue(ValueHelper::isDateTime('2015-03-23')); $this->assertTrue(ValueHelper::isDateTime('2015-03-23 22:21')); $this->assertTrue(ValueHelper::isDateTime('5pm')); $this->assertTrue(ValueHelper::isDateTime('+8 Weeks')); $this->assertFalse(ValueHelper::isDateTime('2015-13-23 22:21')); $this->assertFalse(ValueHelper::isDateTime('2015-12-23 25:21')); $this->assertFalse(ValueHelper::isDateTime('N/A')); $this->assertFalse(ValueHelper::isDateTime(null)); $this->assertFalse(ValueHelper::isDateTime('')); }