productRepository = $this->createMock(ProductRepository::class); $this->warehouseRepository = $this->createMock(WarehouseRepository::class); $this->stockRepository = $this->createMock(StockRepository::class); $this->logger = $this->createMock(LoggerInterface::class); $this->rootPath = '/path/to/root'; $this->hiltesImport = new HiltesImport( $this->productRepository, $this->warehouseRepository, $this->stockRepository, $this->logger, $this->rootPath ); } public function testStartImportWithNoFiles() { $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('No Files to Import'); $this->hiltesImport->startImport(); } public function testStartImportWithFilesButNoData() { $this->productRepository->expects($this->once()) ->method('saveAll') ->willReturn([]); $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('No Files'); $this->hiltesImport->startImport(true); } public function testGetFilesWithNoResults() { #$result = $this->hiltesImport->getFiles(); # $this->assertFalse($result); } public function testProcessLineWithEmptyData() { $this->logger->expects($this->once()) ->method('warning') ->with($this->equalTo('Keine Daten in Zeile')); #$this->hiltesImport->processLine('', 'stock'); } public function testCheckWarehouseNameWithNoWarehouse() { $this->warehouseRepository->expects($this->once()) ->method('findOneBy') ->with($this->equalTo(['name' => '1'])) ->willReturn(null); $this->warehouseRepository->expects($this->once()) ->method('save') ->willReturn(1); $this->warehouseRepository->expects($this->once()) ->method('findOneBy') ->with($this->equalTo(['id' => 1])) ->willReturn(new Warehouse()); # $result = $this->hiltesImport->checkWarehouseName('01'); #$this->assertInstanceOf(Warehouse::class, $result); } public function testCheckProductWithNoProduct() { $this->productRepository->expects($this->once()) ->method('findOneBy') ->with($this->equalTo(['gtin' => '1234567890123'])) ->willReturn(null); $this->productRepository->expects($this->once()) ->method('save') ->willReturn(1); # $result = $this->hiltesImport->checkProduct('1234567890123'); # $this->assertEquals(1, $result); } }