/** * @expectedException \InvalidArgumentException * @expectedExceptionMessageRegExp %s must be an instance of \GeoIp2\Database\Reader. */ public function testCreateWithWrongReaderClass() { $dbCode = 'some_db_code'; $dbPath = 'some_absolute_db_path'; $data = ['filename' => $dbPath, 'locales' => ['en']]; $this->database->expects($this->once())->method('isDbAvailable')->with($dbCode)->willReturn(true); $this->database->expects($this->once())->method('getDbPath')->with($dbCode, true)->willReturn($dbPath); $reader = $this->getMockBuilder('GeoIp2\\Database\\WrongReader')->disableOriginalConstructor()->getMock(); $this->objectManager->expects($this->once())->method('create')->with($this->instanceName, $data)->willReturn($reader); $this->readerFactory->create($dbCode); }
/** * @param string $dbCode * @param string $dbPath * @param string $dbArchPath * @param string $dbUrl * @param string $dbContent */ protected function configureDownload($dbCode, $dbPath, $dbArchPath, $dbUrl, $dbContent) { $this->updater->expects($this->once())->method('loadDbContent')->with($dbUrl)->willReturn($dbContent); $this->database->expects($this->atLeastOnce())->method('getDbPath')->with($dbCode)->willReturn($dbPath); $this->directory->expects($this->atLeastOnce())->method('writeFile')->with($dbArchPath, $dbContent); }