示例#1
0
 /**
  * @test
  */
 public function shouldBeAbleToPopulateByJSON()
 {
     // given
     $car = new Car(1);
     $this->assertEquals(1, $car->getId());
     $json = $car;
     $array = json_decode($json, true);
     // when
     $array['brand'] = 'BMW';
     $car->setValues($array);
     $car->commit();
     $newCar = new Car(1);
     // then
     $this->assertEquals('BMW', $newCar->getBrand());
 }
示例#2
0
     }
 } else {
     $presscontact->setName($_POST["presscontactname"]);
     $presscontact->setHTMLContent(utf8_encode($_POST["presscontacthtml"]));
     $presscontact->setCarBrandId($_POST["carbrand"]);
     $presscontactinsert = $blPressContact->insertPressContact($presscontact);
     if (is_numeric($presscontactinsert)) {
         $car->setPressContactId($presscontactinsert);
         $errorpresscontact["success"] = "Press contact saved!";
     } else {
         $car->setPressContactId(0);
         $errorpresscontact = $presscontactinsert;
     }
 }
 //check if car is set
 if ($car->getId() != 0) {
     $carprev = $blCar->getCar($_POST["carid"]);
     $car->setFolderName($carprev->getFolderName());
     $car->setDateAdded($carprev->getDateAdded());
     $car->setDateApproved($carprev->getDateApproved());
     $car->setUserIdAdded($carprev->getUserIdAdded());
     $car->setUserIdApproved($carprev->getUserIdApproved());
     $car->setLRClicks($carprev->getLRClicks());
     $car->setHRClicks($carprev->getHRClicks());
     $car->setViews($carprev->getViews());
     $car->setState($carprev->getState());
     $car->setDefaultPictureId($carprev->getDefaultPictureId());
     $error = $blCar->updateCar($car);
 } else {
     $car->setState('Design');
     $car->setFolderName(uniqid());
 /**
  * @test
  */
 public function shouldBeAbleToMerge()
 {
     // given
     $car = new Car();
     $car->deleteTableData()->yesImSure();
     $car->setBrand("Volkswagen");
     $car->setModel("Polo 1.6 TDI");
     $car->commit();
     $this->addCarProperty($car->getId(), "Hk", "75");
     $this->addCarProperty($car->getId(), "Mileage", "42000");
     $this->addCarProperty($car->getId(), "Year", "2010");
     $cars = new CarsWithProperties();
     // when
     $values = $cars->getValues();
     $firstCar = $values[0];
     // then
     $this->assertNotNull($firstCar['properties']);
 }
示例#4
0
 public function addCarToStatistics(Car $car)
 {
     if (array_key_exists($car->getId(), $this->statisticsCars)) {
         $this->statisticsCars[$car->getId()]->increment();
     } else {
         $this->statisticsCars[$car->getId()] = new StatCountTuple($car);
     }
 }
 /**
  * @test
  */
 public function testShouldBeAbleToGetRecordById()
 {
     $car = new Car();
     $car->drop()->yesImSure();
     $car->createTable();
     // when
     $car = new Car(1);
     // then
     $this->assertEquals('Opel', $car->getBrand());
     $this->assertEquals('1', $car->getId());
 }