public function testPHPSpecCommand() { $task = $this->taskPhpspec('phpspec')->stopOnFail()->noCodeGeneration()->quiet()->verbose('vv')->noAnsi()->noInteraction()->format('pretty'); verify($task->getCommand())->equals('phpspec run --stop-on-failure --no-code-generation --quiet -vv --no-ansi --no-interaction --format pretty'); $task->run(); $this->phpspec->verifyInvoked('executeCommand', ['phpspec run --stop-on-failure --no-code-generation --quiet -vv --no-ansi --no-interaction --format pretty']); }
public function testConvertCurrency(UnitTester $I) { $exchangeRate = new \Zidisha\Currency\ExchangeRate(); $exchangeRate->setRate(80)->setCurrencyCode(Currency::CODE_KES); // convert to USD $money = Money::create('160', Currency::CODE_KES); $moneyUSD = Money::create('2.0', Currency::CODE_USD); verify($this->currencyService->convertToUSD($money, $exchangeRate))->equals($moneyUSD); // convert from USD $money = Money::create('240', Currency::CODE_KES); $moneyUSD = Money::create('3.0', Currency::CODE_USD); verify($this->currencyService->convertFromUSD($moneyUSD, Currency::create(Currency::CODE_KES), $exchangeRate))->equals($money); $failed = false; try { $money = Money::create('160', Currency::CODE_XOF); $this->currencyService->convertToUSD($money, $exchangeRate); } catch (\Zidisha\Currency\Exception\InvalidCurrencyExchangeException $e) { $failed = true; } verify($failed)->true(); $failed = false; try { $this->currencyService->convertFromUSD($moneyUSD, Currency::create(Currency::CODE_XOF), $exchangeRate); } catch (\Zidisha\Currency\Exception\InvalidCurrencyExchangeException $e) { $failed = true; } verify($failed)->true(); }
public function testPHPUnitCommand() { $task = $this->taskPHPUnit('phpunit')->bootstrap('bootstrap.php')->filter('Model')->group('important')->xml('result.xml')->debug(); verify($task->getCommand())->equals('phpunit --bootstrap bootstrap.php --filter Model --group important --log-junit result.xml --debug'); $task->run(); $this->phpunit->verifyInvoked('executeCommand', ['phpunit --bootstrap bootstrap.php --filter Model --group important --log-junit result.xml --debug']); }
/** * Do the Artisan commands fire? */ public function testCommands() { $self = $this; $this->prepareSpecify(); $this->specify('Boots', function () use($self) { $target = $self->getProvider(['package']); $target->shouldReceive('package'); $target->boot(); }); $this->prepareSpecify(); $this->specify('Identifies provisions', function () use($self) { $target = $self->getProvider(); verify($target->provides())->notEmpty(); }); $this->prepareSpecify(); $this->specify('Binds to application', function () use($self) { App::shouldReceive('bind')->with('/^toolbox\\.commands\\./', Mockery::on(function ($closure) { $command = $closure(); verify_that('is a command', is_a($command, 'Illuminate\\Console\\Command')); return true; })); Event::shouldReceive('listen')->with('toolbox.build', Mockery::on(function ($closure) { $app = Mockery::mock('Illuminate\\Console\\Application[call]'); $app->shouldReceive('call'); $command = $closure($app); return true; })); $target = $self->getProvider(['commands']); $target->shouldReceive('commands')->with(Mockery::type('array')); $target->register(); }); }
function nav() { unset($_SESSION['index_class']); unset($_SESSION['editmix_class']); unset($_SESSION['validate_class']); unset($_SESSION['makemix_class']); unset($_SESSION['mwbedocs_class']); unset($_SESSION['upfiles_class']); if ($_SESSION['action'] == "index") { index(); } elseif ($_SESSION['action'] == "makemix") { makemix(); } elseif ($_SESSION['action'] == "upfiles") { upfiles(); } elseif ($_SESSION['action'] == "verify") { verify(); } elseif ($_SESSION['action'] == "validate") { validate(); } elseif ($_SESSION['action'] == "editmix") { editmix(); } elseif ($_SESSION['action'] == "mwbedocs") { mwbedocs(); } elseif ($_SESSION['action'] == "delmix") { delmix(); } else { index(); } }
public function testLogin() { $this->form = new LoginForm(); $this->specify('should not allow logging in blocked users', function () { $user = $this->getFixture('user')->getModel('blocked'); $this->form->setAttributes(['login' => $user->email, 'password' => 'qwerty']); verify($this->form->validate())->false(); verify($this->form->getErrors('login'))->contains('Your account has been blocked'); }); $this->specify('should not allow logging in unconfirmed users', function () { \Yii::$app->getModule('user')->enableConfirmation = true; \Yii::$app->getModule('user')->enableUnconfirmedLogin = false; $user = $this->getFixture('user')->getModel('user'); $this->form->setAttributes(['login' => $user->email, 'password' => 'qwerty']); verify($this->form->validate())->true(); $user = $this->getFixture('user')->getModel('unconfirmed'); $this->form->setAttributes(['login' => $user->email, 'password' => 'unconfirmed']); verify($this->form->validate())->false(); \Yii::$app->getModule('user')->enableUnconfirmedLogin = true; verify($this->form->validate())->true(); }); $this->specify('should log the user in with correct credentials', function () { $user = $this->getFixture('user')->getModel('user'); $this->form->setAttributes(['login' => $user->email, 'password' => 'wrong']); verify($this->form->validate())->false(); $this->form->setAttributes(['login' => $user->email, 'password' => 'qwerty']); verify($this->form->validate())->true(); }); }
/** * Output the POS template */ public function template_redirect() { // check is pos if (!is_pos('template')) { return; } // check auth if (!is_user_logged_in()) { add_filter('login_url', array($this, 'login_url')); auth_redirect(); } //check store table if (verify() == -1) { wp_die(__('You are not listed as a store employee or administrator.')); } // check privileges if (!current_user_can('access_woocommerce_pos')) { /* translators: wordpress */ wp_die(__('You do not have sufficient permissions to access this page.')); } // disable cache plugins $this->no_cache(); // last chance before template is rendered do_action('woocommerce_pos_template_redirect'); // add head & footer actions add_action('woocommerce_pos_head', array($this, 'head')); add_action('woocommerce_pos_footer', array($this, 'footer')); // now show the page include 'views/template.php'; exit; }
public function testProcessProlog() { $I = $this->tester; $this->tester->wantToTest("processing the prolog and importing the file into the database"); $this->import->setCsvReader($this->import->file); $this->import->processProlog(); $prolog = $this->import->prolog; $this->assertEquals(14, count($prolog['columns']), "There are the correct number of columns"); $this->assertEquals(6, count($prolog['prefix']), "There are the correct number of prefix entries"); $this->assertEquals(10, count($prolog['meta']), "There are the correct number of meta entries"); $this->import->getDataColumnIds(); $this->import->processData(); $results = $this->import->results['success']; verify( "There were 8 rows processed", count($results['rows']) )->equals(12); $this->import->processParents(); $I->seeRecordCountInDatabaseTable("SchemaPropertyElement", 138); $I->seeRecordCountInDatabaseTable("SchemaProperty", 12); //prolog namespace entries are readable //prolog headers are actually in row 1 //prolog headers not in row 1 produce fatal error (logged) //prolog entries can be matched to database (column uri matched to profile id) //prolog entries that can't be matched produce fatal error (logged) } //
public function login() { check_if_already_logged_in(); $data['page'] = "login"; $data['newline'] = "<br/>"; if (isset($_POST['btnLogin'])) { $username = $_POST["username"]; $password = $_POST["password"]; if ($user_info = $this->Users_model->find($username)) { $user_data = $this->Users_model->find_info($user_info['id']); if (verify($password, $user_info["password"], $user_info["salt"])) { $v = $this->Users_model->validity($user_info['id']); $newdata = array('id' => $user_info['id'], 'username' => $username, 'type' => $user_info['type'], 'validity' => $v['validity'], 'user_info' => $user_data); $this->session->set_userdata($newdata); header('Location: home'); } else { echo "false"; } } else { echo "Check your password or username"; } } $this->load->view('templates/header'); $this->load->view('users/login', $data); $this->load->view('templates/footer'); }
public function toExecLsCommand(CliGuy $I) { $command = strncasecmp(PHP_OS, 'WIN', 3) == 0 ? 'dir' : 'ls'; $res = $I->taskExec($command)->run(); verify($res->getMessage())->contains('src'); verify($res->getMessage())->contains('codeception.yml'); }
public function testComposerDumpAutoloadCommand() { verify($this->taskComposerDumpAutoload('composer')->getCommand())->equals('composer dump-autoload'); verify($this->taskComposerDumpAutoload('composer')->noDev()->getCommand())->equals('composer dump-autoload --no-dev'); verify($this->taskComposerDumpAutoload('composer')->optimize()->getCommand())->equals('composer dump-autoload --optimize'); verify($this->taskComposerDumpAutoload('composer')->optimize()->noDev()->getCommand())->equals('composer dump-autoload --optimize --no-dev'); }
public function testWorkflowCached() { $this->factory->addWorkflowDefinition('wid', ['initialStatusId' => 'A', 'status' => ['A']]); $this->specify('workflow are loaded once', function () { verify('workflow instances are the same', spl_object_hash($this->factory->getWorkflow('wid', null)))->equals(spl_object_hash($this->factory->getWorkflow('wid', null))); }); }
public function testAtoumCommand() { $task = (new \Robo\Task\Testing\Atoum('atoum'))->bootstrap('bootstrap.php')->tags("needDb")->lightReport()->tap()->bootstrap('tests/bootstrap.php')->configFile("config/dev.php")->debug()->files(array("path/to/file1.php", "path/to/file2.php"))->directories("tests/units"); verify($task->getCommand())->equals('atoum --bootstrap bootstrap.php --tags needDb --use-light-report --use-tap-report --bootstrap tests/bootstrap.php -c config/dev.php --debug --f path/to/file1.php --f path/to/file2.php --directories tests/units'); $task->run(); $this->atoum->verifyInvoked('executeCommand', ['atoum --bootstrap bootstrap.php --tags needDb --use-light-report --use-tap-report --bootstrap tests/bootstrap.php -c config/dev.php --debug --f path/to/file1.php --f path/to/file2.php --directories tests/units']); }
public function testParallelExec() { $result = $this->taskParallelExec()->process('ls 1')->process('ls 2')->process('ls 3')->run(); $this->process->verifyInvokedMultipleTimes('start', 3); verify($result->getExitCode())->equals(0); $this->guy->seeInOutput("3 processes ended in 0.00 s"); }
public function testSemver() { $semver = test::double('Robo\\Task\\SemVerTask', ['dump' => null]); $res = $this->taskSemVer()->increment('major')->prerelease('RC')->increment('patch')->run(); verify($res->getMessage())->equals('v1.0.1-RC.1'); $semver->verifyInvoked('dump'); }
public function actionReturn() { if (verify($_POST) && $_POST['respCode'] == '00') { $this->update_order(); } $this->redirect($this->createUrl('site/orders?msg=' . urlencode('订单支付成功,订单号为:' . $_POST['orderId']))); }
/** * @tests */ public function parser_should_use_prefetch_count_from_annotation() { $parser = new Parser(new AnnotationReader()); $consumer = new ConsumerWithPrefetchCount(); $consumerMethods = $parser->getConsumerMethods($consumer); $consumerMethod = $consumerMethods[0]; verify($consumerMethod->getPrefetchCount())->equals(100); }
public function testIsInterfaceImplemented() { $leftOperand = M::mock('Lrusev\\Formula\\Operand\\Number', ['getValue' => 5]); $rightOperand = M::mock('Lrusev\\Formula\\Operand\\Number', ['getValue' => 15]); $operator = new Div($leftOperand, $rightOperand); verify("operator implement Lrusev\\Formula\\Operand\\OperandInterface", $operator)->isInstanceOf('Lrusev\\Formula\\Operand\\OperandInterface'); verify("operator implement Lrusev\\Formula\\Operator\\OperatorInterface", $operator)->isInstanceOf('Lrusev\\Formula\\Operator\\OperatorInterface'); }
public function testLoadWorkflowSuccess2() { $src = new WorkflowFileSource(); $src->addWorkflowDefinition('wid', ['initialStatusId' => 'A', 'status' => ['A' => ['label' => 'Entry', 'transition' => 'A,B'], 'B' => ['label' => 'Published', 'transition' => ' A , B ']]]); verify($src->getStatus('wid/A'))->notNull(); verify($src->getStatus('wid/B'))->notNull(); verify(count($src->getTransitions('wid/A')))->equals(2); }
public function Verify($data) { if (isset($data['signature'])) { return verify($data); } else { return false; } }
public function testRsync() { verify((new \Robo\Task\Remote\Rsync())->fromPath('src/')->toHost('localhost')->toUser('dev')->toPath('/var/www/html/app/')->recursive()->excludeVcs()->checksum()->wholeFile()->verbose()->progress()->humanReadable()->stats()->getCommand())->equals('rsync --recursive --exclude .git --exclude .svn --exclude .hg --checksum --whole-file --verbose --progress --human-readable --stats src/ \'dev@localhost:/var/www/html/app/\''); // From the folder 'foo bar' (with space) in 'src' directory verify((new \Robo\Task\Remote\Rsync())->fromPath('src/foo bar/baz')->toHost('localhost')->toUser('dev')->toPath('/var/path/with/a space')->getCommand())->equals('rsync \'src/foo bar/baz\' \'dev@localhost:/var/path/with/a space\''); // Copy two folders, 'src/foo' and 'src/bar' verify((new \Robo\Task\Remote\Rsync())->fromPath(['src/foo', 'src/bar'])->toHost('localhost')->toUser('dev')->toPath('/var/path/with/a space')->getCommand())->equals('rsync src/foo src/bar \'dev@localhost:/var/path/with/a space\''); }
public function testBehatCommand() { $behat = test::double('Robo\\Task\\Testing\\Behat', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]); $task = (new \Robo\Task\Testing\Behat('behat'))->stopOnFail()->noInteraction()->colors(); verify($task->getCommand())->equals('behat run --stop-on-failure --no-interaction --colors'); $task->run(); $behat->verifyInvoked('executeCommand', ['behat run --stop-on-failure --no-interaction --colors']); }
public function testLoadWorkflowSuccess2() { $factory = new ArrayWorkflowItemFactory(); $factory->addWorkflowDefinition('wid', ['initialStatusId' => 'A', 'status' => ['A' => ['label' => 'Entry', 'transition' => 'A,B'], 'B' => ['label' => 'Published', 'transition' => ' A , B ']]]); verify($factory->getStatus('wid/A', null, null))->notNull(); verify($factory->getStatus('wid/B', null, null))->notNull(); verify(count($factory->getTransitions('wid/A', null, null)))->equals(2); }
/** * Tests adapter page 2 content. */ public function testGetSlicePage2() { $this->service->expects($this->any())->method('execute')->with($this->search)->will($this->returnValue(['hits' => ['total' => 4, 'hits' => [['_source' => ['id' => 'd3', 'field1' => 'value1']], ['_source' => ['id' => 'd4', 'field1' => 'value1']]]]])); $this->specify('getting page 2 results', function () { verify($this->adapter->getSlice(2, 2))->equals([['_source' => ['id' => 'd3', 'field1' => 'value1']], ['_source' => ['id' => 'd4', 'field1' => 'value1']]]); verify($this->adapter->getNbResults())->equals(4); }); }
public function Check($result) { if (verify($result)) { return true; } else { return false; } }
public function testOpeningTheFile() { $reader = $this->import->setCsvReader($this->import->file); verify( "Reading the file doesn't return an error", get_class($reader) )->equals("Ddeboer\\DataImport\\Reader\\CsvReader"); }
public function testIsValid() { $examples = [['secret', ['action' => 'checkOrder', 'orderSumAmount' => '87.10', 'orderSumCurrencyPaycash' => '643', 'orderSumBankPaycash' => '1001', 'shopId' => '13', 'invoiceId' => '1234567', 'customerNumber' => '8123294469', 'md5' => '6f58d99969865670ee52bbfd2c03fb90']], ['s<kY23653f,{9fcnshwq', ['action' => 'checkOrder', 'orderSumAmount' => '87.10', 'orderSumCurrencyPaycash' => '643', 'orderSumBankPaycash' => '1001', 'shopId' => '13', 'invoiceId' => '55', 'customerNumber' => '8123294469', 'md5' => '1B35ABE38AA54F2931B0C58646FD1321']]]; $this->specify('Request must be a valid if md5 is matching', function ($shopPassword, $requestData) { $request = $this->createRequest($shopPassword, $requestData); verify($request->isValid())->true(); }, ['examples' => $examples]); }
/** * */ public function testAssertGetClientId() { $this->specify('verify service can getClientId', function () { $service = new OAuth2Service($this->createAuthorizationServer(), $this->createResourceServer()); $service->validateAccessToken(true, self::$token['access_token']); verify($service->getClientId())->equals('test'); }); }
public function testServerCommand() { if (strtolower(PHP_OS) === 'linux') { $expectedCommand = 'exec php -S 127.0.0.1:8000 -t web'; } else { $expectedCommand = 'php -S 127.0.0.1:8000 -t web'; } verify($this->taskServer('8000')->host('127.0.0.1')->dir('web')->getCommand())->equals($expectedCommand); }
public function testServerCommand() { if (strtolower(PHP_OS) === 'linux') { $expectedCommand = 'exec php -S 127.0.0.1:8000 -t web'; } else { $expectedCommand = 'php -S 127.0.0.1:8000 -t web'; } verify((new \Robo\Task\Development\PhpServer('8000'))->host('127.0.0.1')->dir('web')->getCommand())->equals($expectedCommand); }