Example #1
0
 public function setUp()
 {
     $env = Env::getInstance();
     if (!$env instanceof SilexEnv) {
         $this->markTestSkipped('Silex session storage can only be tested in a Silex environment.');
     }
     $this->session = new Session(new MockArraySessionStorage());
     $this->access = new Access($this->session);
 }
Example #2
0
 public function setUp()
 {
     $env = Env::getInstance();
     if (!$env instanceof ZfEnv) {
         $this->markTestSkipped('Zend session storage can only be tested in a Zend Framework 1 environment.');
     }
     Zend_Session::$_unitTestEnabled = true;
     Zend_Session::start();
     $this->namespace = new Zend_Session_Namespace('test');
     $this->storage = new Storage($this->namespace);
 }
 public function setUp()
 {
     if (Env::getInstance() instanceof Zf1Env) {
         $this->markTestSkipped('Zend Framework 1 environment does not support ComponentAbstract.');
     }
     $testPimple = new \Pimple();
     $testPimple['dewdrop-request'] = new Request();
     require_once __DIR__ . '/../test-components/animals/Component.php';
     $this->component = new \DewdropTest\Admin\Animals\Component($testPimple);
     $this->request = $this->component->getRequest();
     $this->paths = $this->component->getPaths();
     $this->isWp = $this->paths->isWp();
 }
Example #4
0
 /**
  * @param array $methodsToMock
  * @return \PHPUnit_Framework_MockObject_MockObject|\Dewdrop\Cli\Command\Dbdeploy
  */
 private function getMockCommand(array $methodsToMock = array())
 {
     /* @var $command \PHPUnit_Framework_MockObject_MockObject|\Dewdrop\Cli\Command\Dbdeploy */
     $command = $this->getMock('\\Dewdrop\\Cli\\Command\\Dbdeploy', count($methodsToMock) ? $methodsToMock : array('abort'), array($this->runner, $this->renderer));
     $env = Env::getInstance();
     $dbTypeSuffix = 'pgsql';
     if ($env instanceof WpEnv) {
         $dbTypeSuffix = 'mysql';
     }
     $command->overrideChangesetPath($env->getProjectNoun(), $this->paths->getDewdropLib() . '/tests/Dewdrop/Cli/Command/dbdeploy-test/plugin/' . $dbTypeSuffix);
     $command->overrideChangesetPath('dewdrop-test', $this->paths->getDewdropLib() . '/tests/Dewdrop/Cli/Command/dbdeploy-test/dewdrop-test/' . $dbTypeSuffix);
     $command->overrideChangesetPath('dewdrop-core', $this->paths->getDewdropLib() . '/tests/Dewdrop/Cli/Command/dbdeploy-test/dewdrop-core/');
     $command->overrideChangelogTableName('dewdrop_test_dbdeploy_changelog');
     return $command;
 }
Example #5
0
 /**
  * Setup the default changesets.  If a changeset has already been configured with a given
  * name, the default will not be applied.  This is done primarily to allow the
  * overrideChangesetPath() method to swap out the default paths during testing.
  *
  * @return void
  */
 protected function initChangesets()
 {
     $mainChangesetName = Env::getInstance()->getProjectNoun();
     $defaultChangesets = ['dewdrop-core' => $this->paths->getDewdropLib() . '/db/' . $this->dbType, $mainChangesetName => $this->paths->getPluginRoot() . '/db', 'dewdrop-test' => $this->paths->getDewdropLib() . '/tests/db/' . $this->dbType];
     if (Pimple::hasResource('dbdeploy.changesets')) {
         $defaultChangesets = array_merge($defaultChangesets, Pimple::getResource('dbdeploy.changesets'));
     }
     foreach ($defaultChangesets as $name => $path) {
         if (!array_key_exists($name, $this->changesets)) {
             $this->changesets[$name] = $path;
         }
     }
 }
Example #6
0
 /**
  * Optionally point this class at a non-standard configuration file path.
  *
  * @param string $file
  */
 public function __construct(EnvInterface $env = null, $file = null)
 {
     $env = $env ?: Env::getInstance();
     $this->data = $env->getConfigData($file);
 }
 /**
  * When Dewdrop was WP-only, the primary dbdeploy changeset was called "plugin".
  * We now support several environments and calling projects "plugins" doesn't
  * make sense in some cases.  To reflect this, the EnvInterface->getProjectNoun()
  * method was added.  Because existing projects had "plugin" in the dbdeploy_changelog
  * already, this method is in place to update any of those records on older
  * projects.
  */
 public function maintainBackwardCompatibilityOnPrimaryChangeset()
 {
     $primaryChangesetName = Env::getInstance()->getProjectNoun();
     if ('plugin' !== $primaryChangesetName) {
         $this->dbAdapter->update($this->tableName, ['delta_set' => $primaryChangesetName], "delta_set = 'plugin'");
     }
 }
Example #8
0
 public function testCanInstantiateWithNoArgsAndUseGlobalAccessResource()
 {
     $env = Env::getInstance();
     if ($env instanceof ZfEnv) {
         Zend_Session::$_unitTestEnabled = true;
     }
     $session = new Session();
     $globalStorage = Pimple::getResource('session.access');
     $this->assertEquals($session->getAccessObject(), $globalStorage);
 }
Example #9
0
<?php

require_once __DIR__ . '/../../../autoload.php';
use Dewdrop\Env;
Env::bootstrapCli();
$env = Env::getInstance();
$env->initializeCli();
$GLOBALS['dewdrop_pimple'] = \Dewdrop\Bootstrap\Detector::findPimple();