privatebinWithDb.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. require_once 'privatebin.php';
  3. class privatebinWithDbTest extends privatebinTest
  4. {
  5. private $_options = array(
  6. 'dsn' => 'sqlite:../data/tst.sq3',
  7. 'usr' => null,
  8. 'pwd' => null,
  9. 'opt' => array(
  10. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  11. PDO::ATTR_PERSISTENT => true
  12. ),
  13. );
  14. public function setUp()
  15. {
  16. /* Setup Routine */
  17. $this->_model = privatebin_db::getInstance($this->_options);
  18. serversalt::setPath(PATH . 'data');
  19. $this->reset();
  20. }
  21. public function tearDown()
  22. {
  23. /* Tear Down Routine */
  24. parent::tearDown();
  25. @unlink('../data/tst.sq3');
  26. }
  27. public function reset()
  28. {
  29. parent::reset();
  30. // but then inject a db config
  31. $options = parse_ini_file(CONF, true);
  32. $options['model'] = array(
  33. 'class' => 'privatebin_db',
  34. );
  35. $options['model_options'] = $this->_options;
  36. helper::confBackup();
  37. helper::createIniFile(CONF, $options);
  38. }
  39. }