Download the PHP package tatter/imposter without Composer
On this page you can find all versions of the php package tatter/imposter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tatter/imposter
More information about tatter/imposter
Files in tatter/imposter
Package imposter
Short Description Mock authentication for CodeIgniter 4
License MIT
Homepage https://github.com/tattersoftware/codeigniter4-imposter
Informations about the package imposter
Tatter\Imposter
Mock authentication for CodeIgniter 4
Quick Start
- Install with Composer:
> composer require --dev tatter/imposter
- Access via the service:
$user = service('auth')->user();
Description
Imposter
provides a thin authentication layer for testing your CodeIgniter apps that
require authentication. This library is for testing purposes only. The tiny footprint
and easy-to-use interfaces make it ideal for handling mock authentication in a rapid way.
Imposter
fulfills all the CodeIgniter authentication guidelines
and thus supplies the Composer provision for codeigniter4/authentication-implementation
.
Installation
Install easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities and always be up-to-date:
> composer require tatter/imposter
Or, install manually by downloading the source files and adding the directory to
app/Config/Autoload.php
.
Usage
Use the service to log a user in or out.
The current status can be checked by getting the ID or User; both will be null
if no
user is authenticated.
You may also load the helper to use the user_id()
convenience method as outlined in the
CodeIgniter authentication guidelines.
Users
Imposter
comes with a minimal set of classes to be fully compatible with
Tatter\Users. This means that any
project or library which uses the interfaces from Tatter\Users
can be tested using
Imposter
without the need of an actual authentication library or even a database.
User Entity
The Tatter\Imposter\Entities\User
entity class implements all three entity interfaces from
Tatter\Users
: UserEntity
, HasGroup
, and HasPermission
. Use it like any regular entity,
except that the $groups
and $permissions
atributes are simple CSV casts for storing your
entity relationships:
Imposter Factory
The ImposterFactory
class allows UserProvider
to use the Imposter
classes automatically
during testing. To enable ImposterFactory
add it to the list of providers during
your test's setUp
or setUpBeforeClass
phase:
Because Imposter
is a database-free solution UserFactory
has its own local storage for
User
entities. Use the static methods to manipulate the storage to stage your tests:
index()
- Gets the current index of the storeadd(User $user)
- Adds aTatter\Imposter\Entities\User
object to the store, returning the new indexreset()
- Resets the store and the indexfake()
- Returns a newTatter\Imposter\Entities\User
object using Faker's generated data (note: not added to the store)
For example: