protected function import_csv() { set_time_limit(0); $file_name = dirname(APPLICATION_PATH) . '/files/price.csv'; if (file_exists($file_name)) { $Price = new Price(); $f = fopen($file_name, 'r'); echo getdate() . "<BR>"; while (!feof($f)) { $s = fgets($f); $s = trim($s); if ($s != '') { $ar = split(';', $s); if ($ar[1] == '2') { $data = array('id_product' => $ar[0], 'exists_type' => $ar[1], 'price' => $ar[2]); if (!($er = $Price->add($data))) { print_r($data); print_r('error=' . $er); exit; } } } } echo getdate(); fclose($f); } else { echo 'file not found'; } }
public function testShouldBeImmutable() { $p1ArrayMoney = ['EUR' => 100, 'GBP' => 101]; $p2ArrayMoney = ['EUR' => 100]; $p2ArrayCurrency = ['EUR/GBP 1.100']; $price1 = new Price($p1ArrayMoney); $price2 = new Price($p2ArrayMoney, $p2ArrayCurrency); $priceAdd = $price1->add($price2); $priceMul = $price1->multiply(2); $this->assertEquals(new Price($p1ArrayMoney), $price1); $this->assertEquals(new Price($p2ArrayMoney, $p2ArrayCurrency), $price2); }