Exemple #1
0
 /**
  * @return \GeoIp2\Database\Reader
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function getReader()
 {
     if (null === $this->reader) {
         $this->reader = $this->readerFactory->create('city');
     }
     return $this->reader;
 }
 /**
  * @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);
 }
 /**
  * @return \GeoIp2\Database\Reader|\PHPUnit_Framework_MockObject_MockObject
  */
 protected function configureReaderFactory()
 {
     $reader = $this->getMockBuilder('GeoIp2\\Database\\Reader')->disableOriginalConstructor()->getMock();
     $this->readerFactory->expects($this->once())->method('create')->willReturn($reader);
     return $reader;
 }