Пример #1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $availableDrivers = ['mysql', 'sqlite', 'pgsql'];
     if (null !== ($driver = $input->getArgument('driver'))) {
         if (!in_array($driver, $availableDrivers)) {
             $output->writeln(sprintf('Driver "%s" is not available.', $driver));
             $driver = null;
         }
     }
     if (null === $driver) {
         $questionHelper = new QuestionHelper();
         $driver = $questionHelper->ask($input, $output, new ChoiceQuestion('Which database driver do you use ?', $availableDrivers));
     }
     $aclSchema = new AclSchema(['permissions_table_name' => $input->getOption('permissions_table_name'), 'requester_column_length' => $input->getOption('requester_column_length'), 'resource_column_length' => $input->getOption('resource_column_length')]);
     $output->writeln('Here is the "create query" for <comment>' . $driver . '</comment>:' . PHP_EOL);
     $output->writeln('<info>' . $aclSchema->getCreateQuery('sqlite') . '</info>' . PHP_EOL);
 }
Пример #2
0
 protected function setUp()
 {
     if (!in_array('sqlite', PDO::getAvailableDrivers())) {
         $this->markTestSkipped('This test requires SQLite support in your environment.');
     }
     $this->aclSchema = new AclSchema();
     $this->pdo = new PDO('sqlite:' . self::SQLITE_PATH, null, null, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
     try {
         $this->pdo->prepare('DROP TABLE acl_permissions')->execute();
     } catch (\PDOException $e) {
     }
     $create = $this->aclSchema->getCreateQuery('sqlite');
     $this->pdo->prepare($create)->execute();
     $this->aliceRequester = new Requester('alice');
     $this->bobRequester = new Requester('bob');
     $this->malloryRequester = new Requester('mallory');
     $this->fooResource = new Resource('foo');
     $this->barResource = new Resource('bar');
     if ($this->pdo->query('SELECT COUNT(*) FROM acl_permissions')->fetchColumn() > 0) {
         throw new \Exception('sqlite database must be reset before each test');
     }
 }