public function testConfigOverrides() { $config = (require __DIR__ . '/data/beaucallongthrottle.local.php'); $config = $config['beaucallongthrottle']['BeaucalLongThrottle\\Adapter\\DbMultiple']; unset($config['options_class']); $options = new DbMultipleAdapterOptions($config); $this->assertEquals('use_transactions_another', $options->getUseTransactions()); $this->assertEquals('db_adapter_class_another', $options->getDbAdapterClass()); $this->assertEquals('db_table_another', $options->getDbTable()); $this->assertEquals('db_date_time_format_another', $options->getDbDateTimeFormat()); $this->assertEquals('clear_all_is_cheap_another', $options->getClearAllIsCheap()); $this->assertEquals(['regex_counts_another' => 99], $options->getRegexCounts()); }
/** * @expectedException BeaucalLongThrottle\Exception\OptionException * @expectedExceptionMessage regex_counts pattern BAD REGEX is invalid */ public function testRegexCountsInvalidPattern() { $dbOptions = new ThrottleDbAdapterOptions(); $dbOptions->setRegexCounts(['BAD REGEX' => 1]); $gateway = new TableGateway($dbOptions->getDbTable(), $this->getAdapter()); $throttleDbAdapter = new ThrottleDbMultipleAdapter($gateway, $dbOptions, new LockHandleFactory()); $throttleOptions = new ThrottleOptions(); $throttle = new Throttle($throttleDbAdapter, $throttleOptions); $throttle->takeLock('ok', new DateTimeUnit(6, 'days')); }