コード例 #1
0
 /**
  * Test a failing deactivate
  *
  * @return void
  * @author Dan Cox
  */
 public function test_deactivateFail()
 {
     $this->modules->shouldReceive('deactivate')->with('test')->andThrow("Exception");
     $CT = new CommandTester($this->command);
     $CT->execute(['command' => $this->command->getName(), 'name' => 'test']);
     $this->assertContains('Failed to deactivate', $CT->getDisplay());
 }
コード例 #2
0
ファイル: ProjectScanTest.php プロジェクト: danzabar/alice
 /**
  * Test updating existing projects
  *
  * @return void
  * @author Dan Cox
  */
 public function test_updateProjectsFromScan()
 {
     $this->DI->addMock('finder', $this->finder);
     $this->DI->addMock('config', $this->config);
     $this->DI->addMock('database', $this->database);
     $this->finder->shouldReceive('files')->andReturn($this->finder);
     $this->finder->shouldReceive('in')->andReturn([$this->finder]);
     $this->finder->shouldReceive('getRealPath')->andReturn('/var/www/test/test.yml');
     $this->config->shouldReceive('load')->with('/var/www/test/test.yml')->andReturn($this->config);
     $this->config->shouldReceive('params')->andReturn($this->config);
     $this->config->name = 'project';
     $this->config->description = '';
     $this->config->root_development = '';
     $this->config->root_live = '';
     $this->config->repository = array('remote_url' => '');
     $this->database->shouldReceive('getEntity')->andReturn($this->database);
     $this->database->shouldReceive('setModel');
     $this->database->shouldReceive('count')->with(['name', '=', 'project'])->andReturn(1);
     $this->database->shouldReceive('first')->andReturn($this->database);
     $this->database->repository = $this->database;
     $this->database->shouldReceive('save');
     $CT = new CommandTester($this->command);
     $CT->execute(['command' => $this->command->getName()]);
     $this->assertContains('Successfully saved project: project', $CT->getDisplay());
     $this->assertContains('Finished processing project file changes', $CT->getDisplay());
 }
コード例 #3
0
ファイル: ModuleMakeTest.php プロジェクト: danzabar/alice
 /**
  * Test a fail to make a config file for whatever reason
  *
  * @return void
  * @author Dan Cox
  */
 public function test_fail()
 {
     $this->setExpectedException('RuntimeException');
     $this->fs->shouldReceive('mkdir')->with(WORKBENCH . 'test')->andThrow(new Exception());
     $CT = new CommandTester($this->command);
     $CT->execute(['command' => $this->command->getName(), 'name' => 'test']);
     $this->assertContains('Failed', $CT->getDisplay());
 }
コード例 #4
0
 /**
  * Creates the Mockery based on the service name
  *
  * @param string $service
  * @return void
  * @author Dan Cox
  */
 public function __construct($service)
 {
     $service = str_replace('.', '_', $service);
     $this->mockery = \Mockery::mock($service);
     // Add a call for the DI
     $this->mockery->shouldReceive('getDI')->andReturn($this->mockery);
     $this->mockery->shouldReceive('setDI')->andReturn($this->mockery);
 }
コード例 #5
0
ファイル: CronRemoveTest.php プロジェクト: danzabar/alice
 /**
  * Test when a cron cannot be found
  *
  * @return void
  * @author Dan Cox
  */
 public function test_invalidCron()
 {
     $this->setExpectedException('RuntimeException');
     $this->database->shouldReceive('setModel')->with('Alice\\Entity\\Cron')->andReturn($this->database);
     $this->database->shouldReceive('count')->andReturn(0);
     $CT = new CommandTester($this->command);
     $CT->execute(['command' => $this->command->getName(), 'name' => 'test']);
 }
コード例 #6
0
ファイル: ContactAddTest.php プロジェクト: danzabar/alice
 /**
  * Test a fail case
  *
  * @return void
  * @author Dan Cox
  */
 public function test_addFail()
 {
     $this->database->shouldReceive('setModel')->with('Alice\\Entity\\Contact')->andReturn($this->database);
     $this->database->shouldReceive('getEntity')->andThrow('Exception');
     $CT = new CommandTester($this->command);
     $CT->execute(['command' => $this->command->getName(), 'first' => 'test', 'last' => 'test', 'email' => '*****@*****.**', '--phone' => '12345678910']);
     $this->assertContains('There was an issue', $CT->getDisplay());
 }
コード例 #7
0
ファイル: LogTest.php プロジェクト: danzabar/alice
 /**
  * Test Creating the file first
  *
  * @return void
  * @author Dan Cox
  */
 public function test_createFileFirst()
 {
     $this->fs->shouldReceive('exists')->andReturn(FALSE);
     $this->config->shouldReceive('create')->andReturn($this->config);
     $this->config->shouldReceive('params')->andReturn($this->config);
     $this->config->shouldReceive('save');
     $this->log->write('file.yml', 'logname', array('data' => array()));
 }
コード例 #8
0
ファイル: ModuleToolTest.php プロジェクト: danzabar/alice
 /**
  * Test creating config files for the mod
  *
  * @return void
  * @author Dan Cox
  */
 public function test_createConfigurationFiles()
 {
     $this->config->shouldReceive('create')->andReturn($this->config);
     $this->config->shouldReceive('params')->andReturn($this->config);
     $this->config->shouldReceive('save');
     $tool = new ModuleTool();
     $tool->config(['test' => 'value']);
     $this->assertEquals('value', $this->config->test);
 }
コード例 #9
0
ファイル: CronUpdateTest.php プロジェクト: danzabar/alice
 /**
  * Basic test
  *
  * @return void
  * @author Dan Cox
  */
 public function test_update()
 {
     $this->cron->shouldReceive('updateFromDB');
     $this->process->shouldReceive('build')->andReturn($this->process);
     $this->process->shouldReceive('getProcess')->andReturn($this->process);
     $this->process->shouldReceive('mustRun');
     $CT = new CommandTester($this->command);
     $CT->execute(['command' => $this->command->getName()]);
     $this->assertContains('Updated', $CT->getDisplay());
 }
コード例 #10
0
ファイル: UpdateTest.php プロジェクト: danzabar/alice
 /**
  * Test a run through that fails on dctrine
  *
  * @return void
  * @author Dan Cox
  */
 public function test_runThroughFailDoctrine()
 {
     $this->DI->addMock('doctrineprocess', $this->doctrine);
     $this->doctrine->shouldReceive('build')->with(['force' => true])->andReturn($this->doctrine);
     $this->doctrine->shouldReceive('getProcess')->andReturn($this->doctrine);
     $this->doctrine->shouldReceive('mustRun')->andThrow('Exception');
     $CT = new CommandTester($this->command);
     $CT->execute(['command' => $this->command->getName()]);
     $this->assertContains('Failed updating schema...', $CT->getDisplay());
 }
コード例 #11
0
ファイル: ProjectCreateTest.php プロジェクト: danzabar/alice
 /**
  * Command is simple, lets just test a run through
  *
  * @return void
  * @author Dan Cox
  */
 public function test_runThrough()
 {
     $this->DI->addMock('config', $this->config);
     $this->config->shouldReceive('create');
     $this->config->shouldReceive('params')->andReturn($this->config);
     $this->config->shouldReceive('save');
     $CT = new CommandTester($this->command);
     $CT->execute(['command' => $this->command->getName(), 'name' => 'test']);
     $this->assertContains("Saved project file", $CT->getDisplay());
 }
コード例 #12
0
ファイル: DoctrineSchemaTest.php プロジェクト: danzabar/alice
 /**
  * Test a run through with a mocked process
  *
  * @return void
  * @author Dan Cox
  */
 public function test_runThrough()
 {
     $this->DI->addMock('doctrineprocess', $this->doctrine);
     $this->doctrine->shouldReceive('build')->with(['force' => true])->andReturn($this->doctrine);
     $this->doctrine->shouldReceive('getProcess')->andReturn($this->doctrine);
     $this->doctrine->shouldReceive('run');
     $this->doctrine->shouldReceive('isSuccessful')->andReturn(TRUE);
     $CT = new CommandTester($this->command);
     $CT->execute(['command' => $this->command->getName()]);
     $this->assertContains('Successfully updated the database schema', $CT->getDisplay());
 }
コード例 #13
0
ファイル: ModulesTest.php プロジェクト: danzabar/alice
 /**
  * Test deactivating a mod
  *
  * @return void
  * @author Dan Cox
  */
 public function test_deactivate()
 {
     $this->config->shouldReceive('load');
     $this->probe->shouldReceive('load')->with('/var/www/');
     $this->probe->shouldReceive('deactivateModule');
     $this->config->shouldReceive('params')->andReturn($this->config);
     $this->config->modules = array('mod' => '/var/www');
     $mod = new Modules();
     $mod->library()->availableModules = array('mod' => '/var/www/');
     $mod->deactivate('mod');
 }
コード例 #14
0
ファイル: CronTest.php プロジェクト: danzabar/alice
 /**
  * Test updating crontab text file
  *
  * @return void
  * @author Dan Cox
  */
 public function test_updateCronTabText()
 {
     $this->database->shouldReceive('setModel')->with('Alice\\Entity\\Cron')->andReturn($this->database);
     $this->database->shouldReceive('get')->andReturn([$this->database]);
     // 1 Result.
     $this->database->jobdate = '* * * * *';
     $this->database->id = 1;
     $this->fs->shouldReceive('dumpFile')->with('/tmp/crontab.txt', "* * * * * /usr/bin/php " . ROOT . "alice cron:run 1\n");
     $cron = new Cron();
     $cron->updateFromDB();
 }
コード例 #15
0
ファイル: CommandCreateTest.php プロジェクト: danzabar/alice
 /**
  * Test a working run through of the command
  *
  * @return void
  * @author Dan Cox
  */
 public function test_runThroughCommand()
 {
     $this->command->getHelper('question')->setInputStream($this->inputStream("git init, touch readme.md\nvalue = test, foo = bar\n"));
     // Database expectations
     $this->database->shouldReceive('getEntity')->andReturn($this->database);
     $this->database->shouldReceive('persist');
     $this->database->shouldReceive('flush');
     // Mock the config class
     $this->DI->addMock('config', $this->config);
     $this->config->shouldReceive('create')->with(CONFIG . 'commands/test.command.yml');
     $this->config->shouldReceive('params')->andReturn($this->config);
     $this->config->shouldReceive('save');
     $CT = new CommandTester($this->command);
     $CT->execute(['command' => $this->command->getName(), 'name' => 'test.command']);
 }
コード例 #16
0
ファイル: SkeletonBuildTest.php プロジェクト: danzabar/alice
 /**
  * Using a test skeleton, run a basic skeleton command list
  *
  * @return void
  * @author Dan Cox
  */
 public function test_runBasicSkeletonCommands()
 {
     $sp = m::mock('skeletonprocess');
     $collection = m::mock('collection');
     $this->DI->addMock('skeletonprocess', $sp);
     $this->DI->addMock('collection', $collection);
     $this->DI->addMock('fs', $this->filesystem);
     // Collection Mocks
     $collection->shouldReceive('create')->andReturn($collection);
     $collection->build_script = array('mkdir [directory]', 'composer install');
     // FS Mocks
     $this->filesystem->shouldReceive('exists')->andReturn(TRUE);
     // Skeleton Mocks
     $sp->shouldReceive('build')->with(['directory' => __DIR__, 'verbose' => false])->andReturn($sp);
     $sp->shouldReceive('getProcess')->andReturn($sp);
     $sp->shouldReceive('setArguments')->with(array('mkdir', __DIR__))->andReturn($sp);
     $sp->shouldReceive('setArguments')->with(array('composer', 'install'))->andReturn($sp);
     $sp->shouldReceive('mustRun');
     $sp->shouldReceive('getCommandLine')->andReturn("'mkdir' '" . __DIR__ . "'");
     $CT = new CommandTester($this->command);
     $CT->execute(['command' => $this->command->getName(), 'config' => 'test.yml', 'directory' => __DIR__]);
     // The skeleton process passes, but the composer process fails
     $this->assertContains("Successfully ran command: 'mkdir'", $CT->getDisplay());
     $this->assertContains("The command \"'composer'", $CT->getDisplay());
 }
コード例 #17
0
ファイル: EntityTest.php プロジェクト: danzabar/alice
 /**
  * Test the delete function
  *
  * @return void
  * @author Dan Cox
  */
 public function test_removeModel()
 {
     DI::addMock('database', $this->database);
     $this->database->shouldReceive('getEntity')->andReturn($this->database);
     $this->database->shouldReceive('remove');
     $this->database->shouldReceive('flush');
     $this->entity->delete();
 }
コード例 #18
0
ファイル: CronCreateTest.php プロジェクト: danzabar/alice
 /**
  * Test that a run time exception fires when the command list does not exist
  *
  * @return void
  * @author Dan Cox
  */
 public function test_runtimeExceptionOnMissingCommandList()
 {
     $this->database->shouldReceive('setModel')->with('Alice\\Entity\\Command')->andReturn($this->database);
     $this->database->shouldReceive('getEntity')->andReturn($this->database);
     $this->database->shouldReceive('count')->andReturn(0);
     $this->setExpectedException('RuntimeException');
     $CT = new CommandTester($this->command);
     $CT->execute(["command" => $this->command->getName(), "name" => 'test', "time" => '* * * * *', "--commandlist" => 'test']);
 }
コード例 #19
0
ファイル: CommandRunTest.php プロジェクト: danzabar/alice
 /**
  * Test the runtime exception fires when a command does not exist
  *
  * @return void
  * @author Dan Cox
  */
 public function test_commandDoesntExist()
 {
     $this->setExpectedException('RuntimeException');
     $this->database->shouldReceive('setModel')->with('Alice\\Entity\\Command')->andReturn($this->database);
     $this->database->shouldReceive('getEntity')->andReturn($this->database);
     $this->database->shouldReceive('count')->andReturn(0);
     $CT = new CommandTester($this->command);
     $CT->execute(['command' => $this->command->getName(), 'name' => 'testFail', 'directory' => __DIR__]);
 }
コード例 #20
0
 /**
  * Test the query builder function
  *
  * @return void
  * @author Dan Cox
  */
 public function test_queryBuilder()
 {
     $connection = $this->DI->get('connection');
     $connection->shouldReceive('connection')->andReturn($connection);
     $connection->shouldReceive('createQueryBuilder')->andReturn($this->builderStub);
     $this->builderStub->shouldReceive('from')->with('Test', 'u')->andReturn($this->builderStub);
     $this->builderStub->query = 'foo';
     $builder = $this->DI->get('database')->setEntity('Test')->queryBuilder();
     $this->assertEquals('foo', $builder->query);
 }
コード例 #21
0
ファイル: ModuleLibraryTest.php プロジェクト: danzabar/alice
 /**
  * Test getting the active modules
  *
  * @return void
  * @author Dan Cox
  */
 public function test_getActive()
 {
     $this->config->shouldReceive('load');
     $this->config->shouldReceive('params')->andReturn($this->config);
     $this->config->modules = [];
     $this->cache->shouldReceive('getCache')->andReturn(['mod' => []]);
     $library = new ModuleLibrary();
     $active = $library->getActive();
     $this->assertEquals(['mod'], $active);
 }
コード例 #22
0
ファイル: ModuleCacheTest.php プロジェクト: danzabar/alice
 /**
  * Test the remove function
  *
  * @return void
  * @author Dan Cox
  */
 public function test_remove()
 {
     $this->config->shouldReceive('load');
     $this->config->shouldReceive('params')->andReturn($this->config);
     $this->config->mod = array('commands' => array(), 'entity' => array());
     $this->config->shouldReceive('save');
     $cache = new ModuleCache();
     $cache->remove('mod');
     $this->assertFalse(isset($this->config->mod));
 }
コード例 #23
0
 /**
  * Get SQL from an update
  *
  * @return void
  * @author Dan Cox
  */
 public function test_getSql()
 {
     $connection = $this->DI->get('connection');
     $connection->shouldReceive('getSchemaTool')->once()->andReturn($this->schema);
     $connection->shouldReceive('connection')->once()->andReturn($connection);
     $connection->shouldReceive('getMetadataFactory')->once()->andReturn($this->metadataFactory);
     $this->metadataFactory->shouldReceive('getAllMetadata')->once()->andReturn(array());
     $this->schema->shouldReceive('getUpdateSchemaSql')->once();
     $this->DI->get('schema')->getSql();
 }
コード例 #24
0
ファイル: SkeletonDeployTest.php プロジェクト: danzabar/alice
 /**
  * Test the whole process
  *
  * @return void
  * @author Dan Cox
  */
 public function test_runThrough()
 {
     $sp = m::mock('skeletonprocess');
     $collection = m::mock('collection');
     $this->DI->addMock('skeletonprocess', $sp);
     $this->DI->addMock('collection', $collection);
     $this->DI->addMock('fs', $this->fs);
     $collection->shouldReceive('create')->andReturn($collection);
     $collection->deploy_script = array('mkdir [directory]', 'git clone [git]');
     $this->fs->shouldReceive('exists')->andReturn(TRUE);
     $sp->shouldReceive('build')->with(['directory' => __DIR__, 'verbose' => false])->andReturn($sp);
     $sp->shouldReceive('getProcess')->andReturn($sp);
     $sp->shouldReceive('setArguments')->with(['mkdir', __DIR__])->andReturn($sp);
     $sp->shouldReceive('setArguments')->with(['git', 'clone', 'giturl'])->andReturn($sp);
     $sp->shouldReceive('setArguments')->with(['php', 'artisan', 'migrate'])->andReturn($sp);
     $sp->shouldReceive('mustRun');
     $sp->shouldReceive('getCommandLine')->andReturn("'mkdir' '" . __DIR__ . "'");
     $CT = new CommandTester($this->command);
     $CT->execute(['command' => $this->command->getName(), 'config' => 'test.yml', 'directory' => __DIR__, '--git' => 'giturl']);
     // Mkdir Passes... git fails
     $this->assertContains("Successfully ran command: 'mkdir'", $CT->getDisplay());
     $this->assertContains("The command \"'git'", $CT->getDisplay());
 }
コード例 #25
0
ファイル: CronRunTest.php プロジェクト: danzabar/alice
 /**
  * Test for when a command list is not valid
  *
  * @return void
  * @author Dan Cox
  */
 public function test_commandListNotValid()
 {
     $this->setExpectedException('RuntimeException');
     $this->database->shouldReceive('setModel')->with('Alice\\Entity\\Cron')->andReturn($this->database);
     $this->database->shouldReceive('count')->with(['id', '=', 1])->andReturn(1);
     $this->database->shouldReceive('find')->andReturn($this->database);
     $this->database->job = NULL;
     $this->database->name = 'test2';
     $this->database->command = 'test';
     $this->database->shouldReceive('setModel')->with('Alice\\Entity\\Command')->andReturn($this->database);
     $this->database->shouldReceive('count')->with(['name', '=', 'test'])->andReturn(0);
     $this->log->shouldReceive('write');
     $CT = new CommandTester($this->command);
     $CT->execute(['command' => $this->command->getName(), 'cronid' => 1]);
 }
コード例 #26
0
ファイル: CronEditTest.php プロジェクト: danzabar/alice
 /**
  * Test with an invalid command list
  *
  * @return void
  * @author Dan Cox
  */
 public function test_invalidCommandList()
 {
     $this->setExpectedException('RuntimeException');
     // Cron
     $this->database->shouldReceive('setModel')->with('Alice\\Entity\\Cron')->andReturn($this->database);
     $this->database->shouldReceive('getEntity')->andReturn($this->database);
     $this->database->shouldReceive('count')->with(['name', '=', 'test'])->andReturn(1);
     $this->database->shouldReceive('first')->with(['name' => 'test'])->andReturn($this->database);
     $this->database->shouldReceive('save');
     // Command List
     $this->database->shouldReceive('setModel')->with('Alice\\Entity\\Command')->andReturn($this->database);
     $this->database->shouldReceive('count')->with(['name', '=', 'test2'])->andReturn(0);
     $CT = new CommandTester($this->command);
     $CT->execute(['command' => $this->command->getName(), 'name' => 'test', '--commandlist' => 'test2']);
 }
コード例 #27
0
ファイル: ModuleProbeTest.php プロジェクト: danzabar/alice
 /**
  * Fail, fail, fail
  *
  * @return void
  * @author Dan Cox
  */
 public function test_activateWithFailedRequirements()
 {
     $this->setExpectedException('Alice\\Exceptions\\ModuleRequirementNotMetException');
     $config = ['details' => ['name' => 'mod'], 'namespace' => '', 'extension' => 'module', 'requires' => ['mod2'], 'services' => []];
     $this->config->shouldReceive('load')->andReturn($this->config);
     $this->config->shouldReceive('params')->andReturn($this->config);
     $this->config->shouldReceive('all')->andReturn($config);
     $this->probe->shouldReceive('load');
     $this->probe->shouldReceive('class_exists')->andReturn(true);
     $this->probe->shouldReceive('reflection')->andReturn($this->reflection);
     $this->library->shouldReceive('getActive')->andReturn([]);
     $this->cache->shouldReceive('saveServices');
     $this->cache->shouldReceive('readFrom');
     $this->reflection->shouldReceive('getMethod')->andReturn($this->reflection);
     $this->reflection->shouldReceive('invokeArgs')->andReturn($this->reflection);
     $this->reflection->shouldReceive('newInstance');
     $probe = new ModuleProbe();
     $probe->load('test/');
     $probe->activateModule();
 }
コード例 #28
0
ファイル: ProcessTest.php プロジェクト: danzabar/alice
 /**
  * Test the disabled output switch
  *
  * @return void
  * @author Dan Cox
  */
 public function test_disableOutput()
 {
     $this->builder->shouldReceive('disableOutput');
     $this->process->disableOutput();
 }