/** * @param $strContent * @param int $intHeight * @return string * @throws \Exception */ public static function generate($strContent, $intHeight = 35) { // Handle height if (!is_numeric($intHeight)) { $intHeight = 35; } $strPath = 'barcode/cache'; $strAbsolutePath = \System::getContainer()->get('kernel')->getRootDir() . '/../web/' . $strPath . '/'; $objBarcode = new Base1DBarcode(); $objBarcode->savePath = $strAbsolutePath; $strAbsoluteFilePath = $objBarcode->getBarcodePNGPath($strContent, 'C128', 1.5, $intHeight); $strFile = substr($strAbsoluteFilePath, strlen($strAbsolutePath)); return $strPath . '/' . $strFile; }
/** * PHARMA2T Barcode PNG rendering test * * @covers BG\BarcodeBundle\Util\Base1DBarcode::getBarcodePNGPath(); */ public function testPHARMA2TGetBarcodePNGPath() { $d1 = new barCode(); $d1->savePath = '/tmp/'; $bcPathAbs = $d1->getBarcodePNGPath(self::C_BC_DEFAULT, 'PHARMA2T', self::C_BC_1D_WIDTH, self::C_BC_1D_HEIGHT); // print_r(filesize($bcPathAbs)); if (function_exists('imagecreate')) { $checkCondition = file_exists($bcPathAbs) && filesize($bcPathAbs) === 118; } else { $checkCondition = file_exists($bcPathAbs) ? true : false; } unlink($bcPathAbs); $this->assertTrue($checkCondition); }