Skip to content

Commit

Permalink
Merge branch 'develop' into develop-asset-gen-optimisation
Browse files Browse the repository at this point in the history
  • Loading branch information
Silic0nS0ldier committed Mar 14, 2020
2 parents cdbb770 + d261eba commit f831c29
Show file tree
Hide file tree
Showing 61 changed files with 248 additions and 272 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Ignores text editor metadata
*.komodoproject
.php_cs.cache
.serenata
.vscode

# Ignores Mac metadata. You can configure this globally if you use a Mac: http://islegend.com/development/setting-global-gitignore-mac-windows/
.DS_Store
Expand Down Expand Up @@ -73,6 +72,10 @@ app/assets/*
vagrant/Homestead/
.vagrant/*

# Ignore dev utils cache
.phpunit.result.cache
.php_cs.cache

# Igore npm lockfile
build/package-lock.json
build/package.lock
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Changed Composer Dependencies
- Reset Slim version to ^3.12
- Updated PHPUnit to 8.5 (Version 7.5 still used for PHP 7.1)

### Added
- PHP 7.4 Support & Travis environment.
- New `Locale` service. Provides a list of available locales in diffeent form.
- New `BaseServicesProvider` abstract class added as base for all ServiceProvider class.
- Sprinkle Services Provider can now be autoloaded using the `$servicesproviders` property in the sprinkle bootstrapper class.
- Current locale code can now be accessed from Twig using the `currentLocale` global variable [(#1056)].
- Current locale code can now be accessed from Twig using the `currentLocale` global variable ([#1056]).
- Locale now have config & metadata file ([#850])
- Added `locale:compare`, `locale:dictionary` and `locale:info` Bakery commands.
- New `cli` service. Returns true if current app is a CLI envrionement, false otherwise.

### Changed
- `Interop\Container\ContainerInterface` has been replaced with `Psr\Container\ContainerInterface`.
Expand All @@ -37,6 +39,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Improved Bakery debug command output
- Improve ordering by activity date ([#1061] & [#1062]; Thanks @ktecho!)
- Updated Vagrant config and documentation
- Fixed a bug where `withTrashed` in `findUnique` was not available when `SoftDeletes` trait is not included in a model.
- CSRF global middleware is not loaded anymore if in a CLI envrionement. This will avoid sessions to be created for bakery and tests by default.

### Removed
- Running of Browserify against node package entrypoints citing foundational flaw in implementation.
Expand Down
2 changes: 1 addition & 1 deletion app/sprinkles/account/src/Rememberme/PDOStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
class PDOStorage implements StorageInterface
{
/** @var Capsule $db */
/** @var Capsule */
protected $db;

/**
Expand Down
37 changes: 20 additions & 17 deletions app/sprinkles/account/tests/Integration/AuthenticatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
namespace UserFrosting\Sprinkle\Account\Tests\Integration;

use UserFrosting\Sprinkle\Account\Authenticate\Authenticator;
use UserFrosting\Sprinkle\Account\Authenticate\Exception\AccountDisabledException;
use UserFrosting\Sprinkle\Account\Authenticate\Exception\AccountInvalidException;
use UserFrosting\Sprinkle\Account\Authenticate\Exception\AccountNotVerifiedException;
use UserFrosting\Sprinkle\Account\Authenticate\Exception\InvalidCredentialsException;
use UserFrosting\Sprinkle\Account\Facades\Password;
use UserFrosting\Sprinkle\Account\Tests\withTestUser;
use UserFrosting\Sprinkle\Core\Database\Models\Session as SessionTable;
Expand All @@ -34,7 +38,7 @@ class AuthenticatorTest extends TestCase
/**
* Setup the test database.
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -134,11 +138,11 @@ public function testLoginWithSessionDatabase(Authenticator $authenticator)

/**
* @depends testConstructor
* @expectedException \UserFrosting\Sprinkle\Account\Authenticate\Exception\AccountInvalidException
* @param Authenticator $authenticator
*/
public function testValidateUserAccountThrowAccountInvalidException(Authenticator $authenticator)
{
$this->expectException(AccountInvalidException::class);
$this->invokeMethod($authenticator, 'validateUserAccount', [99999999]);
}

Expand All @@ -154,11 +158,11 @@ public function testValidateUserAccountRetunNullOnFalseArgument(Authenticator $a

/**
* @depends testConstructor
* @expectedException \UserFrosting\Sprinkle\Account\Authenticate\Exception\AccountInvalidException
* @param Authenticator $authenticator
*/
public function testValidateUserAccountThrowExceptionArgumentNotInt(Authenticator $authenticator)
{
$this->expectException(AccountInvalidException::class);
$this->invokeMethod($authenticator, 'validateUserAccount', ['stringIsNotInt']);
}

Expand All @@ -170,21 +174,20 @@ public function testValidateUserAccount(Authenticator $authenticator)
{
$testUser = $this->createTestUser();
$user = $this->invokeMethod($authenticator, 'validateUserAccount', [$testUser->id]);
$testUserId = $testUser->id;
$userId = $user->id;
$this->assertSame($testUserId, $userId);
$this->assertSame($testUser->id, $user->id);
}

/**
* @depends testConstructor
* @expectedException \UserFrosting\Sprinkle\Account\Authenticate\Exception\AccountDisabledException
* @param Authenticator $authenticator
*/
public function testValidateUserAccountWithAccountDisabledException(Authenticator $authenticator)
{
$testUser = $this->createTestUser();
$testUser->flag_enabled = false;
$testUser->save();

$this->expectException(AccountDisabledException::class);
$this->invokeMethod($authenticator, 'validateUserAccount', [$testUser->id]);
}

Expand Down Expand Up @@ -277,30 +280,29 @@ public function testAttempt_withEmail(Authenticator $authenticator)
/**
* @depends testConstructor
* @depends testAttempt_withUserName
* @expectedException \UserFrosting\Sprinkle\Account\Authenticate\Exception\InvalidCredentialsException
* @param Authenticator $authenticator
*/
public function testAttempt_withNoUser(Authenticator $authenticator)
{
$currentUser = $authenticator->attempt('user_name', 'fooBar', 'barFoo', false);
$this->expectException(InvalidCredentialsException::class);
$authenticator->attempt('user_name', 'fooBar', 'barFoo', false);
}

/**
* @depends testConstructor
* @depends testAttempt_withUserName
* @expectedException \UserFrosting\Sprinkle\Account\Authenticate\Exception\InvalidCredentialsException
* @param Authenticator $authenticator
*/
public function testAttempt_withNoPassword(Authenticator $authenticator)
{
$testUser = $this->createTestUser(false, false, ['password' => '']);
$currentUser = $authenticator->attempt('email', $testUser->email, 'fooBar', false);
$this->expectException(InvalidCredentialsException::class);
$authenticator->attempt('email', $testUser->email, 'fooBar', false);
}

/**
* @depends testConstructor
* @depends testAttempt_withUserName
* @expectedException \UserFrosting\Sprinkle\Account\Authenticate\Exception\AccountDisabledException
* @param Authenticator $authenticator
*/
public function testAttempt_withFlagEnabledFalse(Authenticator $authenticator)
Expand All @@ -311,13 +313,13 @@ public function testAttempt_withFlagEnabledFalse(Authenticator $authenticator)
'flag_enabled' => 0,
]);

$currentUser = $authenticator->attempt('user_name', $testUser->user_name, $password, false);
$this->expectException(AccountDisabledException::class);
$authenticator->attempt('user_name', $testUser->user_name, $password, false);
}

/**
* @depends testConstructor
* @depends testAttempt_withUserName
* @expectedException \UserFrosting\Sprinkle\Account\Authenticate\Exception\AccountNotVerifiedException
* @param Authenticator $authenticator
*/
public function testAttempt_withFlagVerifiedFalse(Authenticator $authenticator)
Expand All @@ -328,7 +330,8 @@ public function testAttempt_withFlagVerifiedFalse(Authenticator $authenticator)
'flag_verified' => 0,
]);

$currentUser = $authenticator->attempt('user_name', $testUser->user_name, $password, false);
$this->expectException(AccountNotVerifiedException::class);
$authenticator->attempt('user_name', $testUser->user_name, $password, false);
}

/**
Expand Down Expand Up @@ -361,7 +364,6 @@ public function testAttempt_withFlagVerifiedFalseNoEmailVerification(Authenticat
/**
* @depends testConstructor
* @depends testAttempt_withUserName
* @expectedException \UserFrosting\Sprinkle\Account\Authenticate\Exception\InvalidCredentialsException
* @param Authenticator $authenticator
*/
public function testAttempt_withBadPassword(Authenticator $authenticator)
Expand All @@ -371,7 +373,8 @@ public function testAttempt_withBadPassword(Authenticator $authenticator)
'password' => Password::hash($password),
]);

$currentUser = $authenticator->attempt('user_name', $testUser->user_name, 'BarFoo', false);
$this->expectException(InvalidCredentialsException::class);
$authenticator->attempt('user_name', $testUser->user_name, 'BarFoo', false);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AuthorizationManagerTest extends TestCase
/**
* Setup the test database.
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand All @@ -38,7 +38,7 @@ public function setUp()
$this->refreshDatabase();
}

public function tearDown()
public function tearDown(): void
{
parent::tearDown();
m::close();
Expand Down Expand Up @@ -80,14 +80,13 @@ public function testService()

/**
* @depends testConstructor
* @expectedException \ArgumentCountError
* @param AuthorizationManager $manager
* REQUIRES PHP 7.1 or better
*/
/*public function testCheckAccess_withOutUser(AuthorizationManager $manager)
public function testCheckAccess_withOutUser(AuthorizationManager $manager)
{
$this->expectException(\ArgumentCountError::class);
$manager->checkAccess();
}*/
}

/**
* @depends testConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class AccountControllerTest extends TestCase
/**
* Setup test database for controller tests
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->setupTestDatabase();
Expand All @@ -62,7 +62,7 @@ public function setUp()
}
}

public function tearDown()
public function tearDown(): void
{
parent::tearDown();
m::close();
Expand Down Expand Up @@ -499,11 +499,13 @@ public function testlogin(AccountController $controller)
$ms = $this->ci->alerts;
$messages = $ms->getAndClearMessages();
$this->assertSame('success', end($messages)['type']);

// We have to logout the user to avoid problem
$this->logoutCurrentUser($testUser);
}

/**
* @depends testControllerConstructor
* @depends testlogin
* @param AccountController $controller
*/
public function testloginWithEmail(AccountController $controller)
Expand Down Expand Up @@ -534,6 +536,9 @@ public function testloginWithEmail(AccountController $controller)
$ms = $this->ci->alerts;
$messages = $ms->getAndClearMessages();
$this->assertSame('success', end($messages)['type']);

// We have to logout the user to avoid problem
$this->logoutCurrentUser($testUser);
}

/**
Expand Down Expand Up @@ -1590,7 +1595,7 @@ public function testSuggestUsername(AccountController $controller)

// Make sure we got a string
$data = json_decode($body, true);
$this->assertInternalType('string', $data['user_name']);
$this->assertIsString($data['user_name']);
$this->assertNotSame('', $data['user_name']);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class UserModelTest extends TestCase
/**
* Setup the database schema.
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
63 changes: 63 additions & 0 deletions app/sprinkles/account/tests/Integration/FindUniqueTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

/*
* UserFrosting (http://www.userfrosting.com)
*
* @link https://github.com/userfrosting/UserFrosting
* @copyright Copyright (c) 2019 Alexander Weissman
* @license https://github.com/userfrosting/UserFrosting/blob/master/LICENSE.md (MIT License)
*/

namespace UserFrosting\Sprinkle\Account\Tests\Integration;

use UserFrosting\Sprinkle\Account\Database\Models\User;
use UserFrosting\Sprinkle\Account\Database\Models\Group;
use UserFrosting\Sprinkle\Account\Tests\withTestUser;
use UserFrosting\Sprinkle\Core\Tests\TestDatabase;
use UserFrosting\Sprinkle\Core\Tests\RefreshDatabase;
use UserFrosting\Tests\TestCase;

/**
* Test for bug with `withTrashed` in `findUnique` not available when `SoftDeletes` trait is not included in a model.
* @see https://chat.userfrosting.com/channel/support?msg=aAYvdwczSvBMzriJ6
*/
class FindUniqueTest extends TestCase
{
use TestDatabase;
use RefreshDatabase;
use withTestUser;

/**
* Setup the database schema.
*/
public function setUp(): void
{
parent::setUp();

// Setup test database
$this->setupTestDatabase();
$this->refreshDatabase();
}

/**
* User Model does have the soft Delete
*/
public function testUserFindUnique(): void
{
$user = $this->createTestUser();
$resultA = User::findUnique($user->user_name, 'user_name', true);
$resultB = $this->ci->classMapper->staticMethod('user', 'findUnique', $user->user_name, 'user_name');
$this->assertEquals($resultA, $resultB);
}

/**
* Group model doesn't have the soft delete
*/
public function testGroupFindUnique(): void
{
$group = $this->ci->factory->create(Group::class);
$resultA = Group::findUnique($group->name, 'name', true);
$resultB = $this->ci->classMapper->staticMethod('group', 'findUnique', $group->name, 'name');
$this->assertEquals($resultA, $resultB);
}
}
2 changes: 1 addition & 1 deletion app/sprinkles/account/tests/Integration/PDOStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class PDOStorageTest extends TestCase

protected $expire = '2022-12-21 21:21:00';

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
Loading

0 comments on commit f831c29

Please sign in to comment.