/**
  * @test
  * it should apply number placeholder to taxonomy terms too
  */
 public function it_should_apply_number_placeholder_to_taxonomy_terms_too(FunctionalTester $I)
 {
     $postIds = $I->haveManyPostsInDatabase(3, ['terms' => ['taxonomy_{{n}}' => ['term_{{n}}']]]);
     for ($i = 0; $i < 3; $i++) {
         $termId = $I->grabTermIdFromDatabase(['name' => 'term_' . $i]);
         $termTaxonomyId = $I->grabTermTaxonomyIdFromDatabase(['term_id' => $termId, 'taxonomy' => 'taxonomy_' . $i]);
         $I->seeInDatabase($I->grabTermRelationshipsTableName(), ['object_id' => $postIds[$i], 'term_taxonomy_id' => $termTaxonomyId, 'term_order' => 0]);
         $I->seeInDatabase($I->grabTermTaxonomyTableName(), ['term_taxonomy_id' => $termTaxonomyId, 'taxonomy' => 'taxonomy_' . $i, 'count' => 1]);
     }
 }
Пример #2
0
 /**
  * @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)]);
         }
     }
 }
 public function memberCanReturnBox(FunctionalTester $I)
 {
     $I->am('a member');
     $I->wantTo('make sure I can return a box I own');
     //Load and login a known member
     $user = User::find(1);
     $I->amLoggedAs($user);
     //Setup a box a already claimed
     $box = \BB\Entities\StorageBox::first();
     $box->user_id = $user->id;
     $box->save();
     $I->amOnPage('/storage_boxes');
     //Make sure the db is correct
     $I->seeInDatabase('storage_boxes', ['user_id' => $user->id]);
     //The page should have our name next to the claimed box
     $I->see($user->name);
     $I->click('Return Box');
     //We should be gone from the DB
     $I->dontSeeInDatabase('storage_boxes', ['user_id' => $user->id]);
     $I->cantSee($user->name);
 }
Пример #4
0
 /**
  * @test
  * it should add the main site address by default
  */
 public function it_should_add_the_main_site_address_by_default(FunctionalTester $I)
 {
     $I->haveMultisiteInDatabase();
     $I->seeInDatabase($I->grabSiteTableName(), ['domain' => $I->getSiteDomain(), 'path' => '/']);
 }
Пример #5
0
 /**
  * @test
  * it should serialize object comment meta
  */
 public function it_should_serialize_object_comment_meta(FunctionalTester $I)
 {
     $postId = $I->havePostInDatabase();
     $commentId = $I->haveCommentInDatabase($postId);
     $meta = (object) ['one' => 1, 'two' => 2];
     $I->haveCommentMetaInDatabase($commentId, 'foo', $meta);
     $I->seeInDatabase($I->grabCommentmetaTableName(), ['comment_id' => $commentId, 'meta_key' => 'foo', 'meta_value' => serialize($meta)]);
 }
Пример #6
0
 /**
  * @test
  * it should allow having numbered meta for many posts using meta_input
  */
 public function it_should_allow_having_numbered_meta_for_many_posts_using_meta_input(FunctionalTester $I)
 {
     $meta = ['one_{{n}}' => 'meta {{n}}', 'two_{{n}}' => '{{n}} meta {{n}}'];
     $ids = $I->haveManyPostsInDatabase(3, ['meta_input' => $meta]);
     for ($i = 0; $i < 3; $i++) {
         $id = $ids[$i];
         $I->seeInDatabase($I->grabPostsTableName(), ['ID' => $id]);
         foreach ($meta as $meta_key => $meta_value) {
             $I->seeInDatabase($I->grabPostmetaTableName(), ['post_id' => $id, 'meta_key' => str_replace('{{n}}', $i, $meta_key), 'meta_value' => str_replace('{{n}}', $i, $meta_value)]);
         }
     }
 }
Пример #7
0
 /**
  * @test
  * it should allow setting an option in a secondary site
  */
 public function it_should_allow_setting_an_option_in_a_secondary_site(FunctionalTester $I)
 {
     $I->useBlog(2);
     $I->haveOptionInDatabase('key', 'value');
     $table = $I->grabPrefixedTableNameFor('options');
     $I->seeInDatabase($table, ['option_name' => 'key', 'option_value' => 'value']);
 }
$I = new FunctionalTester($scenario);
$I->am('an user');
$I->wantTo('Update my profile');
//setup
$I->amAuthenticatedWithCredentials();
$I->amOnAction('ProfileController@edit');
$user = \App\User::find(1);
//save
$_email = $user->email;
$_firstname = $user->profile->firstname;
$_lastname = $user->profile->lastname;
$_phone = $user->profile->phone;
//modify user
$I->fillField(['name' => 'email'], '*****@*****.**');
$I->fillField(['id' => 'firstname'], 'John');
$I->fillField(['id' => 'lastname'], 'Doe');
$I->fillField(['id' => 'phone'], '+33616391876');
$I->click('submit-edit');
$I->cantSeeInField(['name' => 'email'], $_email);
$I->cantSeeInField(['id' => 'firstname'], $_firstname);
$I->cantSeeInField(['id' => 'lastname'], $_lastname);
$I->cantSeeInField(['id' => 'phone'], $_phone);
//reset user test
$I->fillField(['name' => 'email'], $_email);
$I->fillField(['id' => 'firstname'], $_firstname);
$I->fillField(['id' => 'lastname'], $_lastname);
$I->fillField(['id' => 'phone'], $_phone);
$I->click('submit-edit');
$I->seeInDatabase('users', ['email' => $_email]);
$I->seeInDatabase('users_profiles', ['phone' => $_phone]);
Пример #9
0
 /**
  * @test
  * it should serialize meta value when adding array post meta
  */
 public function it_should_serialize_meta_value_when_adding_array_post_meta(FunctionalTester $I)
 {
     $id = $I->havePostInDatabase();
     $meta = ['one', 'two', 'three'];
     $I->havePostmetaInDatabase($id, 'foo', $meta);
     $I->seeInDatabase($I->grabPostmetaTableName(), ['post_id' => $id, 'meta_key' => 'foo', 'meta_value' => serialize($meta)]);
 }
Пример #10
0
<?php

$I = new FunctionalTester($scenario);
$I->am('an administrator');
$I->wantTo('add a new user');
Auth::loginUsingId(1);
$I->amOnPage('/admin/users/create');
$I->submitForm('//form', ['name' => 'Tom', 'email' => '*****@*****.**']);
$I->see('En epost er sendt');
$I->seeInDatabase('users', ['email' => '*****@*****.**', 'rights' => '[]']);
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('register for a new account');
$I->lookForwardTo('be a member');
$I->amOnPage('/register');
$I->see('Register', 'h1');
$I->fillField('Email:', '*****@*****.**');
$I->fillField('Password:'******'1234');
$I->click('Register Now');
$I->seeCurrentUrlEquals('/login');
$I->see('You may now sign in!', '.flash');
$I->seeInDatabase('users', ['email' => '*****@*****.**']);
 /**
  * Confirm the gocardless method gets correctly called
  *
  * @param FunctionalTester $I
  */
 public function chargeAndBillUser(FunctionalTester $I)
 {
     $authId = str_random();
     $amount = rand(5, 30);
     $userId = 31;
     $chargeDate = Carbon::now()->day(10);
     //Generate helper mock
     $goCardlessHelper = m::mock('\\BB\\Helpers\\GoCardlessHelper');
     $goCardlessHelper->shouldReceive('getNameFromReason')->withArgs(['subscription'])->once()->andReturn('Subscription');
     $goCardlessHelper->shouldReceive('newBill')->withArgs([$authId, $amount, 'Subscription'])->once()->andReturn(false);
     $repo = new \BB\Repo\SubscriptionChargeRepository(app('\\BB\\Entities\\SubscriptionCharge'), app('\\BB\\Repo\\PaymentRepository'), $goCardlessHelper);
     //Call the method and confirm the mock gets called correctly
     $repo->createChargeAndBillDD($userId, $chargeDate, $amount, 'processing', $authId);
     $I->seeInDatabase('subscription_charge', ['user_id' => $userId, 'amount' => $amount]);
 }
 /**
  * Payment status change updates sub charge
  *
  * @param FunctionalTester $I
  */
 public function paymentStatusSubChargeChange(FunctionalTester $I)
 {
     $I->haveInDatabase('users', ['id' => 17, 'active' => 1, 'status' => 'active', 'monthly_subscription' => 15]);
     $subChargeRepo = App::make('\\BB\\Repo\\SubscriptionChargeRepository');
     $paymentRepo = new \BB\Repo\PaymentRepository(new \BB\Entities\Payment());
     $subChargeDate = Carbon::create(2015, 1, 10, 0, 0, 0);
     $subCharge = $subChargeRepo->createCharge(17, $subChargeDate, 0, 'due');
     //Sub charge is due
     $I->seeInDatabase('subscription_charge', ['id' => $subCharge->id, 'status' => 'due', 'amount' => 0]);
     $paymentId = $paymentRepo->recordSubscriptionPayment(17, 'test', 1, 10, 'pending');
     $I->seeInDatabase('payments', ['id' => $paymentId, 'reason' => 'subscription', 'source' => 'test', 'reference' => $subCharge->id, 'status' => 'pending']);
     //When a payment has started the sub charge should be processing
     $I->seeInDatabase('subscription_charge', ['id' => $subCharge->id, 'status' => 'processing', 'amount' => 10]);
     $paymentDate = Carbon::create(2015, 1, 18, 0, 0, 0);
     $paymentRepo->markPaymentPaid($paymentId, $paymentDate);
     $I->seeInDatabase('payments', ['id' => $paymentId, 'reason' => 'subscription', 'source' => 'test', 'reference' => $subCharge->id, 'status' => 'paid']);
     //When the payment is paid the charge should be paid with a value and date
     $I->seeInDatabase('subscription_charge', ['id' => $subCharge->id, 'status' => 'paid', 'amount' => 10, 'payment_date' => $paymentDate->format('Y-m-d')]);
 }
Пример #14
0
 public function it_can_have_users(FunctionalTester $I)
 {
     $I->wantTo('have a user');
     $I->haveUserInDatabase('someUser', 23);
     $I->seeInDatabase('wp_users', ['ID' => 23, 'user_login' => 'someUser']);
 }
Пример #15
0
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('sign in');
$I->amOnPage('user/login');
$I->fillField('email', '*****@*****.**');
$I->fillField('password', 'adminn');
$I->click('.btn-primary');
$I->amOnPage('/');
$I->see('admin');
$I->see('PHP');
$I->seeInDatabase('users', ['email' => '*****@*****.**']);
$I->seeRecord('users', ['email' => '*****@*****.**']);
Пример #16
0
 /**
  * @test
  * it should serialize object user meta in database
  */
 public function it_should_serialize_object_user_meta_in_database(FunctionalTester $I)
 {
     $I->haveUserInDatabase('Luca');
     $userId = $I->grabUserIdFromDatabase('Luca');
     $meta = (object) ['foo' => 'bar', 'one' => 23];
     $I->haveUserMetaInDatabase($userId, 'foo', $meta);
     $table = $I->grabPrefixedTableNameFor('usermeta');
     $I->seeInDatabase($table, ['user_id' => $userId, 'meta_key' => 'foo', 'meta_value' => serialize($meta)]);
 }
Пример #17
0
<?php

$I = new FunctionalTester($scenario);
$I->am('a member');
$I->wantTo('set aside lessons to watch later');
$I->amOnPage('/lessons');
$I->click('.watch-later');
$I->seeInDatabase('watch_later', ['lesson_id' => 5]);
$I->amOnPage('/saves');
$I->see('lesson');
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('create a new user from the command line');
$I->runShellCommand('php artisan create:user superadmin@email.com "Super Admin" --admin');
$I->seeInShellOutput('User created');
$I->seeInDatabase('users', ['email' => '*****@*****.**', 'rights' => '["admin"]']);