/**
  * Setup services for tests.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->storageManager = new MysqlStorageManager($this->getConnection(), self::TABLE_NAME);
     $this->storageManager->setContainer($this->getServiceContainer());
     $this->syncStorage = new SyncStorage($this->storageManager);
     $this->extractor = new PassthroughExtractor();
     $this->extractor->setContainer($this->getServiceContainer());
     $this->extractor->setStorageFacility($this->syncStorage);
     $shops = $this->getServiceContainer()->getParameter('ongr_connections.shops');
     foreach ($shops as $shop) {
         $this->shopIds[] = $shop['shop_id'];
         $this->storageManager->createStorage($shop['shop_id']);
     }
 }
 /**
  * Set-up services before each test.
  */
 protected function setUp()
 {
     $this->connection = $this->getMockBuilder('\\Doctrine\\DBAL\\Connection')->disableOriginalConstructor()->getMock();
     $this->service = new MysqlStorageManager($this->connection, self::TABLE_NAME);
     $this->container = $this->getMockForAbstractClass('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $this->container->expects($this->any())->method('getParameter')->will($this->returnCallback(function ($parameter) {
         if ($parameter == 'ongr_connections.active_shop') {
             return 'test_default';
         } elseif ($parameter == 'ongr_connections.shops') {
             return ['test_default' => ['shop_id' => 0], 'test' => ['shop_id' => 1], 'test2' => ['shop_id' => 2], 'test12345' => ['shop_id' => 12345], 'string_id' => ['shop_id' => 'string'], 'inject' => ['shop_id' => '\';inject']];
         }
         return null;
     }));
     $this->service->setContainer($this->container);
 }
 /**
  * Test possible SQL injection.
  */
 public function testInvalidTableName()
 {
     $tableName = ';SQL injection here';
     $this->setExpectedException('\\InvalidArgumentException', "Invalid table name specified: \"{$tableName}\"");
     $service = new MysqlStorageManager($this->getConnection(), $tableName);
     $service->setContainer($this->getServiceContainer());
     $service->getTableName();
 }