diff --git a/app/User.php b/app/User.php index 7ce7ea0ec81..ca72f312f0b 100644 --- a/app/User.php +++ b/app/User.php @@ -10,7 +10,7 @@ class User extends Authenticatable { - use Notifiable,HasApiTokens; + use Notifiable, HasApiTokens; /** * The attributes that are mass assignable. diff --git a/composer.lock b/composer.lock index 4edff7f3aa2..f59cc1bca4f 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "aws/aws-sdk-php", - "version": "3.51.0", + "version": "3.52.0", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "a932a76e110dc2c65c216de21a1aa65e151d21ef" + "reference": "1bc98d7f1f4b6ffb3c54d6a854d5ee5b7137e220" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/a932a76e110dc2c65c216de21a1aa65e151d21ef", - "reference": "a932a76e110dc2c65c216de21a1aa65e151d21ef", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/1bc98d7f1f4b6ffb3c54d6a854d5ee5b7137e220", + "reference": "1bc98d7f1f4b6ffb3c54d6a854d5ee5b7137e220", "shasum": "" }, "require": { @@ -84,7 +84,7 @@ "s3", "sdk" ], - "time": "2018-01-19T20:32:42+00:00" + "time": "2018-01-22T22:20:45+00:00" }, { "name": "bacon/bacon-qr-code", @@ -3249,12 +3249,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "402a514551804df5b4b2150f217e23a15408795a" + "reference": "eca509e364dcea7b7f41f9452d575684cc8e3fb4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/402a514551804df5b4b2150f217e23a15408795a", - "reference": "402a514551804df5b4b2150f217e23a15408795a", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/eca509e364dcea7b7f41f9452d575684cc8e3fb4", + "reference": "eca509e364dcea7b7f41f9452d575684cc8e3fb4", "shasum": "" }, "conflict": { @@ -3309,7 +3309,7 @@ "phpxmlrpc/extras": "<0.6.1", "pusher/pusher-php-server": "<2.2.1", "sabre/dav": ">=1.6,<1.6.99|>=1.7,<1.7.11|>=1.8,<1.8.9", - "shopware/shopware": "<5.2.25", + "shopware/shopware": "<5.3.7", "silverstripe/cms": ">=3,<=3.0.11|>=3.1,<3.1.11", "silverstripe/forum": "<=0.6.1|>=0.7,<=0.7.3", "silverstripe/framework": ">=3,<3.3", @@ -3338,7 +3338,7 @@ "symfony/web-profiler-bundle": ">=2,<2.3.19|>=2.4,<2.4.9|>=2.5,<2.5.4", "symfony/yaml": ">=2,<2.0.22|>=2.1,<2.1.7", "thelia/backoffice-default-template": ">=2.1,<2.1.2", - "thelia/thelia": ">=2.1,<2.1.2|>=2.1.0-beta1,<2.1.3", + "thelia/thelia": ">=2.1.0-beta1,<2.1.3|>=2.1,<2.1.2", "twig/twig": "<1.20", "typo3/cms": ">=6.2,<6.2.30|>=7,<7.6.22|>=8,<8.7.5", "typo3/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.10|>=3.1,<3.1.7|>=3.2,<3.2.7|>=3.3,<3.3.5", @@ -3387,7 +3387,7 @@ } ], "description": "Prevents installation of composer packages with known security vulnerabilities: no API, simply require it", - "time": "2018-01-18T10:00:53+00:00" + "time": "2018-01-22T14:51:56+00:00" }, { "name": "sabberworm/php-css-parser", diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 21ef8d289b9..201fb297430 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -146,6 +146,18 @@ ]; }); +$factory->define(App\Day::class, function (Faker\Generator $faker) { + return [ + 'account_id' => 1, + ]; +}); + +$factory->define(App\Tag::class, function (Faker\Generator $faker) { + return [ + 'account_id' => 1, + ]; +}); + $factory->define(App\ContactFieldType::class, function (Faker\Generator $faker) { return [ 'id' => 1, diff --git a/tests/Unit/PetCategoryTest.php b/tests/Unit/PetCategoryTest.php new file mode 100644 index 00000000000..c4151159da9 --- /dev/null +++ b/tests/Unit/PetCategoryTest.php @@ -0,0 +1,33 @@ +assertEquals( + 3, + $petCategory->common()->count() + ); + } + + public function test_it_gets_pet_category_name() + { + $petCategory = new PetCategory; + $petCategory->name = 'Rgis'; + + $this->assertEquals( + 'Rgis', + $petCategory->name + ); + } +} diff --git a/tests/Unit/ReminderTest.php b/tests/Unit/ReminderTest.php index 8920a63350f..05f85214dfe 100644 --- a/tests/Unit/ReminderTest.php +++ b/tests/Unit/ReminderTest.php @@ -61,8 +61,14 @@ public function test_calculate_next_expected_date() $reminder->next_expected_date = '1980-01-01 10:10:10'; $reminder->frequency_number = 1; - Carbon::setTestNow(Carbon::create(2017, 1, 1)); + Carbon::setTestNow(Carbon::create(1980, 1, 1)); + $reminder->frequency_type = 'week'; + $this->assertEquals( + '1980-01-08', + $reminder->calculateNextExpectedDate($timezone)->next_expected_date->toDateString() + ); + Carbon::setTestNow(Carbon::create(2017, 1, 1)); // from 1980, incrementing one week will lead to Jan 03, 2017 $reminder->frequency_type = 'week'; $this->assertEquals( diff --git a/tests/Unit/TagTest.php b/tests/Unit/TagTest.php new file mode 100644 index 00000000000..fdcadd9d99c --- /dev/null +++ b/tests/Unit/TagTest.php @@ -0,0 +1,24 @@ +create(['name' => 'this is great']); + + $tag->updateSlug(); + + $this->assertEquals( + 'this-is-great', + $tag->name_slug + ); + } +} diff --git a/tests/Unit/UserTest.php b/tests/Unit/UserTest.php index 2844219946e..918202003fc 100644 --- a/tests/Unit/UserTest.php +++ b/tests/Unit/UserTest.php @@ -3,6 +3,7 @@ namespace Tests\Unit; use App\User; +use App\Account; use Tests\TestCase; use Illuminate\Foundation\Testing\DatabaseTransactions; @@ -38,4 +39,53 @@ public function test_name_accessor_returns_name_in_the_user_preferred_way() $user->name, 'Doe John' ); } + + public function test_it_gets_the_right_metric_symbol() + { + $user = new User; + $user->metric = 'fahrenheit'; + + $this->assertEquals( + 'F', $user->getMetricSymbol() + ); + + $user->metric = 'celsius'; + $this->assertEquals( + 'C', $user->getMetricSymbol() + ); + } + + public function test_you_can_vote_if_you_havent_voted_yet_today() + { + $account = factory(Account::class)->create([]); + $user = factory('App\User')->create(['account_id' => $account->id]); + + $this->assertFalse($user->hasAlreadyRatedToday()); + } + + public function test_you_cant_vote_if_you_have_already_voted_today() + { + $account = factory(Account::class)->create([]); + $user = factory('App\User')->create(['account_id' => $account->id]); + $day = factory('App\Day')->create([ + 'account_id' => $account->id, + 'date' => \Carbon\Carbon::now(), + ]); + + $this->assertTrue($user->hasAlreadyRatedToday()); + } + + public function test_it_gets_2fa_secret_attribute() + { + $user = new User; + + $this->assertNull($user->getGoogle2faSecretAttribute(null)); + + $string = 'pass1234'; + + $this->assertEquals( + $string, + $user->getGoogle2faSecretAttribute(encrypt($string)) + ); + } }