本文整理汇总了PHP中expect函数的典型用法代码示例。如果您正苦于以下问题:PHP expect函数的具体用法?PHP expect怎么用?PHP expect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了expect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testConstructSuccess
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);
});
}
示例2: testItems
public function testItems()
{
$this->specify("Попытка получить список операторов", function () {
$items = ['operator1' => 'Оператор 1', 'operator2' => 'Оператор 2'];
expect("Список должен состоять из пар идентификатор - имя", Operator::items())->equals($items);
});
}
示例3: testLoginCorrect
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();
}
示例4: testValidateCorrect
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();
});
}
示例5: testChangeUserName
public function testChangeUserName()
{
$user = User::find()->where(['username' => 'neo'])->one();
$user->username = "neozzz";
$user->save();
expect($user->username)->equals('neozzz');
}
示例6: itCallsTheDriverForConnexion
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);
}
示例7: itRemovesAllIncludedGroups
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);
}
示例8: testValidateCorrect
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();
});
}
示例9: itCallsTheRightOptions
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);
}
示例10: connectThrowsConnectionFailureOnFailure
/**
* @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);
}
示例11: testBatchRemoveForCompositePrimaryKey
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);
});
}
示例12: testToString
/**
* @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());
}
示例13: testTextDynamicStringCustomDelimeter
/**
* Tests the dynamic function
*
* @author Stanislav Kiryukhin <korsar.zn@gmail.com>
* @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);
}
示例14: itDelegatesTheDuplicationToTheDao
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);
}
示例15: itAddsDefaultProjectMappingIfProjectMappingDoesNotExist
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());
}