コード例 #1
0
ファイル: WPDbPostCest.php プロジェクト: lucatume/wp-browser
 /**
  * @test
  * it should allow inserting many posts and return an array of ids
  */
 public function it_should_allow_inserting_many_posts_and_return_an_array_of_ids(FunctionalTester $I)
 {
     $ids = $I->haveManyPostsInDatabase(5);
     $I->assertEquals(5, count(array_unique($ids)));
     array_map(function ($id) use($I) {
         $I->assertTrue(is_int($id));
     }, $ids);
 }
コード例 #2
0
 public function GetTimestamp(Tester $I)
 {
     $I->wantTo('Get Current Server Timestamp, make sure it is smaller than local');
     $I->haveHttpHeader("apikey", $this->apiInfo[Helper::CSV_ORDER_APIKEY]);
     $I->sendGET("currenttime", ["source" => $this->apiInfo[Helper::CSV_ORDER_SOURCE]]);
     $response = $I->grabResponse();
     $timeDifference = time() - intval($response);
     $I->assertTrue($timeDifference < 90 && $timeDifference > -90);
 }
コード例 #3
0
ファイル: WPDbLinksCest.php プロジェクト: lucatume/wp-browser
 /**
  * @test
  * it should allow using number placeholder when inserting many
  */
 public function it_should_allow_using_number_placeholder_when_inserting_many(FunctionalTester $I)
 {
     $overrides = ['link_url' => 'http://example.com/{{n}}', 'link_name' => 'Example {{n}}', 'link_image' => 'http://example.com/images/image-{{n}}.jpg', 'link_target' => '_blank', 'link_description' => '{{n}} example link', 'link_visible' => 'N', 'link_owner' => 12, 'link_rating' => 14, 'link_updated' => Date::fromString('today'), 'link_rel' => 'nofollow', 'link_notes' => 'Not a real {{n}} image', 'link_rss' => 'http://example.com/rss/{{n}}'];
     $ids = $I->haveManyLinksInDatabase(5, $overrides);
     $table = $I->grabLinksTableName();
     for ($i = 0; $i < count($ids); $i++) {
         $I->assertTrue(is_int($ids[$i]));
         foreach ($overrides as $key => $value) {
             $I->seeInDatabase($table, ['link_id' => $ids[$i], $key => str_replace('{{n}}', $i, $value)]);
         }
     }
 }
コード例 #4
0
 public function canRecordPhoto(FunctionalTester $I)
 {
     $I->am('a developer');
     $I->wantTo('ensure photos get recorded in the db');
     $equipment = \BB\Entities\Equipment::findOrFail(2);
     $I->assertTrue(is_array($equipment->photos), "The photos element is an array");
     $I->assertEquals(0, count($equipment->photos), 'Should have no photos');
     $equipment->addPhoto('foo.png');
     $equipment = \BB\Entities\Equipment::findOrFail(2);
     $I->assertEquals(1, count($equipment->photos), 'Should have 1 photo');
     $equipment->addPhoto('bar.png');
     $equipment = \BB\Entities\Equipment::findOrFail(2);
     $I->assertEquals(2, count($equipment->photos), 'Should have 2 photos');
     $I->assertEquals([['path' => 'foo.png'], ['path' => 'bar.png']], $equipment->photos, 'Should contain photo paths');
 }
コード例 #5
0
 /**
  * Checks that the minimum password requirement is working as expected (IS-21).
  *
  * @param FunctionalTester $I
  */
 public function testTheMinimumPasswordLength(FunctionalTester $I)
 {
     // assert that the property exists
     $I->assertTrue(isset(Yii::$app->user->minPasswordLength));
     // assert that the default value of the property is 6
     $I->assertEquals(6, Yii::$app->user->minPasswordLength);
     // try to register a user with a shorter password
     $registerPage = RegisterPage::openBy($I);
     $registerPage->register(Commons::TEST_EMAIL, '12345');
     // it must fail
     $I->see('Password should contain at least 6 characters.');
     $I->dontSeeRecord(User::className(), ['email' => Commons::TEST_EMAIL]);
     // try to register a user with a correct password length
     $registerPage->register(Commons::TEST_EMAIL, 'Innologica!23');
     // it must pass
     $I->seeRecord(User::className(), ['email' => Commons::TEST_EMAIL]);
 }
コード例 #6
0
 public function filterResponse(FunctionalTester $I)
 {
     $port = $I->openProxy();
     $I->assertNotNull($port, "`{$port}` is not a valid port");
     $rep = $I->filterResponse("contents.setTextContents('<html><body>Response successfully intercepted</body></html>');");
     $I->assertTrue($rep);
     $I->closeProxy();
 }
コード例 #7
0
<?php

$I = new FunctionalTester($scenario);
$I->am('a guest');
$I->wantTo('sign up for a Larabook account');
$I->amOnPage('/');
$I->click('Sign Up!');
$I->seeCurrentUrlEquals('/register');
$I->fillField('Username:'******'JohnDoe');
$I->fillField('Email:', '*****@*****.**');
$I->fillField('Password:'******'demo');
$I->fillField('Password Confirmation:', 'demo');
$I->click(['class' => 'submitbutton']);
$I->seeCurrentUrlEquals('');
$I->see('Welcome to Larabook!');
$I->seeRecord('users', ['username' => 'JohnDoe', 'email' => '*****@*****.**']);
$I->assertTrue(Auth::check());
コード例 #8
0
 /**
  * @test
  * it should allow having comment meta in the database
  */
 public function it_should_allow_having_comment_meta_in_the_database(FunctionalTester $I)
 {
     $postId = $I->havePostInDatabase();
     $commentId = $I->haveCommentInDatabase($postId);
     $metaId = $I->haveCommentMetaInDatabase($commentId, 'foo', 'bar');
     $I->assertTrue(!empty($metaId) && is_int($metaId));
     $I->seeInDatabase($I->grabCommentmetaTableName(), ['comment_id' => $commentId, 'meta_key' => 'foo', 'meta_value' => 'bar']);
 }
コード例 #9
0
<?php

$I = new FunctionalTester($scenario);
$rabman = new \Rabman\ResourceFactory(\Codeception\Util\Fixtures::get('rabman-opt'));
$items = $rabman->nodes()->columns(['exchange_types.name']);
$count = count($items);
$I->assertTrue($count > 0);
$expected = [['name' => 'direct'], ['name' => 'headers'], ['name' => 'topic'], ['name' => 'fanout']];
$I->assertEquals($expected, $items[0]['exchange_types']);
コード例 #10
0
ファイル: WPDbUserCest.php プロジェクト: lucatume/wp-browser
 /**
  * @test
  * it should replace number placeholder when having many users
  */
 public function it_should_replace_number_placeholder_when_having_many_users(FunctionalTester $I)
 {
     $ids = $I->haveManyUsersInDatabase(5, 'user_{{n}}_login');
     for ($i = 0; $i < 5; $i++) {
         $I->assertTrue(is_int($ids[$i]));
         $I->seeUserInDatabase(['ID' => $ids[$i], 'user_login' => 'user_' . $i . '_login']);
     }
 }
コード例 #11
0
 public function cancelOutstandingCharges(FunctionalTester $I)
 {
     $repo = app('\\BB\\Repo\\SubscriptionChargeRepository');
     /** @var \BB\Repo\SubscriptionChargeRepository $repo */
     $userId = 30;
     $amount = rand(5, 30);
     $chargeDate1 = Carbon::now()->subMonth();
     $chargeDate2 = Carbon::now();
     $repo->createCharge($userId, $chargeDate1, $amount, 'due');
     $repo->createCharge($userId, $chargeDate2, $amount);
     $I->assertTrue($repo->hasOutstandingCharges($userId), 'No outstanding charges found');
     $repo->cancelOutstandingCharges($userId);
     $I->assertFalse($repo->hasOutstandingCharges($userId), 'Outstanding charges found');
 }
コード例 #12
0
 /**
  * @env nochecking
  * @depends openConnectionPassword
  */
 public function closeConnection(FunctionalTester $I)
 {
     $I->openConnection('localhost', 32768, SecureShell::AUTH_PASSWORD, 'root', 'password');
     $I->assertTrue($I->closeConnection());
 }
コード例 #13
0
ファイル: UserCest.php プロジェクト: Okipa/una.app
 public function update_my_personal_profile_with_changes(FunctionalTester $I)
 {
     $I->am('Admin');
     $I->wantTo('update my profile and change some informations');
     $I->expectTo('see a success confirmation message and see that my data have changed');
     /***************************************************************************************************************
      * settings
      **************************************************************************************************************/
     // we create the admin role
     $admin_role = $this->_createAdminRole();
     // we attach it to the logged user
     $admin_role->users()->attach($this->_user);
     /***************************************************************************************************************
      * run test
      **************************************************************************************************************/
     $I->amOnPage('/');
     $I->amOnRoute('users.profile');
     $I->see(trans('users.page.title.profile'), 'h2');
     $I->selectOption('gender', config('user.gender_key.male'));
     $I->fillField('last_name', 'OTHER');
     $I->fillField('first_name', 'Other');
     $I->fillField('birth_date', '01/01/1999');
     $I->fillField('phone_number', '0101010101');
     $I->fillField('email', '*****@*****.**');
     $I->fillField('address', '1 impasse Commandant Cousteau');
     $I->fillField('zip_code', 99456);
     $I->fillField('city', 'Toulon');
     $I->fillField('country', 'Maroc');
     $I->fillField('password', 'password');
     $I->fillField('password_confirmation', 'password');
     $I->click(trans('global.action.save'));
     $I->seeCurrentRouteIs('users.profile');
     $I->see(trans('global.modal.alert.title.success'), 'h3');
     $I->see(trans('users.message.account.success'));
     $this->_user->fresh();
     $I->seeRecord('users', ['last_name' => 'OTHER', 'first_name' => 'Other', 'gender' => config('user.gender_key.male'), 'birth_date' => '1999-01-01', 'status_id' => $this->_user->status_id, 'board_id' => $this->_user->board_id, 'phone_number' => '+33 1 01 01 01 01', 'email' => '*****@*****.**', 'address' => '1 impasse Commandant Cousteau', 'zip_code' => 99456, 'city' => 'Toulon', 'country' => 'Maroc']);
     $I->seeRecord('role_users', ['user_id' => $this->_user->id, 'role_id' => Sentinel::findRoleBySlug('admin')->id]);
     $I->seeRecord('activations', ['user_id' => $this->_user->id, 'completed' => true]);
     $user = Sentinel::getUserRepository()->findByCredentials(['email' => '*****@*****.**']);
     $I->assertTrue(Hash::check('test', $user->password));
 }
コード例 #14
0
<?php

/* @var $scenario Codeception\Scenario */
$I = new FunctionalTester($scenario);
$I->assertTrue(Yii::$app->user->isGuest);
$I->wantTo('ensure that home page works');
$I->amOnPage('/');
$I->dontSee('Logout');
$I->see('Main');
$I->see('Login');
$I->click('Main');
$I->dontSee('Logout');
$I->see('Main');
$I->see('Login');
$user = \app\models\User::findByUsername('admin');
Yii::$app->user->login($user);
$I->assertFalse(Yii::$app->user->isGuest);
$I->amOnPage('/');
$I->see('I`m index');
$I->see('About');
$I->see('Logout');
$I->click('About');
$I->see('Information');
コード例 #15
0
 public function it_creates_default_permission_for_all_roles(FunctionalTester $I)
 {
     $roles = Role::all();
     foreach ($roles as $role) {
         $rolePermissions = RolePermission::where('role_id', '=', $role->id)->with('permission')->get();
         $I->assertTrue($rolePermissions->count() >= 1, 'Each role should have a default permission.');
     }
 }
コード例 #16
0
<?php

$I = new FunctionalTester($scenario);
$I->am('a guest');
$I->wantTo('sign up for a Larabook account');
$I->amOnPage('/');
$I->click('Sign Up');
$I->seeCurrentUrlEquals('/register');
$I->fillField('Username:'******'JohnDoe');
$I->fillField('Email:', '*****@*****.**');
$I->fillField('Password:'******'password');
$I->fillField('Password Confirmation:', 'password');
$I->click('Sign Up');
$I->seeCurrentUrlEquals('');
$I->see('Glad to have you as a new Larabook member');
$I->seeRecord('users', ['username' => 'JohnDoe']);
$I->assertTrue(Auth::check(), 'The user is logged in');