/** * 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()); }
/** * 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()); }
/** * 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()); }
/** * 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']); }
/** * 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()); }
/** * 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()); }
/** * 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()); }
/** * Fail by exception * * @return void * @author Dan Cox */ public function test_failbyexception() { $this->database->shouldReceive('setModel')->with('Alice\\Entity\\Contact')->andReturn($this->database); $this->database->shouldReceive('getEntity')->andReturn($this->database); $this->database->shouldReceive('count')->andReturn(1); $this->database->shouldReceive('first')->andThrow('Exception'); $CT = new CommandTester($this->command); $CT->execute(['command' => $this->command->getName(), 'email' => '*****@*****.**']); $this->assertContains("Failed removing contact from database", $CT->getDisplay()); }
/** * 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()); }
/** * 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']); }
/** * 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()); }
/** * Construtor * @param string $serviceName * @param Object $userData */ function UserDataLog($serviceName, $userData) { $this->serviceName = $serviceName; $this->setDirectory(); // Definindo dados do usuário $this->fields['ip'] = $userData->getIp(); $this->fields['language'] = $userData->getLanguage(); $this->fields['nameHost'] = $userData->getName(); $this->fields['OS'] = $userData->getOS(); $this->fields['port'] = $userData->getPort(); $this->fields['resolution'] = $userData->getResolution(); $this->fields['title'] = $userData->getTitle(); $this->fields['url'] = $userData->getURL(); $browser = array(); $support = array(); $browser = $userData->getBrowser(); $support = $userData->getSupport(); $i = 0; for ($i = 0; $i < count($browser) - 1; $i++) { $this->fields['browser'] .= $browser[$i] . " , "; } $this->fields['browser'] .= $browser[$i]; for ($i = 0; $i < count($support) - 1; $i++) { $this->fields['support'] .= $support[$i] . " , "; } $this->fields['support'] .= $support[$i]; }
/** * 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()); }
/** * 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']); }
/** * 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__]); }
public function equals(Object $object) { if ($object instanceof BasicPermission) { if ($object->getName() == $this->getName()) { return true; } return false; } return false; }
/** * 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]); }
/** * 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']); }
/** * OnContentSearch * * @param string $text Target search string. * * @return array Search results. * * @since 1.0 */ public function onContentSearch($text) { // Exclude always for backend if ($this->app->getName() == 'admin') { return false; } $doc = JFactory::getDocument(); if ($doc->getType() !== 'html') { return false; } // Discard other params and take only text keywords if (trim($text)) { $this->saveSearchword(trim($text)); // TODOReturn notifications/Exception if called from this plugin } }
public function getEntityLabel() { $label = ''; if (method_exists($this->entity, 'getLabel')) { $label = $this->entity->getLabel(); } else { if (method_exists($this->entity, 'getTitle')) { $label = $this->entity->getTitle(); } else { if (method_exists($this->entity, 'getName')) { $label = $this->entity->getName(); } else { if (method_exists($this->entity, '__toString')) { $label = $this->entity->__toString(); } } } } return $label; }
/** * 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()); }
/** * Render error caption * * @param Object $input Form Input element * @return string */ public function error() { $str = ''; if ($this->_canHasFeedback()) { $class = ['glyphicon', 'form-control-feedback']; if ($this->_element->getMessages()) { $class[] = $this->_errorIcon; $feedbackText = $this->_errorMsg; } else { $class[] = $this->_successIcon; $feedbackText = $this->_successMsg; } $str .= self::newLine(sprintf('<span class="%s" aria-hidden="true">', implode(' ', $class))); $str .= self::newLine(sprintf('</span><span id="%s-feedback" class="sr-only">(%s)</span>', $this->_element->getAttribute('id') ?: $this->_element->getName(), $feedbackText)); } if ($msg = $this->_element->getMessages()) { foreach ($msg as $line) { //need to translate empty field error message, since Zend do not translate it $str .= self::newLine(sprintf('<span class="help-block">%s</span>', $this->translate($line))); } } return $str; }
/** * Add category * * @param Object $category WPTerm object * * @return WPBlogTerms $this */ public function addCategory($category) { if (!$this->hasCategory($category->getName())) { array_push($this->categories, $category); } return $this; }
/** * donne les promotions disponibles, ça tient compte de la fundation et du removed=0, pas du point ni de la presence d'un prix pour celle ci * @return String $listeDispoPromotion */ public function getAvailablePromotion() { $rtn = new ComplexData(); $req = $this->db->query("SELECT obj_id, obj_name FROM t_object_obj WHERE obj_type = 'promotion' AND fun_id = '%u' AND obj_removed = '0';", array($this->Fundation->getId())); while ($don = $this->db->fetchArray($req)) { $promo = new Object($don['obj_id']); $rtn->addLine(array($don['obj_id'], $promo->getName())); } return $rtn->csvArrays(); }
/** * Function to get html for displaying the index form * * @param array $fields fields * @param Object $index index * @param array $form_params form parameters * @param int $add_fields number of fields in the form * * @return string */ function PMA_getHtmlForIndexForm($fields, $index, $form_params, $add_fields) { $html = ""; $html .= '<form action="tbl_indexes.php" method="post" name="index_frm" id="' . 'index_frm" class="ajax"' . 'onsubmit="if (typeof(this.elements[\'index[Key_name]\'].disabled) !=' . ' \'undefined\') {' . 'this.elements[\'index[Key_name]\'].disabled = false}">'; $html .= PMA_URL_getHiddenInputs($form_params); $html .= '<fieldset id="index_edit_fields">'; $html .= '<div class="index_info">'; $html .= '<div>' . '<div class="label">' . '<strong>' . '<label for="input_index_name">' . __('Index name:') . PMA_Util::showHint(PMA_Message::notice(__('"PRIMARY" <b>must</b> be the name of' . ' and <b>only of</b> a primary key!'))) . '</label>' . '</strong>' . '</div>' . '<input type="text" name="index[Key_name]" id="input_index_name"' . ' size="25"' . 'value="' . htmlspecialchars($index->getName()) . '"' . 'onfocus="this.select()" />' . '</div>'; if (PMA_MYSQL_INT_VERSION > 50500) { $html .= '<div>' . '<div class="label">' . '<strong>' . '<label for="input_index_comment">' . __('Comment:') . '</label>' . '</strong>' . '</div>' . '<input type="text" name="index[Index_comment]" ' . 'id="input_index_comment" size="30"' . 'value="' . htmlspecialchars($index->getComment()) . '"' . 'onfocus="this.select()" />' . '</div>'; } $html .= '<div>' . '<div class="label">' . '<strong>' . '<label for="select_index_type">' . __('Index type:') . PMA_Util::showMySQLDocu('ALTER_TABLE') . '</label>' . '</strong>' . '</div>' . '<select name="index[Index_type]" id="select_index_type" >' . $index->generateIndexSelector() . '</select>' . '</div>'; $html .= '<div class="clearfloat"></div>'; $html .= '</div>'; $html .= '<table id="index_columns">'; $html .= '<thead>' . '<tr>' . '<th>' . __('Column') . '</th>' . '<th>' . __('Size') . '</th>' . '</tr>' . '</thead>'; $odd_row = true; $spatial_types = array('geometry', 'point', 'linestring', 'polygon', 'multipoint', 'multilinestring', 'multipolygon', 'geomtrycollection'); $html .= '<tbody>'; foreach ($index->getColumns() as $column) { $html .= '<tr class="'; $html .= $odd_row ? 'odd' : 'even'; $html .= 'noclick">'; $html .= '<td>'; $html .= '<select name="index[columns][names][]">'; $html .= '<option value="">-- ' . __('Ignore') . ' --</option>'; foreach ($fields as $field_name => $field_type) { if (($index->getType() != 'FULLTEXT' || preg_match('/(char|text)/i', $field_type)) && ($index->getType() != 'SPATIAL' || in_array($field_type, $spatial_types))) { $html .= '<option value="' . htmlspecialchars($field_name) . '"' . ($field_name == $column->getName() ? ' selected="selected"' : '') . '>' . htmlspecialchars($field_name) . ' [' . htmlspecialchars($field_type) . ']' . '</option>' . "\n"; } } // end foreach $fields $html .= '</select>'; $html .= '</td>'; $html .= '<td>'; $html .= '<input type="text" size="5" onfocus="this.select()"' . 'name="index[columns][sub_parts][]" value="'; if ($index->getType() != 'SPATIAL') { $html .= $column->getSubPart(); } $html .= '"/>'; $html .= '</td>'; $html .= '</tr>'; $odd_row = !$odd_row; } // end foreach $edited_index_info['Sequences'] for ($i = 0; $i < $add_fields; $i++) { $html .= '<tr class="'; $html .= $odd_row ? 'odd' : 'even'; $html .= 'noclick">'; $html .= '<td>'; $html .= '<select name="index[columns][names][]">'; $html .= '<option value="">-- ' . __('Ignore') . ' --</option>'; foreach ($fields as $field_name => $field_type) { $html .= '<option value="' . htmlspecialchars($field_name) . '">' . htmlspecialchars($field_name) . ' [' . htmlspecialchars($field_type) . ']' . '</option>' . "\n"; } // end foreach $fields $html .= '</select>'; $html .= '</td>'; $html .= '<td>' . '<input type="text" size="5" onfocus="this.select()"' . 'name="index[columns][sub_parts][]" value="" />' . '</td>'; $html .= '</tr>'; $odd_row = !$odd_row; } // end foreach $edited_index_info['Sequences'] $html .= '</tbody>'; $html .= '</table>'; $html .= '</fieldset>'; $html .= '<fieldset class="tblFooters">'; $btn_value = sprintf(__('Add %s column(s) to index'), 1); $html .= '<div class="slider"></div>'; $html .= '<div class="add_fields">'; $html .= '<input type="submit" value="' . $btn_value . '" />'; $html .= '</div>'; $html .= '</fieldset>'; $html .= '</form>'; return $html; }
/** * 正常系 getNameはproductionを返す * * @covers Lib\Config\DetectEnvironment::getName() * @test testGetName() */ public function testGetName() { $res = $this->object->getName(); $this->assertEquals($res, 'production'); }
return $this->_name; } /** * Вернёт статус объекта. * * @return int */ public function getStatus() { return $this->_status; } /** * Вернёт id объекта. * * @return int */ public function getId() { return $this->_id; } } try { $object = new Object(1, new PDO("mysql:host=localhost;dbname=test", 'root', 'root')); $object->status = 2; $object->save(); var_dump($object->getName()); } catch (PDOException $e) { echo "PDO error: " . $e->getMessage(); } catch (ObjectException $e) { echo $e->getMessage(); }
/** * Check that the name and version is correct * * @return void * @author Dan Cox */ public function test_nameAndVersion() { $this->assertEquals('Test CLI', $this->application->getName()); $this->assertEquals('1.0', $this->application->getVersion()); }
/** * Return value of 'name' field * * @access public * @param void * @return string */ function getObjectName() { return $this->object->getName(); }