public function testConstructSuccess() { $this->specify('Workflow source construct default', function () { $src = new WorkflowFileSource(); expect($src->getClassMapByType(WorkflowFileSource::TYPE_WORKFLOW))->equals('raoul2000\\workflow\\base\\Workflow'); expect($src->getClassMapByType(WorkflowFileSource::TYPE_STATUS))->equals('raoul2000\\workflow\\base\\Status'); expect($src->getClassMapByType(WorkflowFileSource::TYPE_TRANSITION))->equals('raoul2000\\workflow\\base\\Transition'); expect($src->getDefinitionCache())->equals(null); expect($src->getDefinitionLoader())->notNull(); }); $this->specify('Workflow source construct with class map', function () { $src = new WorkflowFileSource(['classMap' => [WorkflowFileSource::TYPE_WORKFLOW => 'my\\namespace\\Workflow', WorkflowFileSource::TYPE_STATUS => 'my\\namespace\\Status', WorkflowFileSource::TYPE_TRANSITION => 'my\\namespace\\Transition']]); expect($src->getClassMapByType(WorkflowFileSource::TYPE_WORKFLOW))->equals('my\\namespace\\Workflow'); expect($src->getClassMapByType(WorkflowFileSource::TYPE_STATUS))->equals('my\\namespace\\Status'); expect($src->getClassMapByType(WorkflowFileSource::TYPE_TRANSITION))->equals('my\\namespace\\Transition'); }); $this->specify('Workflow source construct with cache', function () { // initialized by array $src = new WorkflowFileSource(['definitionCache' => ['class' => 'yii\\caching\\FileCache']]); expect_that($src->getDefinitionCache() instanceof yii\caching\FileCache); // initialized by component ID Yii::$app->set('myCache', ['class' => 'yii\\caching\\FileCache']); $src = new WorkflowFileSource(['definitionCache' => 'myCache']); expect_that($src->getDefinitionCache() instanceof yii\caching\FileCache); // initialized by object $cache = Yii::$app->get('myCache'); Yii::$app->set('myCache', ['class' => 'yii\\caching\\FileCache']); $src = new WorkflowFileSource(['definitionCache' => $cache]); expect_that($src->getDefinitionCache() instanceof yii\caching\FileCache); }); }
public function testItems() { $this->specify("Попытка получить список операторов", function () { $items = ['operator1' => 'Оператор 1', 'operator2' => 'Оператор 2']; expect("Список должен состоять из пар идентификатор - имя", Operator::items())->equals($items); }); }
public function testLoginCorrect() { $model = new LoginForm(['username' => 'bayer.hudson', 'password' => 'password_0']); expect('model should login user', $model->login())->true(); expect('error message should not be set', $model->errors)->hasntKey('password'); expect('user should be logged in', Yii::$app->user->isGuest)->false(); }
public function testValidateCorrect() { $model = new Article(['name' => 'name', 'text' => 'text', 'created_at' => 'created_at', 'updated_at' => 'updated_at', 'user_id' => null]); $this->specify('event wrong', function () use($model) { expect('model should not validate', $model->validate())->true(); }); }
public function testChangeUserName() { $user = User::find()->where(['username' => 'neo'])->one(); $user->username = "******"; $user->save(); expect($user->username)->equals('neozzz'); }
public function itCallsTheDriverForConnexion() { $openid_url = "https://www.google.com/accounts/o8/id"; $return_to_url = "http://example.net"; expect($this->driver)->connect($openid_url, $return_to_url)->once(); $this->connexion_manager->startAuthentication($openid_url, $return_to_url); }
public function itRemovesAllIncludedGroups() { $groupname = "parent group"; $url_get_members = $this->gerrit_server_host . ':' . $this->gerrit_server_port . '/a/groups/' . urlencode($groupname) . '/groups'; $response_with_included_groups = <<<EOS )]}' [ { "kind": "gerritcodereview#group", "url": "#/admin/groups/uuid-6ef56904c11e6d53c8f2f3657353faaac74bfc6d", "options": {}, "group_id": 7, "owner": "enalean", "owner_id": "6ef56904c11e6d53c8f2f3657353faaac74bfc6d", "id": "6ef56904c11e6d53c8f2f3657353faaac74bfc6d", "name": "enalean" }, { "kind": "gerritcodereview#group", "url": "#/admin/groups/uuid-b99e4455ca98f2ec23d9250f69617e34ceae6bd6", "options": {}, "group_id": 6, "owner": "another group", "owner_id": "b99e4455ca98f2ec23d9250f69617e34ceae6bd6", "id": "b99e4455ca98f2ec23d9250f69617e34ceae6bd6", "name": "another group" } ] EOS; stub($this->guzzle_client)->get($url_get_members, '*')->returns($this->getGuzzleRequestWithTextResponse($response_with_included_groups)); $url = $this->gerrit_server_host . ':' . $this->gerrit_server_port . '/a/groups/' . urlencode($groupname) . '/groups.delete'; expect($this->guzzle_client)->post($url, array(Git_Driver_GerritREST::HEADER_CONTENT_TYPE => Git_Driver_GerritREST::MIME_JSON, 'verify' => false), json_encode(array('groups' => array('enalean', 'another group'))))->once(); stub($this->guzzle_client)->post()->returns($this->guzzle_request); $this->driver->removeAllIncludedGroups($this->gerrit_server, $groupname); }
public function testValidateCorrect() { $model = new Event(['type' => 'Type', 'name' => 'Name', 'event' => 'Event', 'title' => 'Title']); $this->specify('event wrong', function () use($model) { expect('model should not validate', $model->validate())->true(); }); }
public function itCallsTheRightOptions() { $url = $this->gerrit_server_host . ':' . $this->gerrit_server_port . '/a/projects/' . urlencode($this->project_name); expect($this->guzzle_client)->get($url, '*')->once(); stub($this->guzzle_client)->get()->returns($this->guzzle_request); $this->driver->doesTheParentProjectExist($this->gerrit_server, $this->project_name); }
/** * @test * @since 6.0.0 */ public function connectThrowsConnectionFailureOnFailure() { $socket = createSocket('localhost', 80)->openWith(NewCallable::of('fsockopen')->mapCall(false)); expect(function () use($socket) { $socket->connect(); })->throws(ConnectionFailure::class); }
public function testBatchRemoveForCompositePrimaryKey() { $ids = []; $depart = new UserDepartmentAssignment(); $depart->userId = 1; $depart->departmentId = 2; $depart->save(false); $ids[] = ['userId' => $depart->userId, 'departmentId' => $depart->departmentId]; $depart = new UserDepartmentAssignment(); $depart->userId = 3; $depart->departmentId = 5; $depart->save(false); $ids[] = ['departmentId' => $depart->departmentId, 'userId' => $depart->userId]; for ($i = 0; $i < 2; $i++) { $depart = new UserDepartmentAssignment(); $depart->userId = $i + 1; $depart->departmentId = $i * 2; } Yii::$app->request->setBodyParams($ids); $this->specify('Remove a AR with single primary key', function () { $action = new BatchRemoveAction("batch-remove", null, ['modelClass' => 'tests\\codeception\\unit\\models\\base\\UserDepartmentAssignment']); $n = $action->run(); expect("Number of deleted records should be 2: ", $n)->equals(2); }); }
/** * @dataProvider values * @param $operator * @param $result * @param $expression */ public function testToString($operator, $result, $expression) { $operator = new Parentheses($operator); expect("expression " . $expression, $operator->render())->equals($expression); expect("expression " . $expression, (string) $operator)->equals($expression); codecept_debug($operator->render()); }
/** * Tests the dynamic function * * @author Stanislav Kiryukhin <*****@*****.**> * @since 2015-07-01 */ public function testTextDynamicStringCustomDelimeter() { $actual = PhTText::dynamic('(Hi|Hello), my name is a Bob!', '(', ')'); expect($actual)->notContains('('); expect($actual)->notContains(')'); expect(preg_match('/^(Hi|Hello), my name is a Bob!$/', $actual))->equals(1); }
public function itDelegatesTheDuplicationToTheDao() { $to_transition_id = 2; $field_mapping = array(); expect($this->dao)->duplicate($this->transition_id, $to_transition_id)->once(); $this->factory->duplicate($this->transition, $to_transition_id, $field_mapping); }
public function itAddsDefaultProjectMappingIfProjectMappingDoesNotExist() { $event = $this->aSystemEventWithParameter('101::103::2'); stub($this->actions)->checkProjectMappingExists(101)->returns(false); expect($this->actions)->initializeProjetMapping(101)->once(); $this->assertTrue($event->process()); }
public function itDelegatesFormattingToValues() { expect($this->v1)->fetchFormattedForJson()->once(); expect($this->v2)->fetchFormattedForJson()->once(); stub($this->bind)->getAllValues()->returns(array($this->v1, $this->v2)); $this->bind->fetchFormattedForJson(); }
public function testFileAdapter() { $translate = new File(DATA_PATH . '/i18n/en.php'); $this->specify('Adapter will load translations from php file that return array with key, value pairs', function () use($translate) { expect($translate->query('word.hello'))->equals('hello'); }); }
public function itStopsTheExecutionWhenThereIsARemainingSystemEventRunning() { stub($this->process_manager)->isAlreadyRunning($this->process)->returns(true); expect($this->response)->error('There is still an event marked as running. Start again when all events marked as running are done.')->once(); expect($this->response)->abort()->once(); $this->command->execute(); }
public function itSavesNothingIfThereAreNoProjectLanguageAndMoreThanOneSystemLanguage() { ForgeConfig::set('sys_supported_languages', 'it_IT,ja_JP'); stub($this->dao)->getUsedLanguageForProject()->returns(false); expect($this->dao)->updateLanguageOption()->never(); $this->language_manager->getUsedLanguageForProject($this->project); }
/** * Tests Mysql::escapeIdentifier * * @author Sid Roberts <*****@*****.**> * @since 2016-11-19 */ public function testEscapeIdentifier() { $this->specify('Identifiers are not properly escaped', function ($identifier, $expected) { $escapedIdentifier = $this->connection->escapeIdentifier($identifier); expect($escapedIdentifier)->equals($expected); }, ["examples" => [["identifier" => "robots", "expected" => "`robots`"], ["identifier" => ["schema", "robots"], "expected" => "`schema`.`robots`"], ["identifier" => "`robots`", "expected" => "```robots```"], ["identifier" => ["`schema`", "rob`ots"], "expected" => "```schema```.`rob``ots`"]]]); }
public function testNotLoginInactiveUser() { $model = new LoginForm(['accountName' => 'erau-inactive', 'password' => 'password_0']); expect('model should not login user', $model->login())->false(); expect('error message should be set', $model->errors)->hasKey('password'); expect('user should not be logged in', Yii::$app->user->isGuest)->true(); }
public function itExecutesTheNextCommand() { $next = mock('Git_GitoliteHousekeeping_ChainOfResponsibility_Command'); expect($next)->execute()->once(); $this->command->setNextCommand($next); $this->command->execute(); }
function it_runs_provided_command() { $script = __DIR__ . '/test-execution.sh'; $file_content = <<<'EOF' #! /bin/bash # Call this like # test-execution.sh path/to/tmpfile some argument "with args" for arg in "$@" do echo $arg >> $1; done EOF; file_put_contents($script, $file_content); chmod($script, 0755); $tmpfile = tempnam(sys_get_temp_dir(), 'command-test_'); $cmd = $script . ' ' . escapeshellarg($tmpfile) . ' some "argument with" arguments'; $this->subject->execute($cmd); $received_args = file_get_contents($tmpfile); $expected = <<<ARGS {$tmpfile} some argument with arguments ARGS; expect($received_args)->toBe($expected); unlink($tmpfile); unlink($script); }
public function itCallsTheArtifactLinkExporterAccordinglyToTheTypeOfTheChangesetValue() { expect($this->int_exporter)->export()->never(); expect($this->float_exporter)->export()->never(); expect($this->artlink_exporter)->export()->once(); $this->visitor->export($this->artifact_xml, $this->changeset_xml, mock('Tracker_Artifact'), $this->artlink_changeset_value); }
public function testLoginCorrect() { $this->_model = new LoginForm(['email' => '*****@*****.**', 'password' => '123123']); expect_that($this->_model->login()); expect_not(Yii::$app->user->isGuest); expect($this->_model->errors)->hasntKey('password'); }
public function itStoresTheLanguageIfThereIsOnlyOnePossibleLanguageForProject() { stub($this->language_manager)->getAvailableLanguages()->returns(array('en_US')); stub($this->language_manager)->getUsedLanguageForProject($this->project)->returns(null); expect($this->language_manager)->saveLanguageOption($this->project, 'en_US')->once(); $this->welcome_page_manager->displayWelcomePage($this->project, $this->request); }
/** * @Then I should be able to create empty images of width :width and height :height */ public function iShouldBeAbleToCreateEmptyImagesOfWidthAndHeight($width, $height) { $image = $this->fixturesGenerator->createEmptyImage($width, $height); expect($image instanceof Image)->toBe(true); expect($image->getWidth() == $width)->toBe(true); expect($image->getHeight() == $height)->toBe(true); }
public function itFallsBackToValueStringProcessing() { $soap_value = (object) array('field_name' => '', 'field_label' => '', 'field_value' => (object) array('value' => 'Bravo,Zoulou')); expect($this->bind)->getFieldData('Bravo,Zoulou', true)->once(); stub($this->bind)->getFieldData()->returns(array(1586, 2894)); $this->assertIdentical(array(1586, 2894), $this->field->getFieldDataFromSoapValue($soap_value)); }
public function testLoginCorrect() { $this->model = new LoginForm(['username' => 'demo', 'password' => 'demo']); expect_that($this->model->login()); expect_not(\Yii::$app->user->isGuest); expect($this->model->errors)->hasntKey('password'); }
/** * @Given /^I should see display with following fields$/ */ public function iShouldSeeDisplayWithFollowingFields(TableNode $table) { $display = $this->getPage('News display')->getElement('Display'); foreach ($table->getHash() as $row) { expect($display->hasFieldWithName($row['Field name']))->toBe(true); } }