PHPackages                             cndrsdrmn/socialite - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. cndrsdrmn/socialite

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

cndrsdrmn/socialite
===================

A extended Laravel Socialite package.

v1.0.0(10mo ago)08MITPHPPHP ^8.3.0CI failing

Since Aug 28Pushed 10mo agoCompare

[ Source](https://github.com/cndrsdrmn/socialite)[ Packagist](https://packagist.org/packages/cndrsdrmn/socialite)[ RSS](/packages/cndrsdrmn-socialite/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

Laravel Socialite Fakes
=======================

[](#laravel-socialite-fakes)

An extension for Laravel Socialite designed to streamline testing. This package provides simple, expressive fake classes that allow you to write deterministic tests for OAuth flows without making any real API calls to external providers. The package seamlessly integrates with and enhances the core functionality of `laravel/socialite`.

Requirements
------------

[](#requirements)

- **PHP**: ^8.3
- **Laravel Socialite**: ^5.23
- **Laravel**: 11.x (compatible with the Socialite version above)

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require --dev cndrsdrmn/socialite
```

The service provider is automatically registered and enhances Socialite's factory in non-production environments. No manual configuration is required for basic usage.

Quickstart
----------

[](#quickstart)

You can use the `Socialite` facade to fake its behavior and assert on redirects and returned users. This works seamlessly with both Pest and PHPUnit.

### Faking and Redirect Assertions

[](#faking-and-redirect-assertions)

```
use Laravel\Socialite\Facades\Socialite;

it('fakes socialite and tracks redirects', function () {
    Socialite::fake();

    // Assert that no redirect has happened yet.
    Socialite::assertNotRedirected();

    // Trigger a redirect using the default fake driver.
    $response = Socialite::driver('default')->redirect();

    // Assert that a redirect was correctly tracked.
    Socialite::assertRedirected();

    expect($response->getStatusCode())->toBe(302);
    expect($response->headers->get('X-Socialite-Fake'))->toBe('1');
});
```

### Configuring Fake Users

[](#configuring-fake-users)

To set specific user data for a provider, pass an array of attributes to the `fake()` method. The fake will return a `Laravel\Socialite\User` instance populated with your provided data.

```
use Laravel\Socialite\Facades\Socialite;

it('returns a fake user with configured attributes', function () {
    Socialite::fake([
        'github' => [
            'id' => 'user-1',
            'name' => 'John Doe',
            'email' => 'john@example.com',
            'nickname' => 'john.doe',
            'avatar' => 'https://example.com/john.jpg',
        ],
    ]);

    $user = Socialite::driver('github')->user();

    // Use the built-in assertions to verify the user data.
    Socialite::assertUser([
        'id' => 'user-1',
        'name' => 'John Doe',
        'email' => 'john@example.com',
        'nickname' => 'john.doe',
        'avatar' => 'https://example.com/john.jpg',
    ]);

    // You can also assert directly on the returned user object.
    expect($user->getId())->toBe('user-1');
});
```

If you call `Socialite::fake()` without any parameters, all providers are faked by default. Any driver not explicitly configured will return a default fake user.

**Default User Attributes:**

```
[
    'id' => 'uuid-v4',
    'name' => 'Fake User',
    'email' => 'fake@example.com',
    'nickname' => 'fake',
    'avatar' => 'https://example.com/avatar.jpg',
]
```

Simulating Failures
-------------------

[](#simulating-failures)

To test your application's error handling, you can configure the fake to throw an exception when `user()` is called.

```
use Exception;
use Laravel\Socialite\Facades\Socialite;

Socialite::fake(withFailure: new Exception('Boom'));

// The following line will now throw the configured exception.
expect(fn () => Socialite::driver('github')->user())
    ->toThrow(Exception::class);
```

Available Assertions
--------------------

[](#available-assertions)

AssertionDescription`Socialite::assertRedirected()`Checks that a redirect occurred through the Socialite fake.`Socialite::assertNotRedirected()`Verifies that a redirect has not yet occurred.`Socialite::assertUser(array $attributes)`Confirms the fake user object includes the specified attributes and values.`Socialite::assertUserHasAttribute(string $attribute, mixed $value)`Checks that the fake user object has a specific attribute with a given value.`Socialite::assertStateless()`Verifies that stateless has been invoked in the current chain.`Socialite::assertNotStateless()`Verifies that stateless has not been invoked in the curren chain.License
-------

[](#license)

This package is open-sourced software licensed under The MIT License (MIT). See the [LICENSE](LICENSE) file for more details.

Credits
-------

[](#credits)

- **Built by**: Candra Sudirman
- **Inspired by**: The streamlined testing workflows found in the Laravel framework.
- **Package Template**: [Skeleton PHP](https://github.com/nunomaduro/skeleton-php)

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance54

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

309d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e6241ea6ad620ee6d8fc3d3bac59afcad6c05ad00f4184da528eb44e69236789?d=identicon)[cndrsdrmn](/maintainers/cndrsdrmn)

---

Top Contributors

[![cndrsdrmn](https://avatars.githubusercontent.com/u/19147653?v=4)](https://github.com/cndrsdrmn "cndrsdrmn (6 commits)")

---

Tags

laraveloauth

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cndrsdrmn-socialite/health.svg)

```
[![Health](https://phpackages.com/badges/cndrsdrmn-socialite/health.svg)](https://phpackages.com/packages/cndrsdrmn-socialite)
```

###  Alternatives

[socialiteproviders/manager

Easily add new or override built-in providers in Laravel Socialite.

42747.6M584](/packages/socialiteproviders-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
