Example #1
0
 /**
  * @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']));
 }
Example #2
0
 /**
  * @param $currencyArray
  *
  * @author Andreas Glaser
  */
 private function assertCurrencyArray($currencyArray)
 {
     $this->assertArrayKeyExistsNotEmpty('id', $currencyArray);
     $this->assertArrayKeyExistsNotEmpty('slug', $currencyArray);
     $this->assertArrayKeyExistsNotEmpty('name', $currencyArray);
     $this->assertArrayKeyExistsNotEmpty('iso3', $currencyArray);
     $this->assertArrayKeyExistsNotEmpty('symbol', $currencyArray);
     $this->assertTrue(ValueHelper::isInteger($currencyArray['id']));
     $this->assertRegExp('/^[a-z0-9-]+$/', $currencyArray['slug']);
     $this->assertRegExp('/^[A-Z0-9-]+$/', $currencyArray['iso3']);
 }
Example #3
0
 /**
  * @param $cityArray
  *
  * @author Andreas Glaser
  */
 private function assertCityArray($cityArray)
 {
     $this->assertArrayKeyExistsNotEmpty('id', $cityArray);
     $this->assertArrayKeyExistsNotEmpty('slug', $cityArray);
     $this->assertArrayKeyExistsNotEmpty('name', $cityArray);
     $this->assertArrayKeyExistsNotEmpty('coordinate', $cityArray);
     $this->assertTrue(ValueHelper::isInteger($cityArray['id']));
     $this->assertRegExp('/^[a-z0-9-]+$/', $cityArray['slug']);
     $this->assertNotEmpty($cityArray['name']);
     $this->assertNotEmpty($cityArray['coordinate']);
 }
Example #4
0
 /**
  * Response constructor.
  *
  * @param $statusCode
  * @param $body
  * @param $headers
  *
  * @author Andreas Glaser
  */
 public function __construct($statusCode, $body, $headers)
 {
     $this->statusCode = $statusCode;
     // guess if request succeeded
     if (ValueHelper::isInteger($this->statusCode) && $this->statusCode >= 200 && $this->statusCode < 300) {
         $this->setIsSuccess(true);
     }
     $this->bodyRaw = $body;
     $this->bodyDecoded = json_decode($body, true);
     $this->headers = $headers;
 }
 /**
  * @author Andreas Glaser
  */
 public function testIsInteger()
 {
     $this->assertTrue(ValueHelper::isInteger(1));
     $this->assertTrue(ValueHelper::isInteger('1'));
     $this->assertFalse(ValueHelper::isInteger(1.3));
     $this->assertFalse(ValueHelper::isInteger('1.0'));
     $this->assertFalse(ValueHelper::isInteger(''));
     $this->assertFalse(ValueHelper::isInteger(null));
     $this->assertFalse(ValueHelper::isInteger([]));
     $this->assertFalse(ValueHelper::isInteger(false));
     $this->assertFalse(ValueHelper::isInteger(true));
 }
Example #6
0
 /**
  * @param $courseTypeArray
  *
  * @author Andreas Glaser
  */
 private function assertCourseTypeArray($courseTypeArray)
 {
     $this->assertArrayHasKey('id', $courseTypeArray);
     $this->assertArrayHasKey('slug', $courseTypeArray);
     $this->assertArrayHasKey('name', $courseTypeArray);
     $this->assertArrayHasKey('description_short', $courseTypeArray);
     $this->assertArrayHasKey('description_long', $courseTypeArray);
     $this->assertArrayHasKey('image', $courseTypeArray);
     $this->assertArrayHasKey('parent', $courseTypeArray);
     $this->assertTrue(ValueHelper::isInteger($courseTypeArray['id']));
     $this->assertNotEmpty($courseTypeArray['slug']);
     $this->assertRegExp('/^[a-z0-9-]+$/', $courseTypeArray['slug']);
     $this->assertNotEmpty($courseTypeArray['name']);
     $this->assertNotEmpty($courseTypeArray['description_short']);
     $this->assertNotEmpty($courseTypeArray['description_long']);
     $this->assertNotEmpty($courseTypeArray['image']);
 }
Example #7
0
 /**
  * @param $countryArray
  *
  * @author Andreas Glaser
  */
 private function assertCountryArray($countryArray)
 {
     $this->assertArrayHasKey('id', $countryArray);
     $this->assertArrayHasKey('slug', $countryArray);
     $this->assertArrayHasKey('name', $countryArray);
     $this->assertArrayHasKey('iso2', $countryArray);
     $this->assertArrayHasKey('iso3', $countryArray);
     $this->assertArrayHasKey('phone_country_code', $countryArray);
     $this->assertArrayHasKey('currency', $countryArray);
     $this->assertArrayHasKey('coordinate', $countryArray);
     $this->assertTrue(ValueHelper::isInteger($countryArray['id']));
     $this->assertNotEmpty($countryArray['slug']);
     $this->assertRegExp('/^[a-z0-9-]+$/', $countryArray['slug']);
     $this->assertNotEmpty($countryArray['name']);
     $this->assertNotEmpty($countryArray['iso2']);
     $this->assertNotEmpty($countryArray['iso3']);
     $this->assertNotEmpty($countryArray['phone_country_code']);
     $this->assertNotEmpty($countryArray['currency']);
     $this->assertNotEmpty($countryArray['coordinate']);
 }