repo stringlengths 7 63 | file_url stringlengths 81 284 | file_path stringlengths 5 200 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:02:33 2026-01-05 05:24:06 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Classic/HasInvitedAtHelpers.php | src/Traits/Classic/HasInvitedAtHelpers.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Classic;
use Illuminate\Support\Facades\Date;
trait HasInvitedAtHelpers
{
public function initializeHasInvitedAtHelpers(): void
{
$this->casts['invited_at'] = 'datetime';
}
public function isInvited(): bool
{
return !is_null($this->getAttributeValue('invited_at'));
}
public function isNotInvited(): bool
{
return !$this->isInvited();
}
public function invite(): void
{
$this->setAttribute('invited_at', Date::now());
$this->save();
$this->fireModelEvent('invited', false);
}
public function undoInvite(): void
{
$this->setAttribute('invited_at', null);
$this->save();
$this->fireModelEvent('invitedUndone', false);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Classic/HasInvitedAtScope.php | src/Traits/Classic/HasInvitedAtScope.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Classic;
use Cog\Flag\Scopes\Classic\InvitedAtScope;
trait HasInvitedAtScope
{
/**
* Boot the HasInvitedAtScope for a model.
*
* @return void
*/
public static function bootHasInvitedAtScope(): void
{
static::addGlobalScope(new InvitedAtScope());
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Classic/HasInvitedFlagScope.php | src/Traits/Classic/HasInvitedFlagScope.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Classic;
use Cog\Flag\Scopes\Classic\InvitedFlagScope;
trait HasInvitedFlagScope
{
/**
* Boot the HasInvitedFlagScope for a model.
*
* @return void
*/
public static function bootHasInvitedFlagScope(): void
{
static::addGlobalScope(new InvitedFlagScope());
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Classic/HasApprovedAt.php | src/Traits/Classic/HasApprovedAt.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Classic;
trait HasApprovedAt
{
use HasApprovedAtHelpers;
use HasApprovedAtScope;
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Classic/HasPublishedAtScope.php | src/Traits/Classic/HasPublishedAtScope.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Classic;
use Cog\Flag\Scopes\Classic\PublishedAtScope;
trait HasPublishedAtScope
{
/**
* Boot the HasPublishedAtScope trait for a model.
*
* @return void
*/
public static function bootHasPublishedAtScope(): void
{
static::addGlobalScope(new PublishedAtScope());
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Classic/HasAcceptedFlagScope.php | src/Traits/Classic/HasAcceptedFlagScope.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Classic;
use Cog\Flag\Scopes\Classic\AcceptedFlagScope;
trait HasAcceptedFlagScope
{
/**
* Boot the HasAcceptedFlagScope trait for a model.
*
* @return void
*/
public static function bootHasAcceptedFlagScope(): void
{
static::addGlobalScope(new AcceptedFlagScope());
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Classic/HasActiveFlag.php | src/Traits/Classic/HasActiveFlag.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Classic;
trait HasActiveFlag
{
use HasActiveFlagHelpers;
use HasActiveFlagScope;
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Classic/HasAcceptedAtScope.php | src/Traits/Classic/HasAcceptedAtScope.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Classic;
use Cog\Flag\Scopes\Classic\AcceptedAtScope;
trait HasAcceptedAtScope
{
/**
* Boot the HasAcceptedAtScope trait for a model.
*
* @return void
*/
public static function bootHasAcceptedAtScope(): void
{
static::addGlobalScope(new AcceptedAtScope());
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Classic/HasInvitedAt.php | src/Traits/Classic/HasInvitedAt.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Classic;
trait HasInvitedAt
{
use HasInvitedAtHelpers;
use HasInvitedAtScope;
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Classic/HasApprovedFlagScope.php | src/Traits/Classic/HasApprovedFlagScope.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Classic;
use Cog\Flag\Scopes\Classic\ApprovedFlagScope;
trait HasApprovedFlagScope
{
/**
* Boot the HasApprovedFlagScope trait for a model.
*
* @return void
*/
public static function bootHasApprovedFlagScope(): void
{
static::addGlobalScope(new ApprovedFlagScope());
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Classic/HasPublishedFlagHelpers.php | src/Traits/Classic/HasPublishedFlagHelpers.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Classic;
trait HasPublishedFlagHelpers
{
public function initializeHasPublishedFlagHelpers(): void
{
$this->casts['is_published'] = 'boolean';
}
public function isPublished(): bool
{
return $this->getAttributeValue('is_published');
}
public function isNotPublished(): bool
{
return !$this->isPublished();
}
public function publish(): void
{
$this->setAttribute('is_published', true);
$this->save();
$this->fireModelEvent('published', false);
}
public function undoPublish(): void
{
$this->setAttribute('is_published', false);
$this->save();
$this->fireModelEvent('publishedUndone', false);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Classic/HasVerifiedAtScope.php | src/Traits/Classic/HasVerifiedAtScope.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Classic;
use Cog\Flag\Scopes\Classic\VerifiedAtScope;
trait HasVerifiedAtScope
{
/**
* Boot the HasVerifiedAtScope for a model.
*
* @return void
*/
public static function bootHasVerifiedAtScope(): void
{
static::addGlobalScope(new VerifiedAtScope());
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Classic/HasVerifiedFlagScope.php | src/Traits/Classic/HasVerifiedFlagScope.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Classic;
use Cog\Flag\Scopes\Classic\VerifiedFlagScope;
trait HasVerifiedFlagScope
{
/**
* Boot the HasVerifiedFlagScope for a model.
*
* @return void
*/
public static function bootHasVerifiedFlagScope(): void
{
static::addGlobalScope(new VerifiedFlagScope());
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasExpiredAtScope.php | src/Traits/Inverse/HasExpiredAtScope.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
use Cog\Flag\Scopes\Inverse\ExpiredAtScope;
trait HasExpiredAtScope
{
/**
* Boot the HasExpiredAtScope trait for a model.
*
* @return void
*/
public static function bootHasExpiredAtScope(): void
{
static::addGlobalScope(new ExpiredAtScope());
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasArchivedFlag.php | src/Traits/Inverse/HasArchivedFlag.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
trait HasArchivedFlag
{
use HasArchivedFlagHelpers;
use HasArchivedFlagScope;
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasDraftedAt.php | src/Traits/Inverse/HasDraftedAt.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
trait HasDraftedAt
{
use HasDraftedAtHelpers;
use HasDraftedAtScope;
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasArchivedAtHelpers.php | src/Traits/Inverse/HasArchivedAtHelpers.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
use Illuminate\Support\Facades\Date;
trait HasArchivedAtHelpers
{
public function initializeHasArchivedAtHelpers(): void
{
$this->casts['archived_at'] = 'datetime';
}
public function isArchived(): bool
{
return !is_null($this->getAttributeValue('archived_at'));
}
public function isNotArchived(): bool
{
return !$this->isArchived();
}
public function archive(): void
{
$this->setAttribute('archived_at', Date::now());
$this->save();
$this->fireModelEvent('archived', false);
}
public function undoArchive(): void
{
$this->setAttribute('archived_at', null);
$this->save();
$this->fireModelEvent('archivedUndone', false);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasClosedAtScope.php | src/Traits/Inverse/HasClosedAtScope.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
use Cog\Flag\Scopes\Inverse\ClosedAtScope;
trait HasClosedAtScope
{
/**
* Boot the HasClosedAtScope trait for a model.
*
* @return void
*/
public static function bootHasClosedAtScope(): void
{
static::addGlobalScope(new ClosedAtScope());
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasExpiredAtHelpers.php | src/Traits/Inverse/HasExpiredAtHelpers.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
use Illuminate\Support\Facades\Date;
trait HasExpiredAtHelpers
{
public function initializeHasExpiredAtHelpers(): void
{
$this->casts['expired_at'] = 'datetime';
}
public function isExpired(): bool
{
return !is_null($this->getAttributeValue('expired_at'));
}
public function isNotExpired(): bool
{
return !$this->isExpired();
}
public function expire(): void
{
$this->setAttribute('expired_at', Date::now());
$this->save();
$this->fireModelEvent('expired', false);
}
public function undoExpire(): void
{
$this->setAttribute('expired_at', null);
$this->save();
$this->fireModelEvent('expiredUndone', false);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasDraftedFlagHelpers.php | src/Traits/Inverse/HasDraftedFlagHelpers.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
trait HasDraftedFlagHelpers
{
public function initializeHasDraftedFlagHelpers(): void
{
$this->casts['is_drafted'] = 'boolean';
}
public function isDrafted(): bool
{
return $this->getAttributeValue('is_drafted');
}
public function isNotDrafted(): bool
{
return !$this->isDrafted();
}
public function draft(): void
{
$this->setAttribute('is_drafted', true);
$this->save();
$this->fireModelEvent('drafted', false);
}
public function undoDraft(): void
{
$this->setAttribute('is_drafted', false);
$this->save();
$this->fireModelEvent('draftedUndone', false);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasEndedFlagScope.php | src/Traits/Inverse/HasEndedFlagScope.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
use Cog\Flag\Scopes\Inverse\EndedFlagScope;
trait HasEndedFlagScope
{
/**
* Boot the HasEndedFlagScope trait for a model.
*
* @return void
*/
public static function bootHasEndedFlagScope(): void
{
static::addGlobalScope(new EndedFlagScope());
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasArchivedAt.php | src/Traits/Inverse/HasArchivedAt.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
trait HasArchivedAt
{
use HasArchivedAtHelpers;
use HasArchivedAtScope;
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasDraftedFlag.php | src/Traits/Inverse/HasDraftedFlag.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
trait HasDraftedFlag
{
use HasDraftedFlagHelpers;
use HasDraftedFlagScope;
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasDraftedAtHelpers.php | src/Traits/Inverse/HasDraftedAtHelpers.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
use Illuminate\Support\Facades\Date;
trait HasDraftedAtHelpers
{
public function initializeHasDraftedAtHelpers(): void
{
$this->casts['drafted_at'] = 'datetime';
}
public function isDrafted(): bool
{
return !is_null($this->getAttributeValue('drafted_at'));
}
public function isNotDrafted(): bool
{
return !$this->isDrafted();
}
public function draft(): void
{
$this->setAttribute('drafted_at', Date::now());
$this->save();
$this->fireModelEvent('drafted', false);
}
public function undoDraft(): void
{
$this->setAttribute('drafted_at', null);
$this->save();
$this->fireModelEvent('draftedUndone', false);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasClosedAtHelpers.php | src/Traits/Inverse/HasClosedAtHelpers.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
use Illuminate\Support\Facades\Date;
trait HasClosedAtHelpers
{
public function initializeHasClosedAtHelpers(): void
{
$this->casts['closed_at'] = 'datetime';
}
public function isClosed(): bool
{
return !is_null($this->getAttributeValue('closed_at'));
}
public function isNotClosed(): bool
{
return !$this->isClosed();
}
public function close(): void
{
$this->setAttribute('closed_at', Date::now());
$this->save();
$this->fireModelEvent('closed', false);
}
public function undoClose(): void
{
$this->setAttribute('closed_at', null);
$this->save();
$this->fireModelEvent('closedUndone', false);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasArchivedFlagHelpers.php | src/Traits/Inverse/HasArchivedFlagHelpers.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
trait HasArchivedFlagHelpers
{
public function initializeHasArchivedFlagHelpers(): void
{
$this->casts['is_archived'] = 'boolean';
}
public function isArchived(): bool
{
return $this->getAttributeValue('is_archived');
}
public function isNotArchived(): bool
{
return !$this->isArchived();
}
public function archive(): void
{
$this->setAttribute('is_archived', true);
$this->save();
$this->fireModelEvent('archived', false);
}
public function undoArchive(): void
{
$this->setAttribute('is_archived', false);
$this->save();
$this->fireModelEvent('archivedUndone', false);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasClosedFlag.php | src/Traits/Inverse/HasClosedFlag.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
trait HasClosedFlag
{
use HasClosedFlagHelpers;
use HasClosedFlagScope;
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasDraftedAtScope.php | src/Traits/Inverse/HasDraftedAtScope.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
use Cog\Flag\Scopes\Inverse\DraftedAtScope;
trait HasDraftedAtScope
{
/**
* Boot the HasDraftedAtScope trait for a model.
*
* @return void
*/
public static function bootHasDraftedAtScope(): void
{
static::addGlobalScope(new DraftedAtScope());
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasEndedAtScope.php | src/Traits/Inverse/HasEndedAtScope.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
use Cog\Flag\Scopes\Inverse\EndedAtScope;
trait HasEndedAtScope
{
/**
* Boot the HasEndedAtScope trait for a model.
*
* @return void
*/
public static function bootHasEndedAtScope(): void
{
static::addGlobalScope(new EndedAtScope());
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasExpiredFlag.php | src/Traits/Inverse/HasExpiredFlag.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
trait HasExpiredFlag
{
use HasExpiredFlagHelpers;
use HasExpiredFlagScope;
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasEndedFlag.php | src/Traits/Inverse/HasEndedFlag.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
trait HasEndedFlag
{
use HasEndedFlagHelpers;
use HasEndedFlagScope;
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasExpiredFlagHelpers.php | src/Traits/Inverse/HasExpiredFlagHelpers.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
trait HasExpiredFlagHelpers
{
public function initializeHasExpiredFlagHelpers(): void
{
$this->casts['is_expired'] = 'boolean';
}
public function isExpired(): bool
{
return $this->getAttributeValue('is_expired');
}
public function isNotExpired(): bool
{
return !$this->isExpired();
}
public function expire(): void
{
$this->setAttribute('is_expired', true);
$this->save();
$this->fireModelEvent('expired', false);
}
public function undoExpire(): void
{
$this->setAttribute('is_expired', false);
$this->save();
$this->fireModelEvent('expiredUndone', false);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasClosedFlagScope.php | src/Traits/Inverse/HasClosedFlagScope.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
use Cog\Flag\Scopes\Inverse\ClosedFlagScope;
trait HasClosedFlagScope
{
/**
* Boot the HasClosedFlagScope trait for a model.
*
* @return void
*/
public static function bootHasClosedFlagScope(): void
{
static::addGlobalScope(new ClosedFlagScope());
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasArchivedAtScope.php | src/Traits/Inverse/HasArchivedAtScope.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
use Cog\Flag\Scopes\Inverse\ArchivedAtScope;
trait HasArchivedAtScope
{
/**
* Boot the HasArchivedAtScope trait for a model.
*
* @return void
*/
public static function bootHasArchivedAtScope(): void
{
static::addGlobalScope(new ArchivedAtScope());
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasExpiredFlagScope.php | src/Traits/Inverse/HasExpiredFlagScope.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
use Cog\Flag\Scopes\Inverse\ExpiredFlagScope;
trait HasExpiredFlagScope
{
/**
* Boot the HasExpiredFlagScope trait for a model.
*
* @return void
*/
public static function bootHasExpiredFlagScope(): void
{
static::addGlobalScope(new ExpiredFlagScope());
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasClosedFlagHelpers.php | src/Traits/Inverse/HasClosedFlagHelpers.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
trait HasClosedFlagHelpers
{
public function initializeHasClosedFlagHelpers(): void
{
$this->casts['is_closed'] = 'boolean';
}
public function isClosed(): bool
{
return $this->getAttributeValue('is_closed');
}
public function isNotClosed(): bool
{
return !$this->isClosed();
}
public function close(): void
{
$this->setAttribute('is_closed', true);
$this->save();
$this->fireModelEvent('closed', false);
}
public function undoClose(): void
{
$this->setAttribute('is_closed', false);
$this->save();
$this->fireModelEvent('closedUndone', false);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasEndedAt.php | src/Traits/Inverse/HasEndedAt.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
trait HasEndedAt
{
use HasEndedAtHelpers;
use HasEndedAtScope;
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasEndedFlagHelpers.php | src/Traits/Inverse/HasEndedFlagHelpers.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
trait HasEndedFlagHelpers
{
public function initializeHasEndedFlagHelpers(): void
{
$this->casts['is_ended'] = 'boolean';
}
public function isEnded(): bool
{
return $this->getAttributeValue('is_ended');
}
public function isNotEnded(): bool
{
return !$this->isEnded();
}
public function end(): void
{
$this->setAttribute('is_ended', true);
$this->save();
$this->fireModelEvent('ended', false);
}
public function undoEnd(): void
{
$this->setAttribute('is_ended', false);
$this->save();
$this->fireModelEvent('endedUndone', false);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasArchivedFlagScope.php | src/Traits/Inverse/HasArchivedFlagScope.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
use Cog\Flag\Scopes\Inverse\ArchivedFlagScope;
trait HasArchivedFlagScope
{
/**
* Boot the HasArchivedFlagScope trait for a model.
*
* @return void
*/
public static function bootHasArchivedFlagScope(): void
{
static::addGlobalScope(new ArchivedFlagScope());
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasClosedAt.php | src/Traits/Inverse/HasClosedAt.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
trait HasClosedAt
{
use HasClosedAtHelpers;
use HasClosedAtScope;
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasEndedAtHelpers.php | src/Traits/Inverse/HasEndedAtHelpers.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
use Illuminate\Support\Facades\Date;
trait HasEndedAtHelpers
{
public function initializeHasEndedAtHelpers(): void
{
$this->casts['ended_at'] = 'datetime';
}
public function isEnded(): bool
{
return !is_null($this->getAttributeValue('ended_at'));
}
public function isNotEnded(): bool
{
return !$this->isEnded();
}
public function end(): void
{
$this->setAttribute('ended_at', Date::now());
$this->save();
$this->fireModelEvent('ended', false);
}
public function undoEnd(): void
{
$this->setAttribute('ended_at', null);
$this->save();
$this->fireModelEvent('endedUndone', false);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasDraftedFlagScope.php | src/Traits/Inverse/HasDraftedFlagScope.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
use Cog\Flag\Scopes\Inverse\DraftedFlagScope;
trait HasDraftedFlagScope
{
/**
* Boot the HasDraftedFlagScope trait for a model.
*
* @return void
*/
public static function bootHasDraftedFlagScope(): void
{
static::addGlobalScope(new DraftedFlagScope());
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/src/Traits/Inverse/HasExpiredAt.php | src/Traits/Inverse/HasExpiredAt.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Flag\Traits\Inverse;
trait HasExpiredAt
{
use HasExpiredAtHelpers;
use HasExpiredAtScope;
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/TestCase.php | tests/TestCase.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\File;
use Orchestra\Testbench\TestCase as Orchestra;
abstract class TestCase extends Orchestra
{
/**
* Actions to be performed on PHPUnit start.
*/
protected function setUp(): void
{
parent::setUp();
$this->destroyPackageMigrations();
$this->registerMigrations();
$this->migrateUnitTestTables();
$this->registerPackageFactories();
}
/**
* Load package service provider.
*
* @param \Illuminate\Foundation\Application $app
* @return array
*/
protected function getPackageProviders($app): array
{
return [
];
}
/**
* Delete all published package migrations.
*
* @return void
*/
protected function destroyPackageMigrations(): void
{
File::cleanDirectory('vendor/orchestra/testbench-core/laravel/database/migrations');
}
/**
* Register test migrations.
*
* @return void
*/
protected function registerMigrations(): void
{
$this->loadMigrationsFrom(__DIR__ . '/database/migrations');
}
/**
* Perform unit test database migrations.
*
* @return void
*/
protected function migrateUnitTestTables(): void
{
$this->artisan('migrate');
}
/**
* Cleanup database after unit test.
*
* @return void
*/
protected function migrateTablesUndo(): void
{
$this->artisan('migrate:reset');
}
/**
* Register package related model factories.
*
* @return void
*/
private function registerPackageFactories(): void
{
Factory::guessFactoryNamesUsing(function (string $modelName) {
return 'Cog\\Tests\\Laravel\\Flag\\Database\\Factories\\' . class_basename($modelName) . 'Factory';
});
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Classic/KeptFlagScopeTest.php | tests/Unit/Scopes/Classic/KeptFlagScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithKeptFlag;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithKeptFlagApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithKeptFlagUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
final class KeptFlagScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithKeptFlag::factory()->count(3)->create([
'is_kept' => true,
]);
EntityWithKeptFlag::factory()->count(2)->create([
'is_kept' => false,
]);
$entities = EntityWithKeptFlag::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_not_kept(): void
{
EntityWithKeptFlag::factory()->count(3)->create([
'is_kept' => true,
]);
EntityWithKeptFlag::factory()->count(2)->create([
'is_kept' => false,
]);
$entities = EntityWithKeptFlag::withoutNotKept()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_get_with_not_kept(): void
{
EntityWithKeptFlag::factory()->count(3)->create([
'is_kept' => true,
]);
EntityWithKeptFlag::factory()->count(2)->create([
'is_kept' => false,
]);
$entities = EntityWithKeptFlag::withNotKept()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_not_kept(): void
{
EntityWithKeptFlag::factory()->count(3)->create([
'is_kept' => true,
]);
EntityWithKeptFlag::factory()->count(2)->create([
'is_kept' => false,
]);
$entities = EntityWithKeptFlag::onlyNotKept()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_keep_model(): void
{
$model = EntityWithKeptFlag::factory()->create([
'is_kept' => false,
]);
EntityWithKeptFlag::where('id', $model->id)->keep();
$model = EntityWithKeptFlag::where('id', $model->id)->first();
$this->assertTrue($model->is_kept);
}
/** @test */
public function it_can_undo_keep_model(): void
{
$model = EntityWithKeptFlag::factory()->create([
'is_kept' => true,
]);
EntityWithKeptFlag::where('id', $model->id)->undoKeep();
$model = EntityWithKeptFlag::withNotKept()->where('id', $model->id)->first();
$this->assertFalse($model->is_kept);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithKeptFlag::factory()->count(3)->create([
'is_kept' => true,
]);
EntityWithKeptFlag::factory()->count(2)->create([
'is_kept' => false,
]);
$entities = EntityWithKeptFlagUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithKeptFlag::factory()->count(3)->create([
'is_kept' => true,
]);
EntityWithKeptFlag::factory()->count(2)->create([
'is_kept' => false,
]);
$entities = EntityWithKeptFlagApplied::all();
$this->assertCount(3, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Classic/VerifiedFlagScopeTest.php | tests/Unit/Scopes/Classic/VerifiedFlagScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithVerifiedFlag;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithVerifiedFlagApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithVerifiedFlagUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
final class VerifiedFlagScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithVerifiedFlag::factory()->count(3)->create([
'is_verified' => true,
]);
EntityWithVerifiedFlag::factory()->count(2)->create([
'is_verified' => false,
]);
$entities = EntityWithVerifiedFlag::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_not_verified(): void
{
EntityWithVerifiedFlag::factory()->count(3)->create([
'is_verified' => true,
]);
EntityWithVerifiedFlag::factory()->count(2)->create([
'is_verified' => false,
]);
$entities = EntityWithVerifiedFlag::withoutNotVerified()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_get_with_not_verified(): void
{
EntityWithVerifiedFlag::factory()->count(3)->create([
'is_verified' => true,
]);
EntityWithVerifiedFlag::factory()->count(2)->create([
'is_verified' => false,
]);
$entities = EntityWithVerifiedFlag::withNotVerified()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_not_verified(): void
{
EntityWithVerifiedFlag::factory()->count(3)->create([
'is_verified' => true,
]);
EntityWithVerifiedFlag::factory()->count(2)->create([
'is_verified' => false,
]);
$entities = EntityWithVerifiedFlag::onlyNotVerified()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_verify_model(): void
{
$model = EntityWithVerifiedFlag::factory()->create([
'is_verified' => false,
]);
EntityWithVerifiedFlag::where('id', $model->id)->verify();
$model = EntityWithVerifiedFlag::where('id', $model->id)->first();
$this->assertTrue($model->is_verified);
}
/** @test */
public function it_can_undo_verify_model(): void
{
$model = EntityWithVerifiedFlag::factory()->create([
'is_verified' => true,
]);
EntityWithVerifiedFlag::where('id', $model->id)->undoVerify();
$model = EntityWithVerifiedFlag::withNotVerified()->where('id', $model->id)->first();
$this->assertFalse($model->is_verified);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithVerifiedFlag::factory()->count(3)->create([
'is_verified' => true,
]);
EntityWithVerifiedFlag::factory()->count(2)->create([
'is_verified' => false,
]);
$entities = EntityWithVerifiedFlagUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithVerifiedFlag::factory()->count(3)->create([
'is_verified' => true,
]);
EntityWithVerifiedFlag::factory()->count(2)->create([
'is_verified' => false,
]);
$entities = EntityWithVerifiedFlagApplied::all();
$this->assertCount(3, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Classic/AcceptedFlagScopeTest.php | tests/Unit/Scopes/Classic/AcceptedFlagScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithAcceptedFlag;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithAcceptedFlagApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithAcceptedFlagUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
final class AcceptedFlagScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithAcceptedFlag::factory()->count(3)->create([
'is_accepted' => true,
]);
EntityWithAcceptedFlag::factory()->count(2)->create([
'is_accepted' => false,
]);
$entities = EntityWithAcceptedFlag::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_not_accepted(): void
{
EntityWithAcceptedFlag::factory()->count(3)->create([
'is_accepted' => true,
]);
EntityWithAcceptedFlag::factory()->count(2)->create([
'is_accepted' => false,
]);
$entities = EntityWithAcceptedFlag::withoutNotAccepted()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_get_with_not_accepted(): void
{
EntityWithAcceptedFlag::factory()->count(3)->create([
'is_accepted' => true,
]);
EntityWithAcceptedFlag::factory()->count(2)->create([
'is_accepted' => false,
]);
$entities = EntityWithAcceptedFlag::withNotAccepted()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_not_accepted(): void
{
EntityWithAcceptedFlag::factory()->count(3)->create([
'is_accepted' => true,
]);
EntityWithAcceptedFlag::factory()->count(2)->create([
'is_accepted' => false,
]);
$entities = EntityWithAcceptedFlag::onlyNotAccepted()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_accept_model(): void
{
$model = EntityWithAcceptedFlag::factory()->create([
'is_accepted' => false,
]);
EntityWithAcceptedFlag::where('id', $model->id)->accept();
$model = EntityWithAcceptedFlag::where('id', $model->id)->first();
$this->assertTrue($model->is_accepted);
}
/** @test */
public function it_can_undo_accept_model(): void
{
$model = EntityWithAcceptedFlag::factory()->create([
'is_accepted' => true,
]);
EntityWithAcceptedFlag::where('id', $model->id)->undoAccept();
$model = EntityWithAcceptedFlag::withNotAccepted()->where('id', $model->id)->first();
$this->assertFalse($model->is_accepted);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithAcceptedFlag::factory()->count(3)->create([
'is_accepted' => true,
]);
EntityWithAcceptedFlag::factory()->count(2)->create([
'is_accepted' => false,
]);
$entities = EntityWithAcceptedFlagUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithAcceptedFlag::factory()->count(3)->create([
'is_accepted' => true,
]);
EntityWithAcceptedFlag::factory()->count(2)->create([
'is_accepted' => false,
]);
$entities = EntityWithAcceptedFlagApplied::all();
$this->assertCount(3, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Classic/InvitedFlagScopeTest.php | tests/Unit/Scopes/Classic/InvitedFlagScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithInvitedFlag;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithInvitedFlagApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithInvitedFlagUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
final class InvitedFlagScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithInvitedFlag::factory()->count(3)->create([
'is_invited' => true,
]);
EntityWithInvitedFlag::factory()->count(2)->create([
'is_invited' => false,
]);
$entities = EntityWithInvitedFlag::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_not_invited(): void
{
EntityWithInvitedFlag::factory()->count(3)->create([
'is_invited' => true,
]);
EntityWithInvitedFlag::factory()->count(2)->create([
'is_invited' => false,
]);
$entities = EntityWithInvitedFlag::withoutNotInvited()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_get_with_not_invited(): void
{
EntityWithInvitedFlag::factory()->count(3)->create([
'is_invited' => true,
]);
EntityWithInvitedFlag::factory()->count(2)->create([
'is_invited' => false,
]);
$entities = EntityWithInvitedFlag::withNotInvited()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_not_invited(): void
{
EntityWithInvitedFlag::factory()->count(3)->create([
'is_invited' => true,
]);
EntityWithInvitedFlag::factory()->count(2)->create([
'is_invited' => false,
]);
$entities = EntityWithInvitedFlag::onlyNotInvited()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_invite_model(): void
{
$model = EntityWithInvitedFlag::factory()->create([
'is_invited' => false,
]);
EntityWithInvitedFlag::where('id', $model->id)->invite();
$model = EntityWithInvitedFlag::where('id', $model->id)->first();
$this->assertTrue($model->is_invited);
}
/** @test */
public function it_can_undo_invite_model(): void
{
$model = EntityWithInvitedFlag::factory()->create([
'is_invited' => true,
]);
EntityWithInvitedFlag::where('id', $model->id)->undoInvite();
$model = EntityWithInvitedFlag::withNotInvited()->where('id', $model->id)->first();
$this->assertFalse($model->is_invited);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithInvitedFlag::factory()->count(3)->create([
'is_invited' => true,
]);
EntityWithInvitedFlag::factory()->count(2)->create([
'is_invited' => false,
]);
$entities = EntityWithInvitedFlagUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithInvitedFlag::factory()->count(3)->create([
'is_invited' => true,
]);
EntityWithInvitedFlag::factory()->count(2)->create([
'is_invited' => false,
]);
$entities = EntityWithInvitedFlagApplied::all();
$this->assertCount(3, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Classic/AcceptedAtScopeTest.php | tests/Unit/Scopes/Classic/AcceptedAtScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithAcceptedAt;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithAcceptedAtApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithAcceptedAtUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Facades\Date;
final class AcceptedAtScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithAcceptedAt::factory()->count(3)->create([
'accepted_at' => Date::now()->subDay(),
]);
EntityWithAcceptedAt::factory()->count(2)->create([
'accepted_at' => null,
]);
$entities = EntityWithAcceptedAt::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_not_accepted(): void
{
EntityWithAcceptedAt::factory()->count(3)->create([
'accepted_at' => Date::now()->subDay(),
]);
EntityWithAcceptedAt::factory()->count(2)->create([
'accepted_at' => null,
]);
$entities = EntityWithAcceptedAt::withoutNotAccepted()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_get_with_not_accepted(): void
{
EntityWithAcceptedAt::factory()->count(3)->create([
'accepted_at' => Date::now()->subDay(),
]);
EntityWithAcceptedAt::factory()->count(2)->create([
'accepted_at' => null,
]);
$entities = EntityWithAcceptedAt::withNotAccepted()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_not_accepted(): void
{
EntityWithAcceptedAt::factory()->count(3)->create([
'accepted_at' => Date::now()->subDay(),
]);
EntityWithAcceptedAt::factory()->count(2)->create([
'accepted_at' => null,
]);
$entities = EntityWithAcceptedAt::onlyNotAccepted()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_accept_model(): void
{
$model = EntityWithAcceptedAt::factory()->create([
'accepted_at' => null,
]);
EntityWithAcceptedAt::where('id', $model->id)->accept();
$model = EntityWithAcceptedAt::where('id', $model->id)->first();
$this->assertNotNull($model->accepted_at);
}
/** @test */
public function it_can_undo_accept(): void
{
$model = EntityWithAcceptedAt::factory()->create([
'accepted_at' => Date::now()->subDay(),
]);
EntityWithAcceptedAt::where('id', $model->id)->undoAccept();
$model = EntityWithAcceptedAt::withNotAccepted()->where('id', $model->id)->first();
$this->assertNull($model->accepted_at);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithAcceptedAt::factory()->count(3)->create([
'accepted_at' => Date::now()->subDay(),
]);
EntityWithAcceptedAt::factory()->count(2)->create([
'accepted_at' => null,
]);
$entities = EntityWithAcceptedAtUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithAcceptedAt::factory()->count(3)->create([
'accepted_at' => Date::now()->subDay(),
]);
EntityWithAcceptedAt::factory()->count(2)->create([
'accepted_at' => null,
]);
$entities = EntityWithAcceptedAtApplied::all();
$this->assertCount(3, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Classic/VerifiedAtScopeTest.php | tests/Unit/Scopes/Classic/VerifiedAtScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithVerifiedAt;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithVerifiedAtApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithVerifiedAtUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Facades\Date;
final class VerifiedAtScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithVerifiedAt::factory()->count(3)->create([
'verified_at' => Date::now()->subDay(),
]);
EntityWithVerifiedAt::factory()->count(2)->create([
'verified_at' => null,
]);
$entities = EntityWithVerifiedAt::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_not_verified(): void
{
EntityWithVerifiedAt::factory()->count(3)->create([
'verified_at' => Date::now()->subDay(),
]);
EntityWithVerifiedAt::factory()->count(2)->create([
'verified_at' => null,
]);
$entities = EntityWithVerifiedAt::withoutNotVerified()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_get_with_not_verified(): void
{
EntityWithVerifiedAt::factory()->count(3)->create([
'verified_at' => Date::now()->subDay(),
]);
EntityWithVerifiedAt::factory()->count(2)->create([
'verified_at' => null,
]);
$entities = EntityWithVerifiedAt::withNotVerified()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_not_verified(): void
{
EntityWithVerifiedAt::factory()->count(3)->create([
'verified_at' => Date::now()->subDay(),
]);
EntityWithVerifiedAt::factory()->count(2)->create([
'verified_at' => null,
]);
$entities = EntityWithVerifiedAt::onlyNotVerified()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_verify_model(): void
{
$model = EntityWithVerifiedAt::factory()->create([
'verified_at' => null,
]);
EntityWithVerifiedAt::where('id', $model->id)->verify();
$model = EntityWithVerifiedAt::where('id', $model->id)->first();
$this->assertNotNull($model->verified_at);
}
/** @test */
public function it_can_undo_verify_model(): void
{
$model = EntityWithVerifiedAt::factory()->create([
'verified_at' => Date::now()->subDay(),
]);
EntityWithVerifiedAt::where('id', $model->id)->undoVerify();
$model = EntityWithVerifiedAt::withNotVerified()->where('id', $model->id)->first();
$this->assertNull($model->verified_at);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithVerifiedAt::factory()->count(3)->create([
'verified_at' => Date::now()->subDay(),
]);
EntityWithVerifiedAt::factory()->count(2)->create([
'verified_at' => null,
]);
$entities = EntityWithVerifiedAtUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithVerifiedAt::factory()->count(3)->create([
'verified_at' => Date::now()->subDay(),
]);
EntityWithVerifiedAt::factory()->count(2)->create([
'verified_at' => null,
]);
$entities = EntityWithVerifiedAtApplied::all();
$this->assertCount(3, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Classic/ApprovedFlagScopeTest.php | tests/Unit/Scopes/Classic/ApprovedFlagScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithApprovedFlag;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithApprovedFlagApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithApprovedFlagUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
final class ApprovedFlagScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithApprovedFlag::factory()->count(3)->create([
'is_approved' => true,
]);
EntityWithApprovedFlag::factory()->count(2)->create([
'is_approved' => false,
]);
$entities = EntityWithApprovedFlag::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_not_approved(): void
{
EntityWithApprovedFlag::factory()->count(3)->create([
'is_approved' => true,
]);
EntityWithApprovedFlag::factory()->count(2)->create([
'is_approved' => false,
]);
$entities = EntityWithApprovedFlag::withoutNotApproved()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_get_with_not_approved(): void
{
EntityWithApprovedFlag::factory()->count(3)->create([
'is_approved' => true,
]);
EntityWithApprovedFlag::factory()->count(2)->create([
'is_approved' => false,
]);
$entities = EntityWithApprovedFlag::withNotApproved()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_not_approved(): void
{
EntityWithApprovedFlag::factory()->count(3)->create([
'is_approved' => true,
]);
EntityWithApprovedFlag::factory()->count(2)->create([
'is_approved' => false,
]);
$entities = EntityWithApprovedFlag::onlyNotApproved()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_approve_model(): void
{
$model = EntityWithApprovedFlag::factory()->create([
'is_approved' => false,
]);
EntityWithApprovedFlag::where('id', $model->id)->approve();
$model = EntityWithApprovedFlag::where('id', $model->id)->first();
$this->assertTrue($model->is_approved);
}
/** @test */
public function it_can_undo_approve_model(): void
{
$model = EntityWithApprovedFlag::factory()->create([
'is_approved' => true,
]);
EntityWithApprovedFlag::where('id', $model->id)->undoApprove();
$model = EntityWithApprovedFlag::withNotApproved()->where('id', $model->id)->first();
$this->assertFalse($model->is_approved);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithApprovedFlag::factory()->count(3)->create([
'is_approved' => true,
]);
EntityWithApprovedFlag::factory()->count(2)->create([
'is_approved' => false,
]);
$entities = EntityWithApprovedFlagUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithApprovedFlag::factory()->count(3)->create([
'is_approved' => true,
]);
EntityWithApprovedFlag::factory()->count(2)->create([
'is_approved' => false,
]);
$entities = EntityWithApprovedFlagApplied::all();
$this->assertCount(3, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Classic/ApprovedAtScopeTest.php | tests/Unit/Scopes/Classic/ApprovedAtScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithApprovedAt;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithApprovedAtApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithApprovedAtUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Facades\Date;
final class ApprovedAtScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithApprovedAt::factory()->count(3)->create([
'approved_at' => Date::now()->subDay(),
]);
EntityWithApprovedAt::factory()->count(2)->create([
'approved_at' => null,
]);
$entities = EntityWithApprovedAt::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_not_approved(): void
{
EntityWithApprovedAt::factory()->count(3)->create([
'approved_at' => Date::now()->subDay(),
]);
EntityWithApprovedAt::factory()->count(2)->create([
'approved_at' => null,
]);
$entities = EntityWithApprovedAt::withoutNotApproved()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_get_with_not_approved(): void
{
EntityWithApprovedAt::factory()->count(3)->create([
'approved_at' => Date::now()->subDay(),
]);
EntityWithApprovedAt::factory()->count(2)->create([
'approved_at' => null,
]);
$entities = EntityWithApprovedAt::withNotApproved()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_not_approved(): void
{
EntityWithApprovedAt::factory()->count(3)->create([
'approved_at' => Date::now()->subDay(),
]);
EntityWithApprovedAt::factory()->count(2)->create([
'approved_at' => null,
]);
$entities = EntityWithApprovedAt::onlyNotApproved()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_approve_model(): void
{
$model = EntityWithApprovedAt::factory()->create([
'approved_at' => null,
]);
EntityWithApprovedAt::where('id', $model->id)->approve();
$model = EntityWithApprovedAt::where('id', $model->id)->first();
$this->assertNotNull($model->approved_at);
}
/** @test */
public function it_can_undo_approve_model(): void
{
$model = EntityWithApprovedAt::factory()->create([
'approved_at' => Date::now()->subDay(),
]);
EntityWithApprovedAt::where('id', $model->id)->undoApprove();
$model = EntityWithApprovedAt::withNotApproved()->where('id', $model->id)->first();
$this->assertNull($model->approved_at);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithApprovedAt::factory()->count(3)->create([
'approved_at' => Date::now()->subDay(),
]);
EntityWithApprovedAt::factory()->count(2)->create([
'approved_at' => null,
]);
$entities = EntityWithApprovedAtUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithApprovedAt::factory()->count(3)->create([
'approved_at' => Date::now()->subDay(),
]);
EntityWithApprovedAt::factory()->count(2)->create([
'approved_at' => null,
]);
$entities = EntityWithApprovedAtApplied::all();
$this->assertCount(3, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Classic/InvitedAtScopeTest.php | tests/Unit/Scopes/Classic/InvitedAtScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithInvitedAt;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithInvitedAtApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithInvitedAtUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Facades\Date;
final class InvitedAtScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithInvitedAt::factory()->count(3)->create([
'invited_at' => Date::now()->subDay(),
]);
EntityWithInvitedAt::factory()->count(2)->create([
'invited_at' => null,
]);
$entities = EntityWithInvitedAt::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_not_invited(): void
{
EntityWithInvitedAt::factory()->count(3)->create([
'invited_at' => Date::now()->subDay(),
]);
EntityWithInvitedAt::factory()->count(2)->create([
'invited_at' => null,
]);
$entities = EntityWithInvitedAt::withoutNotInvited()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_get_with_not_invited(): void
{
EntityWithInvitedAt::factory()->count(3)->create([
'invited_at' => Date::now()->subDay(),
]);
EntityWithInvitedAt::factory()->count(2)->create([
'invited_at' => null,
]);
$entities = EntityWithInvitedAt::withNotInvited()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_not_invited(): void
{
EntityWithInvitedAt::factory()->count(3)->create([
'invited_at' => Date::now()->subDay(),
]);
EntityWithInvitedAt::factory()->count(2)->create([
'invited_at' => null,
]);
$entities = EntityWithInvitedAt::onlyNotInvited()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_invite_model(): void
{
$model = EntityWithInvitedAt::factory()->create([
'invited_at' => null,
]);
EntityWithInvitedAt::where('id', $model->id)->invite();
$model = EntityWithInvitedAt::where('id', $model->id)->first();
$this->assertNotNull($model->invited_at);
}
/** @test */
public function it_can_undo_invite_model(): void
{
$model = EntityWithInvitedAt::factory()->create([
'invited_at' => Date::now()->subDay(),
]);
EntityWithInvitedAt::where('id', $model->id)->undoInvite();
$model = EntityWithInvitedAt::withNotInvited()->where('id', $model->id)->first();
$this->assertNull($model->invited_at);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithInvitedAt::factory()->count(3)->create([
'invited_at' => Date::now()->subDay(),
]);
EntityWithInvitedAt::factory()->count(2)->create([
'invited_at' => null,
]);
$entities = EntityWithInvitedAtUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithInvitedAt::factory()->count(3)->create([
'invited_at' => Date::now()->subDay(),
]);
EntityWithInvitedAt::factory()->count(2)->create([
'invited_at' => null,
]);
$entities = EntityWithInvitedAtApplied::all();
$this->assertCount(3, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Classic/PublishedAtScopeTest.php | tests/Unit/Scopes/Classic/PublishedAtScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithPublishedAt;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithPublishedAtApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithPublishedAtUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Facades\Date;
final class PublishedAtScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithPublishedAt::factory()->count(3)->create([
'published_at' => Date::now()->subDay(),
]);
EntityWithPublishedAt::factory()->count(2)->create([
'published_at' => null,
]);
$entities = EntityWithPublishedAt::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_not_published(): void
{
EntityWithPublishedAt::factory()->count(3)->create([
'published_at' => Date::now()->subDay(),
]);
EntityWithPublishedAt::factory()->count(2)->create([
'published_at' => null,
]);
$entities = EntityWithPublishedAt::withoutNotPublished()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_get_with_not_published(): void
{
EntityWithPublishedAt::factory()->count(3)->create([
'published_at' => Date::now()->subDay(),
]);
EntityWithPublishedAt::factory()->count(2)->create([
'published_at' => null,
]);
$entities = EntityWithPublishedAt::withNotPublished()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_not_published(): void
{
EntityWithPublishedAt::factory()->count(3)->create([
'published_at' => Date::now()->subDay(),
]);
EntityWithPublishedAt::factory()->count(2)->create([
'published_at' => null,
]);
$entities = EntityWithPublishedAt::onlyNotPublished()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_publish_model(): void
{
$model = EntityWithPublishedAt::factory()->create([
'published_at' => null,
]);
EntityWithPublishedAt::where('id', $model->id)->publish();
$model = EntityWithPublishedAt::where('id', $model->id)->first();
$this->assertNotNull($model->published_at);
}
/** @test */
public function it_can_undo_publish_model(): void
{
$model = EntityWithPublishedAt::factory()->create([
'published_at' => Date::now()->subDay(),
]);
EntityWithPublishedAt::where('id', $model->id)->undoPublish();
$model = EntityWithPublishedAt::withNotPublished()->where('id', $model->id)->first();
$this->assertNull($model->published_at);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithPublishedAt::factory()->count(3)->create([
'published_at' => Date::now()->subDay(),
]);
EntityWithPublishedAt::factory()->count(2)->create([
'published_at' => null,
]);
$entities = EntityWithPublishedAtUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithPublishedAt::factory()->count(3)->create([
'published_at' => Date::now()->subDay(),
]);
EntityWithPublishedAt::factory()->count(2)->create([
'published_at' => null,
]);
$entities = EntityWithPublishedAtApplied::all();
$this->assertCount(3, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Classic/ActiveFlagScopeTest.php | tests/Unit/Scopes/Classic/ActiveFlagScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithActiveFlag;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithActiveFlagApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithActiveFlagUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
final class ActiveFlagScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithActiveFlag::factory()->count(3)->create([
'is_active' => true,
]);
EntityWithActiveFlag::factory()->count(2)->create([
'is_active' => false,
]);
$entities = EntityWithActiveFlag::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_not_activated(): void
{
EntityWithActiveFlag::factory()->count(3)->create([
'is_active' => true,
]);
EntityWithActiveFlag::factory()->count(2)->create([
'is_active' => false,
]);
$entities = EntityWithActiveFlag::withoutNotActivated()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_get_with_not_activated(): void
{
EntityWithActiveFlag::factory()->count(3)->create([
'is_active' => true,
]);
EntityWithActiveFlag::factory()->count(2)->create([
'is_active' => false,
]);
$entities = EntityWithActiveFlag::withNotActivated()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_not_activated(): void
{
EntityWithActiveFlag::factory()->count(3)->create([
'is_active' => true,
]);
EntityWithActiveFlag::factory()->count(2)->create([
'is_active' => false,
]);
$entities = EntityWithActiveFlag::onlyNotActivated()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_activate_model(): void
{
$model = EntityWithActiveFlag::factory()->create([
'is_active' => false,
]);
EntityWithActiveFlag::where('id', $model->id)->activate();
$model = EntityWithActiveFlag::where('id', $model->id)->first();
$this->assertTrue($model->is_active);
}
/** @test */
public function it_can_undo_activate_model(): void
{
$model = EntityWithActiveFlag::factory()->create([
'is_active' => true,
]);
EntityWithActiveFlag::where('id', $model->id)->undoActivate();
$model = EntityWithActiveFlag::withNotActivated()->where('id', $model->id)->first();
$this->assertFalse($model->is_active);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithActiveFlag::factory()->count(3)->create([
'is_active' => true,
]);
EntityWithActiveFlag::factory()->count(2)->create([
'is_active' => false,
]);
$entities = EntityWithActiveFlagUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithActiveFlag::factory()->count(3)->create([
'is_active' => true,
]);
EntityWithActiveFlag::factory()->count(2)->create([
'is_active' => false,
]);
$entities = EntityWithActiveFlagApplied::all();
$this->assertCount(3, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Classic/PublishedFlagScopeTest.php | tests/Unit/Scopes/Classic/PublishedFlagScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithPublishedFlag;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithPublishedFlagApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithPublishedFlagUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
final class PublishedFlagScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithPublishedFlag::factory()->count(3)->create([
'is_published' => true,
]);
EntityWithPublishedFlag::factory()->count(2)->create([
'is_published' => false,
]);
$entities = EntityWithPublishedFlag::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_not_published(): void
{
EntityWithPublishedFlag::factory()->count(3)->create([
'is_published' => true,
]);
EntityWithPublishedFlag::factory()->count(2)->create([
'is_published' => false,
]);
$entities = EntityWithPublishedFlag::withoutNotPublished()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_get_with_not_published(): void
{
EntityWithPublishedFlag::factory()->count(3)->create([
'is_published' => true,
]);
EntityWithPublishedFlag::factory()->count(2)->create([
'is_published' => false,
]);
$entities = EntityWithPublishedFlag::withNotPublished()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_not_published(): void
{
EntityWithPublishedFlag::factory()->count(3)->create([
'is_published' => true,
]);
EntityWithPublishedFlag::factory()->count(2)->create([
'is_published' => false,
]);
$entities = EntityWithPublishedFlag::onlyNotPublished()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_publish_model(): void
{
$model = EntityWithPublishedFlag::factory()->create([
'is_published' => false,
]);
EntityWithPublishedFlag::where('id', $model->id)->publish();
$model = EntityWithPublishedFlag::where('id', $model->id)->first();
$this->assertTrue($model->is_published);
}
/** @test */
public function it_can_undo_publish_model(): void
{
$model = EntityWithPublishedFlag::factory()->create([
'is_published' => true,
]);
EntityWithPublishedFlag::where('id', $model->id)->undoPublish();
$model = EntityWithPublishedFlag::withNotPublished()->where('id', $model->id)->first();
$this->assertFalse($model->is_published);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithPublishedFlag::factory()->count(3)->create([
'is_published' => true,
]);
EntityWithPublishedFlag::factory()->count(2)->create([
'is_published' => false,
]);
$entities = EntityWithPublishedFlagUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithPublishedFlag::factory()->count(3)->create([
'is_published' => true,
]);
EntityWithPublishedFlag::factory()->count(2)->create([
'is_published' => false,
]);
$entities = EntityWithPublishedFlagApplied::all();
$this->assertCount(3, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Inverse/ExpiredFlagScopeTest.php | tests/Unit/Scopes/Inverse/ExpiredFlagScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithExpiredFlag;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithExpiredFlagApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithExpiredFlagUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
final class ExpiredFlagScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithExpiredFlag::factory()->count(3)->create([
'is_expired' => true,
]);
EntityWithExpiredFlag::factory()->count(2)->create([
'is_expired' => false,
]);
$entities = EntityWithExpiredFlag::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_expired(): void
{
EntityWithExpiredFlag::factory()->count(3)->create([
'is_expired' => true,
]);
EntityWithExpiredFlag::factory()->count(2)->create([
'is_expired' => false,
]);
$entities = EntityWithExpiredFlag::withoutExpired()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_get_with_expired(): void
{
EntityWithExpiredFlag::factory()->count(3)->create([
'is_expired' => true,
]);
EntityWithExpiredFlag::factory()->count(2)->create([
'is_expired' => false,
]);
$entities = EntityWithExpiredFlag::withExpired()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_expired(): void
{
EntityWithExpiredFlag::factory()->count(3)->create([
'is_expired' => true,
]);
EntityWithExpiredFlag::factory()->count(2)->create([
'is_expired' => false,
]);
$entities = EntityWithExpiredFlag::onlyExpired()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_undo_expire_model(): void
{
$model = EntityWithExpiredFlag::factory()->create([
'is_expired' => true,
]);
EntityWithExpiredFlag::where('id', $model->id)->undoExpire();
$model = EntityWithExpiredFlag::where('id', $model->id)->first();
$this->assertFalse($model->is_expired);
}
/** @test */
public function it_can_expire_model(): void
{
$model = EntityWithExpiredFlag::factory()->create([
'is_expired' => false,
]);
EntityWithExpiredFlag::where('id', $model->id)->expire();
$model = EntityWithExpiredFlag::withExpired()->where('id', $model->id)->first();
$this->assertTrue($model->is_expired);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithExpiredFlag::factory()->count(3)->create([
'is_expired' => true,
]);
EntityWithExpiredFlag::factory()->count(2)->create([
'is_expired' => false,
]);
$entities = EntityWithExpiredFlagUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithExpiredFlag::factory()->count(3)->create([
'is_expired' => true,
]);
EntityWithExpiredFlag::factory()->count(2)->create([
'is_expired' => false,
]);
$entities = EntityWithExpiredFlagApplied::all();
$this->assertCount(2, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Inverse/ClosedAtScopeTest.php | tests/Unit/Scopes/Inverse/ClosedAtScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithClosedAt;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithClosedAtApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithClosedAtUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Facades\Date;
final class ClosedAtScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithClosedAt::factory()->count(3)->create([
'closed_at' => Date::now()->subDay(),
]);
EntityWithClosedAt::factory()->count(2)->create([
'closed_at' => null,
]);
$entities = EntityWithClosedAt::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_closed(): void
{
EntityWithClosedAt::factory()->count(3)->create([
'closed_at' => Date::now()->subDay(),
]);
EntityWithClosedAt::factory()->count(2)->create([
'closed_at' => null,
]);
$entities = EntityWithClosedAt::withoutClosed()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_get_with_closed(): void
{
EntityWithClosedAt::factory()->count(3)->create([
'closed_at' => Date::now()->subDay(),
]);
EntityWithClosedAt::factory()->count(2)->create([
'closed_at' => null,
]);
$entities = EntityWithClosedAt::withClosed()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_closed(): void
{
EntityWithClosedAt::factory()->count(3)->create([
'closed_at' => Date::now()->subDay(),
]);
EntityWithClosedAt::factory()->count(2)->create([
'closed_at' => null,
]);
$entities = EntityWithClosedAt::onlyClosed()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_undo_close_model(): void
{
$model = EntityWithClosedAt::factory()->create([
'closed_at' => Date::now()->subDay(),
]);
EntityWithClosedAt::where('id', $model->id)->undoClose();
$model = EntityWithClosedAt::where('id', $model->id)->first();
$this->assertNull($model->closed_at);
}
/** @test */
public function it_can_close_model(): void
{
$model = EntityWithClosedAt::factory()->create([
'closed_at' => null,
]);
EntityWithClosedAt::where('id', $model->id)->close();
$model = EntityWithClosedAt::withClosed()->where('id', $model->id)->first();
$this->assertNotNull($model->closed_at);
}
/** @test */
public function it_can_skip_auto_apply(): void
{
EntityWithClosedAt::factory()->count(3)->create([
'closed_at' => Date::now()->subDay(),
]);
EntityWithClosedAt::factory()->count(2)->create([
'closed_at' => null,
]);
$entities = EntityWithClosedAtUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithClosedAt::factory()->count(3)->create([
'closed_at' => Date::now()->subDay(),
]);
EntityWithClosedAt::factory()->count(2)->create([
'closed_at' => null,
]);
$entities = EntityWithClosedAtApplied::all();
$this->assertCount(2, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Inverse/EndedFlagScopeTest.php | tests/Unit/Scopes/Inverse/EndedFlagScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithEndedFlag;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithEndedFlagApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithEndedFlagUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
final class EndedFlagScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithEndedFlag::factory()->count(3)->create([
'is_ended' => true,
]);
EntityWithEndedFlag::factory()->count(2)->create([
'is_ended' => false,
]);
$entities = EntityWithEndedFlag::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_ended(): void
{
EntityWithEndedFlag::factory()->count(3)->create([
'is_ended' => true,
]);
EntityWithEndedFlag::factory()->count(2)->create([
'is_ended' => false,
]);
$entities = EntityWithEndedFlag::withoutEnded()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_get_with_ended(): void
{
EntityWithEndedFlag::factory()->count(3)->create([
'is_ended' => true,
]);
EntityWithEndedFlag::factory()->count(2)->create([
'is_ended' => false,
]);
$entities = EntityWithEndedFlag::withEnded()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_ended(): void
{
EntityWithEndedFlag::factory()->count(3)->create([
'is_ended' => true,
]);
EntityWithEndedFlag::factory()->count(2)->create([
'is_ended' => false,
]);
$entities = EntityWithEndedFlag::onlyEnded()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_undo_end_model(): void
{
$model = EntityWithEndedFlag::factory()->create([
'is_ended' => true,
]);
EntityWithEndedFlag::where('id', $model->id)->undoEnd();
$model = EntityWithEndedFlag::where('id', $model->id)->first();
$this->assertFalse($model->is_ended);
}
/** @test */
public function it_can_end_model(): void
{
$model = EntityWithEndedFlag::factory()->create([
'is_ended' => false,
]);
EntityWithEndedFlag::where('id', $model->id)->end();
$model = EntityWithEndedFlag::withEnded()->where('id', $model->id)->first();
$this->assertTrue($model->is_ended);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithEndedFlag::factory()->count(3)->create([
'is_ended' => true,
]);
EntityWithEndedFlag::factory()->count(2)->create([
'is_ended' => false,
]);
$entities = EntityWithEndedFlagUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithEndedFlag::factory()->count(3)->create([
'is_ended' => true,
]);
EntityWithEndedFlag::factory()->count(2)->create([
'is_ended' => false,
]);
$entities = EntityWithEndedFlagApplied::all();
$this->assertCount(2, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Inverse/ArchivedFlagScopeTest.php | tests/Unit/Scopes/Inverse/ArchivedFlagScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithArchivedFlag;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithArchivedFlagApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithArchivedFlagUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
final class ArchivedFlagScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithArchivedFlag::factory()->count(3)->create([
'is_archived' => true,
]);
EntityWithArchivedFlag::factory()->count(2)->create([
'is_archived' => false,
]);
$entities = EntityWithArchivedFlag::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_archived(): void
{
EntityWithArchivedFlag::factory()->count(3)->create([
'is_archived' => true,
]);
EntityWithArchivedFlag::factory()->count(2)->create([
'is_archived' => false,
]);
$entities = EntityWithArchivedFlag::withoutArchived()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_get_with_archived(): void
{
EntityWithArchivedFlag::factory()->count(3)->create([
'is_archived' => true,
]);
EntityWithArchivedFlag::factory()->count(2)->create([
'is_archived' => false,
]);
$entities = EntityWithArchivedFlag::withArchived()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_archived(): void
{
EntityWithArchivedFlag::factory()->count(3)->create([
'is_archived' => true,
]);
EntityWithArchivedFlag::factory()->count(2)->create([
'is_archived' => false,
]);
$entities = EntityWithArchivedFlag::onlyArchived()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_undo_archive_model(): void
{
$model = EntityWithArchivedFlag::factory()->create([
'is_archived' => true,
]);
EntityWithArchivedFlag::where('id', $model->id)->undoArchive();
$model = EntityWithArchivedFlag::where('id', $model->id)->first();
$this->assertFalse($model->is_archived);
}
/** @test */
public function it_can_archive_model(): void
{
$model = EntityWithArchivedFlag::factory()->create([
'is_archived' => false,
]);
EntityWithArchivedFlag::where('id', $model->id)->archive();
$model = EntityWithArchivedFlag::withArchived()->where('id', $model->id)->first();
$this->assertTrue($model->is_archived);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithArchivedFlag::factory()->count(3)->create([
'is_archived' => true,
]);
EntityWithArchivedFlag::factory()->count(2)->create([
'is_archived' => false,
]);
$entities = EntityWithArchivedFlagUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithArchivedFlag::factory()->count(3)->create([
'is_archived' => true,
]);
EntityWithArchivedFlag::factory()->count(2)->create([
'is_archived' => false,
]);
$entities = EntityWithArchivedFlagApplied::all();
$this->assertCount(2, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Inverse/ExpiredAtScopeTest.php | tests/Unit/Scopes/Inverse/ExpiredAtScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithExpiredAt;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithExpiredAtApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithExpiredAtUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Facades\Date;
final class ExpiredAtScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithExpiredAt::factory()->count(3)->create([
'expired_at' => Date::now()->subDay(),
]);
EntityWithExpiredAt::factory()->count(2)->create([
'expired_at' => null,
]);
$entities = EntityWithExpiredAt::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_expired(): void
{
EntityWithExpiredAt::factory()->count(3)->create([
'expired_at' => Date::now()->subDay(),
]);
EntityWithExpiredAt::factory()->count(2)->create([
'expired_at' => null,
]);
$entities = EntityWithExpiredAt::withoutExpired()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_get_with_expired(): void
{
EntityWithExpiredAt::factory()->count(3)->create([
'expired_at' => Date::now()->subDay(),
]);
EntityWithExpiredAt::factory()->count(2)->create([
'expired_at' => null,
]);
$entities = EntityWithExpiredAt::withExpired()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_expired(): void
{
EntityWithExpiredAt::factory()->count(3)->create([
'expired_at' => Date::now()->subDay(),
]);
EntityWithExpiredAt::factory()->count(2)->create([
'expired_at' => null,
]);
$entities = EntityWithExpiredAt::onlyExpired()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_undo_expire_model(): void
{
$model = EntityWithExpiredAt::factory()->create([
'expired_at' => Date::now()->subDay(),
]);
EntityWithExpiredAt::where('id', $model->id)->undoExpire();
$model = EntityWithExpiredAt::where('id', $model->id)->first();
$this->assertNull($model->expired_at);
}
/** @test */
public function it_can_expire_model(): void
{
$model = EntityWithExpiredAt::factory()->create([
'expired_at' => null,
]);
EntityWithExpiredAt::where('id', $model->id)->expire();
$model = EntityWithExpiredAt::withExpired()->where('id', $model->id)->first();
$this->assertNotNull($model->expired_at);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithExpiredAt::factory()->count(3)->create([
'expired_at' => Date::now()->subDay(),
]);
EntityWithExpiredAt::factory()->count(2)->create([
'expired_at' => null,
]);
$entities = EntityWithExpiredAtUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithExpiredAt::factory()->count(3)->create([
'expired_at' => Date::now()->subDay(),
]);
EntityWithExpiredAt::factory()->count(2)->create([
'expired_at' => null,
]);
$entities = EntityWithExpiredAtApplied::all();
$this->assertCount(2, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Inverse/DraftedFlagScopeTest.php | tests/Unit/Scopes/Inverse/DraftedFlagScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithDraftedFlag;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithDraftedFlagApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithDraftedFlagUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
final class DraftedFlagScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithDraftedFlag::factory()->count(3)->create([
'is_drafted' => true,
]);
EntityWithDraftedFlag::factory()->count(2)->create([
'is_drafted' => false,
]);
$entities = EntityWithDraftedFlag::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_drafted(): void
{
EntityWithDraftedFlag::factory()->count(3)->create([
'is_drafted' => true,
]);
EntityWithDraftedFlag::factory()->count(2)->create([
'is_drafted' => false,
]);
$entities = EntityWithDraftedFlag::withoutDrafted()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_get_with_drafted(): void
{
EntityWithDraftedFlag::factory()->count(3)->create([
'is_drafted' => true,
]);
EntityWithDraftedFlag::factory()->count(2)->create([
'is_drafted' => false,
]);
$entities = EntityWithDraftedFlag::withDrafted()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_drafted(): void
{
EntityWithDraftedFlag::factory()->count(3)->create([
'is_drafted' => true,
]);
EntityWithDraftedFlag::factory()->count(2)->create([
'is_drafted' => false,
]);
$entities = EntityWithDraftedFlag::onlyDrafted()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_undo_draft_model(): void
{
$model = EntityWithDraftedFlag::factory()->create([
'is_drafted' => true,
]);
EntityWithDraftedFlag::where('id', $model->id)->undoDraft();
$model = EntityWithDraftedFlag::where('id', $model->id)->first();
$this->assertFalse($model->is_drafted);
}
/** @test */
public function it_can_draft_model(): void
{
$model = EntityWithDraftedFlag::factory()->create([
'is_drafted' => false,
]);
EntityWithDraftedFlag::where('id', $model->id)->draft();
$model = EntityWithDraftedFlag::withDrafted()->where('id', $model->id)->first();
$this->assertTrue($model->is_drafted);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithDraftedFlag::factory()->count(3)->create([
'is_drafted' => true,
]);
EntityWithDraftedFlag::factory()->count(2)->create([
'is_drafted' => false,
]);
$entities = EntityWithDraftedFlagUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithDraftedFlag::factory()->count(3)->create([
'is_drafted' => true,
]);
EntityWithDraftedFlag::factory()->count(2)->create([
'is_drafted' => false,
]);
$entities = EntityWithDraftedFlagApplied::all();
$this->assertCount(2, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Inverse/EndedAtScopeTest.php | tests/Unit/Scopes/Inverse/EndedAtScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithEndedAt;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithEndedAtApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithEndedAtUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Facades\Date;
final class EndedAtScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithEndedAt::factory()->count(3)->create([
'ended_at' => Date::now()->subDay(),
]);
EntityWithEndedAt::factory()->count(2)->create([
'ended_at' => null,
]);
$entities = EntityWithEndedAt::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_ended(): void
{
EntityWithEndedAt::factory()->count(3)->create([
'ended_at' => Date::now()->subDay(),
]);
EntityWithEndedAt::factory()->count(2)->create([
'ended_at' => null,
]);
$entities = EntityWithEndedAt::withoutEnded()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_get_with_ended(): void
{
EntityWithEndedAt::factory()->count(3)->create([
'ended_at' => Date::now()->subDay(),
]);
EntityWithEndedAt::factory()->count(2)->create([
'ended_at' => null,
]);
$entities = EntityWithEndedAt::withEnded()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_ended(): void
{
EntityWithEndedAt::factory()->count(3)->create([
'ended_at' => Date::now()->subDay(),
]);
EntityWithEndedAt::factory()->count(2)->create([
'ended_at' => null,
]);
$entities = EntityWithEndedAt::onlyEnded()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_undo_end_model(): void
{
$model = EntityWithEndedAt::factory()->create([
'ended_at' => Date::now()->subDay(),
]);
EntityWithEndedAt::where('id', $model->id)->undoEnd();
$model = EntityWithEndedAt::where('id', $model->id)->first();
$this->assertNull($model->ended_at);
}
/** @test */
public function it_can_end_model(): void
{
$model = EntityWithEndedAt::factory()->create([
'ended_at' => null,
]);
EntityWithEndedAt::where('id', $model->id)->end();
$model = EntityWithEndedAt::withEnded()->where('id', $model->id)->first();
$this->assertNotNull($model->ended_at);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithEndedAt::factory()->count(3)->create([
'ended_at' => Date::now()->subDay(),
]);
EntityWithEndedAt::factory()->count(2)->create([
'ended_at' => null,
]);
$entities = EntityWithEndedAtUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithEndedAt::factory()->count(3)->create([
'ended_at' => Date::now()->subDay(),
]);
EntityWithEndedAt::factory()->count(2)->create([
'ended_at' => null,
]);
$entities = EntityWithEndedAtApplied::all();
$this->assertCount(2, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Inverse/ClosedFlagScopeTest.php | tests/Unit/Scopes/Inverse/ClosedFlagScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithClosedFlag;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithClosedFlagApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithClosedFlagUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
final class ClosedFlagScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithClosedFlag::factory()->count(3)->create([
'is_closed' => true,
]);
EntityWithClosedFlag::factory()->count(2)->create([
'is_closed' => false,
]);
$entities = EntityWithClosedFlag::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_closed(): void
{
EntityWithClosedFlag::factory()->count(3)->create([
'is_closed' => true,
]);
EntityWithClosedFlag::factory()->count(2)->create([
'is_closed' => false,
]);
$entities = EntityWithClosedFlag::withoutClosed()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_get_with_closed(): void
{
EntityWithClosedFlag::factory()->count(3)->create([
'is_closed' => true,
]);
EntityWithClosedFlag::factory()->count(2)->create([
'is_closed' => false,
]);
$entities = EntityWithClosedFlag::withClosed()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_closed(): void
{
EntityWithClosedFlag::factory()->count(3)->create([
'is_closed' => true,
]);
EntityWithClosedFlag::factory()->count(2)->create([
'is_closed' => false,
]);
$entities = EntityWithClosedFlag::onlyClosed()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_undo_close_model(): void
{
$model = EntityWithClosedFlag::factory()->create([
'is_closed' => true,
]);
EntityWithClosedFlag::where('id', $model->id)->undoClose();
$model = EntityWithClosedFlag::where('id', $model->id)->first();
$this->assertFalse($model->is_closed);
}
/** @test */
public function it_can_close_model(): void
{
$model = EntityWithClosedFlag::factory()->create([
'is_closed' => false,
]);
EntityWithClosedFlag::where('id', $model->id)->close();
$model = EntityWithClosedFlag::withClosed()->where('id', $model->id)->first();
$this->assertTrue($model->is_closed);
}
/** @test */
public function it_can_skip_auto_apply(): void
{
EntityWithClosedFlag::factory()->count(3)->create([
'is_closed' => true,
]);
EntityWithClosedFlag::factory()->count(2)->create([
'is_closed' => false,
]);
$entities = EntityWithClosedFlagUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithClosedFlag::factory()->count(3)->create([
'is_closed' => true,
]);
EntityWithClosedFlag::factory()->count(2)->create([
'is_closed' => false,
]);
$entities = EntityWithClosedFlagApplied::all();
$this->assertCount(2, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Inverse/DraftedAtScopeTest.php | tests/Unit/Scopes/Inverse/DraftedAtScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithDraftedAt;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithDraftedAtApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithDraftedAtUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Facades\Date;
final class DraftedAtScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithDraftedAt::factory()->count(3)->create([
'drafted_at' => Date::now()->subDay(),
]);
EntityWithDraftedAt::factory()->count(2)->create([
'drafted_at' => null,
]);
$entities = EntityWithDraftedAt::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_drafted(): void
{
EntityWithDraftedAt::factory()->count(3)->create([
'drafted_at' => Date::now()->subDay(),
]);
EntityWithDraftedAt::factory()->count(2)->create([
'drafted_at' => null,
]);
$entities = EntityWithDraftedAt::withoutDrafted()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_get_with_drafted(): void
{
EntityWithDraftedAt::factory()->count(3)->create([
'drafted_at' => Date::now()->subDay(),
]);
EntityWithDraftedAt::factory()->count(2)->create([
'drafted_at' => null,
]);
$entities = EntityWithDraftedAt::withDrafted()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_drafted(): void
{
EntityWithDraftedAt::factory()->count(3)->create([
'drafted_at' => Date::now()->subDay(),
]);
EntityWithDraftedAt::factory()->count(2)->create([
'drafted_at' => null,
]);
$entities = EntityWithDraftedAt::onlyDrafted()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_undo_draft_model(): void
{
$model = EntityWithDraftedAt::factory()->create([
'drafted_at' => Date::now()->subDay(),
]);
EntityWithDraftedAt::where('id', $model->id)->undoDraft();
$model = EntityWithDraftedAt::where('id', $model->id)->first();
$this->assertNull($model->drafted_at);
}
/** @test */
public function it_can_draft_model(): void
{
$model = EntityWithDraftedAt::factory()->create([
'drafted_at' => null,
]);
EntityWithDraftedAt::where('id', $model->id)->draft();
$model = EntityWithDraftedAt::withDrafted()->where('id', $model->id)->first();
$this->assertNotNull($model->drafted_at);
}
/** @test */
public function it_can_skip_apply(): void
{
EntityWithDraftedAt::factory()->count(3)->create([
'drafted_at' => Date::now()->subDay(),
]);
EntityWithDraftedAt::factory()->count(2)->create([
'drafted_at' => null,
]);
$entities = EntityWithDraftedAtUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithDraftedAt::factory()->count(3)->create([
'drafted_at' => Date::now()->subDay(),
]);
EntityWithDraftedAt::factory()->count(2)->create([
'drafted_at' => null,
]);
$entities = EntityWithDraftedAtApplied::all();
$this->assertCount(2, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Scopes/Inverse/ArchivedAtScopeTest.php | tests/Unit/Scopes/Inverse/ArchivedAtScopeTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Scopes\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithArchivedAt;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithArchivedAtApplied;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithArchivedAtUnapplied;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Facades\Date;
final class ArchivedAtScopeTest extends TestCase
{
/** @test */
public function it_get_without_global_scope_default(): void
{
EntityWithArchivedAt::factory()->count(3)->create([
'archived_at' => Date::now()->subDay(),
]);
EntityWithArchivedAt::factory()->count(2)->create([
'archived_at' => null,
]);
$entities = EntityWithArchivedAt::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_without_archived(): void
{
EntityWithArchivedAt::factory()->count(3)->create([
'archived_at' => Date::now()->subDay(),
]);
EntityWithArchivedAt::factory()->count(2)->create([
'archived_at' => null,
]);
$entities = EntityWithArchivedAt::withoutArchived()->get();
$this->assertCount(2, $entities);
}
/** @test */
public function it_can_get_with_archived(): void
{
EntityWithArchivedAt::factory()->count(3)->create([
'archived_at' => Date::now()->subDay(),
]);
EntityWithArchivedAt::factory()->count(2)->create([
'archived_at' => null,
]);
$entities = EntityWithArchivedAt::withArchived()->get();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_get_only_archived(): void
{
EntityWithArchivedAt::factory()->count(3)->create([
'archived_at' => Date::now()->subDay(),
]);
EntityWithArchivedAt::factory()->count(2)->create([
'archived_at' => null,
]);
$entities = EntityWithArchivedAt::onlyArchived()->get();
$this->assertCount(3, $entities);
}
/** @test */
public function it_can_undo_archive_model(): void
{
$model = EntityWithArchivedAt::factory()->create([
'archived_at' => Date::now()->subDay(),
]);
EntityWithArchivedAt::where('id', $model->id)->undoArchive();
$model = EntityWithArchivedAt::where('id', $model->id)->first();
$this->assertNull($model->archived_at);
}
/** @test */
public function it_can_archive_model(): void
{
$model = EntityWithArchivedAt::factory()->create([
'archived_at' => null,
]);
EntityWithArchivedAt::where('id', $model->id)->archive();
$model = EntityWithArchivedAt::withArchived()->where('id', $model->id)->first();
$this->assertNotNull($model->archived_at);
}
/** @test */
public function it_can_skip_auto_apply(): void
{
EntityWithArchivedAt::factory()->count(3)->create([
'archived_at' => Date::now()->subDay(),
]);
EntityWithArchivedAt::factory()->count(2)->create([
'archived_at' => null,
]);
$entities = EntityWithArchivedAtUnapplied::all();
$this->assertCount(5, $entities);
}
/** @test */
public function it_can_auto_apply(): void
{
EntityWithArchivedAt::factory()->count(3)->create([
'archived_at' => Date::now()->subDay(),
]);
EntityWithArchivedAt::factory()->count(2)->create([
'archived_at' => null,
]);
$entities = EntityWithArchivedAtApplied::all();
$this->assertCount(2, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Classic/HasKeptFlagBehaviorTest.php | tests/Unit/Traits/Classic/HasKeptFlagBehaviorTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithKeptFlag;
use Cog\Tests\Laravel\Flag\TestCase;
final class HasKeptFlagBehaviorTest extends TestCase
{
/** @test */
public function it_sets_is_kept_false_on_create(): void
{
$entity = new EntityWithKeptFlag([
'name' => 'test',
]);
$entity->save();
$this->assertFalse($entity->is_kept);
}
/** @test */
public function it_sets_is_kept_true_on_any_update(): void
{
$entity = EntityWithKeptFlag::factory()->create([
'is_kept' => false,
]);
$entity->update([
'name' => 'new-name',
]);
$this->assertTrue($entity->is_kept);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Classic/HasActiveFlagHelpersTest.php | tests/Unit/Traits/Classic/HasActiveFlagHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithActiveFlag;
use Cog\Tests\Laravel\Flag\TestCase;
final class HasActiveFlagHelpersTest extends TestCase
{
/** @test */
public function it_casts_is_active_to_boolean(): void
{
$entity = EntityWithActiveFlag::factory()->create([
'is_active' => 1,
]);
$this->assertTrue($entity->is_active);
}
/** @test */
public function it_not_casts_is_active_to_boolean(): void
{
$entity = EntityWithActiveFlag::factory()->make([
'is_active' => null,
]);
$this->assertNull($entity->is_active);
}
/** @test */
public function it_can_check_if_entity_is_active(): void
{
$activatedEntity = EntityWithActiveFlag::factory()->create([
'is_active' => true,
]);
$deactivatedEntity = EntityWithActiveFlag::factory()->create([
'is_active' => false,
]);
$this->assertTrue($activatedEntity->isActivated());
$this->assertFalse($deactivatedEntity->isActivated());
}
/** @test */
public function it_can_check_if_entity_is_not_activated(): void
{
$activatedEntity = EntityWithActiveFlag::factory()->create([
'is_active' => true,
]);
$deactivatedEntity = EntityWithActiveFlag::factory()->create([
'is_active' => false,
]);
$this->assertFalse($activatedEntity->isNotActivated());
$this->assertTrue($deactivatedEntity->isNotActivated());
}
/** @test */
public function it_can_activate(): void
{
$entity = EntityWithActiveFlag::factory()->create([
'is_active' => false,
]);
$entity->activate();
$this->assertTrue($entity->is_active);
}
/** @test */
public function it_can_undo_activate(): void
{
$entity = EntityWithActiveFlag::factory()->create([
'is_active' => true,
]);
$entity->undoActivate();
$this->assertFalse($entity->is_active);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Classic/HasVerifiedAtHelpersTest.php | tests/Unit/Traits/Classic/HasVerifiedAtHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithVerifiedAt;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Date;
final class HasVerifiedAtHelpersTest extends TestCase
{
/** @test */
public function it_casts_verified_at_to_datetime(): void
{
$entity = EntityWithVerifiedAt::factory()->create([
'verified_at' => '1986-03-28 00:00:00',
]);
$this->assertInstanceOf(Carbon::class, $entity->verified_at);
$this->assertSame('1986-03-28 00:00:00', $entity->verified_at->format('Y-m-d H:i:s'));
}
/** @test */
public function it_can_check_if_entity_is_verified(): void
{
$verifiedEntity = EntityWithVerifiedAt::factory()->create([
'verified_at' => Date::now(),
]);
$unverifiedEntity = EntityWithVerifiedAt::factory()->create([
'verified_at' => null,
]);
$this->assertTrue($verifiedEntity->isVerified());
$this->assertFalse($unverifiedEntity->isVerified());
}
/** @test */
public function it_can_check_if_entity_is_not_verified(): void
{
$verifiedEntity = EntityWithVerifiedAt::factory()->create([
'verified_at' => Date::now(),
]);
$unverifiedEntity = EntityWithVerifiedAt::factory()->create([
'verified_at' => null,
]);
$this->assertFalse($verifiedEntity->isNotVerified());
$this->assertTrue($unverifiedEntity->isNotVerified());
}
/** @test */
public function it_can_verify(): void
{
$entity = EntityWithVerifiedAt::factory()->create([
'verified_at' => null,
]);
$entity->verify();
$this->assertNotNull($entity->verified_at);
}
/** @test */
public function it_can_undo_verify(): void
{
$entity = EntityWithVerifiedAt::factory()->create([
'verified_at' => Date::now(),
]);
$entity->undoVerify();
$this->assertNull($entity->verified_at);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Classic/HasPublishedFlagHelpersTest.php | tests/Unit/Traits/Classic/HasPublishedFlagHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithPublishedFlag;
use Cog\Tests\Laravel\Flag\TestCase;
final class HasPublishedFlagHelpersTest extends TestCase
{
/** @test */
public function it_casts_is_published_to_boolean(): void
{
$entity = EntityWithPublishedFlag::factory()->create([
'is_published' => 1,
]);
$this->assertTrue($entity->is_published);
}
/** @test */
public function it_not_casts_is_published_to_boolean(): void
{
$entity = EntityWithPublishedFlag::factory()->make([
'is_published' => null,
]);
$this->assertNull($entity->is_published);
}
/** @test */
public function it_can_check_if_entity_is_published(): void
{
$publishedEntity = EntityWithPublishedFlag::factory()->create([
'is_published' => true,
]);
$unpublishedEntity = EntityWithPublishedFlag::factory()->create([
'is_published' => false,
]);
$this->assertTrue($publishedEntity->isPublished());
$this->assertFalse($unpublishedEntity->isPublished());
}
/** @test */
public function it_can_check_if_entity_is_not_published(): void
{
$publishedEntity = EntityWithPublishedFlag::factory()->create([
'is_published' => true,
]);
$unpublishedEntity = EntityWithPublishedFlag::factory()->create([
'is_published' => false,
]);
$this->assertFalse($publishedEntity->isNotPublished());
$this->assertTrue($unpublishedEntity->isNotPublished());
}
/** @test */
public function it_can_publish(): void
{
$entity = EntityWithPublishedFlag::factory()->create([
'is_published' => false,
]);
$entity->publish();
$this->assertTrue($entity->is_published);
}
/** @test */
public function it_can_undo_publish(): void
{
$entity = EntityWithPublishedFlag::factory()->create([
'is_published' => true,
]);
$entity->undoPublish();
$this->assertFalse($entity->is_published);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Classic/HasInvitedFlagHelpersTest.php | tests/Unit/Traits/Classic/HasInvitedFlagHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithInvitedFlag;
use Cog\Tests\Laravel\Flag\TestCase;
final class HasInvitedFlagHelpersTest extends TestCase
{
/** @test */
public function it_casts_is_invited_to_boolean(): void
{
$entity = EntityWithInvitedFlag::factory()->create([
'is_invited' => 1,
]);
$this->assertTrue($entity->is_invited);
}
/** @test */
public function it_not_casts_is_invited_to_boolean(): void
{
$entity = EntityWithInvitedFlag::factory()->make([
'is_invited' => null,
]);
$this->assertNull($entity->is_invited);
}
/** @test */
public function it_can_check_if_entity_is_invited(): void
{
$invitedEntity = EntityWithInvitedFlag::factory()->create([
'is_invited' => true,
]);
$uninvitedEntity = EntityWithInvitedFlag::factory()->create([
'is_invited' => false,
]);
$this->assertTrue($invitedEntity->isInvited());
$this->assertFalse($uninvitedEntity->isInvited());
}
/** @test */
public function it_can_check_if_entity_is_not_invited(): void
{
$invitedEntity = EntityWithInvitedFlag::factory()->create([
'is_invited' => true,
]);
$uninvitedEntity = EntityWithInvitedFlag::factory()->create([
'is_invited' => false,
]);
$this->assertFalse($invitedEntity->isNotInvited());
$this->assertTrue($uninvitedEntity->isNotInvited());
}
/** @test */
public function it_can_invite(): void
{
$entity = EntityWithInvitedFlag::factory()->create([
'is_invited' => false,
]);
$entity->invite();
$this->assertTrue($entity->is_invited);
}
/** @test */
public function it_can_undo_invite(): void
{
$entity = EntityWithInvitedFlag::factory()->create([
'is_invited' => true,
]);
$entity->undoInvite();
$this->assertFalse($entity->is_invited);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Classic/HasPublishedAtHelpersTest.php | tests/Unit/Traits/Classic/HasPublishedAtHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithPublishedAt;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Date;
final class HasPublishedAtHelpersTest extends TestCase
{
/** @test */
public function it_casts_published_at_to_datetime(): void
{
$entity = EntityWithPublishedAt::factory()->create([
'published_at' => '1986-03-28 00:00:00',
]);
$this->assertInstanceOf(Carbon::class, $entity->published_at);
$this->assertSame('1986-03-28 00:00:00', $entity->published_at->format('Y-m-d H:i:s'));
}
/** @test */
public function it_can_check_if_entity_is_published(): void
{
$publishedEntity = EntityWithPublishedAt::factory()->create([
'published_at' => Date::now(),
]);
$unpublishedEntity = EntityWithPublishedAt::factory()->create([
'published_at' => null,
]);
$this->assertTrue($publishedEntity->isPublished());
$this->assertFalse($unpublishedEntity->isPublished());
}
/** @test */
public function it_can_check_if_entity_is_not_published(): void
{
$publishedEntity = EntityWithPublishedAt::factory()->create([
'published_at' => Date::now(),
]);
$unpublishedEntity = EntityWithPublishedAt::factory()->create([
'published_at' => null,
]);
$this->assertFalse($publishedEntity->isNotPublished());
$this->assertTrue($unpublishedEntity->isNotPublished());
}
/** @test */
public function it_can_publish(): void
{
$entity = EntityWithPublishedAt::factory()->create([
'published_at' => null,
]);
$entity->publish();
$this->assertNotNull($entity->published_at);
}
/** @test */
public function it_can_undo_publish(): void
{
$entity = EntityWithPublishedAt::factory()->create([
'published_at' => Date::now(),
]);
$entity->undoPublish();
$this->assertNull($entity->published_at);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Classic/HasKeptFlagHelperTest.php | tests/Unit/Traits/Classic/HasKeptFlagHelperTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithKeptFlag;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Facades\Date;
final class HasKeptFlagHelperTest extends TestCase
{
/** @test */
public function it_casts_is_kept_to_boolean(): void
{
$entity = EntityWithKeptFlag::factory()->create([
'is_kept' => 1,
]);
$this->assertTrue($entity->is_kept);
}
/** @test */
public function it_not_casts_is_kept_to_boolean(): void
{
$entity = EntityWithKeptFlag::factory()->make([
'is_kept' => null,
]);
$this->assertNull($entity->is_kept);
}
/** @test */
public function it_can_check_if_entity_is_kept(): void
{
$keptEntity = EntityWithKeptFlag::factory()->create([
'is_kept' => true,
]);
$unkeptEntity = EntityWithKeptFlag::factory()->create([
'is_kept' => false,
]);
$this->assertTrue($keptEntity->isKept());
$this->assertFalse($unkeptEntity->isKept());
}
/** @test */
public function it_can_check_if_entity_is_not_kept(): void
{
$keptEntity = EntityWithKeptFlag::factory()->create([
'is_kept' => true,
]);
$unkeptEntity = EntityWithKeptFlag::factory()->create([
'is_kept' => false,
]);
$this->assertFalse($keptEntity->isNotKept());
$this->assertTrue($unkeptEntity->isNotKept());
}
/** @test */
public function it_can_keep(): void
{
$entity = EntityWithKeptFlag::factory()->create([
'is_kept' => false,
]);
$entity->keep();
$this->assertTrue($entity->is_kept);
}
/** @test */
public function it_can_undo_keep(): void
{
$entity = EntityWithKeptFlag::factory()->create([
'is_kept' => true,
]);
$entity->undoKeep();
$this->assertFalse($entity->is_kept);
}
/** @test */
public function it_can_get_unkept_older_than_hours(): void
{
EntityWithKeptFlag::factory()->count(3)->create([
'is_kept' => true,
'created_at' => Date::now()->subHours(4)->toDateTimeString(),
]);
EntityWithKeptFlag::factory()->count(2)->create([
'is_kept' => false,
'created_at' => Date::now()->subHours(4)->toDateTimeString(),
]);
EntityWithKeptFlag::factory()->count(2)->create([
'is_kept' => false,
'created_at' => Date::now()->subHours(2)->toDateTimeString(),
]);
EntityWithKeptFlag::factory()->count(2)->create([
'is_kept' => false,
]);
$entities = EntityWithKeptFlag::onlyUnkeptOlderThanHours(4)->get();
$this->assertCount(2, $entities);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Classic/HasAcceptedAtHelpersTest.php | tests/Unit/Traits/Classic/HasAcceptedAtHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithAcceptedAt;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Date;
final class HasAcceptedAtHelpersTest extends TestCase
{
/** @test */
public function it_casts_accepted_at_to_datetime(): void
{
$entity = EntityWithAcceptedAt::factory()->create([
'accepted_at' => '1986-03-28 00:00:00',
]);
$this->assertInstanceOf(Carbon::class, $entity->accepted_at);
$this->assertSame('1986-03-28 00:00:00', $entity->accepted_at->format('Y-m-d H:i:s'));
}
/** @test */
public function it_can_check_if_entity_is_accepted(): void
{
$acceptedEntity = EntityWithAcceptedAt::factory()->create([
'accepted_at' => Date::now(),
]);
$rejectedEntity = EntityWithAcceptedAt::factory()->create([
'accepted_at' => null,
]);
$this->assertTrue($acceptedEntity->isAccepted());
$this->assertFalse($rejectedEntity->isAccepted());
}
/** @test */
public function it_can_check_if_entity_is_not_accepted(): void
{
$acceptedEntity = EntityWithAcceptedAt::factory()->create([
'accepted_at' => Date::now(),
]);
$rejectedEntity = EntityWithAcceptedAt::factory()->create([
'accepted_at' => null,
]);
$this->assertFalse($acceptedEntity->isNotAccepted());
$this->assertTrue($rejectedEntity->isNotAccepted());
}
/** @test */
public function it_can_accept(): void
{
$entity = EntityWithAcceptedAt::factory()->create([
'accepted_at' => null,
]);
$entity->accept();
$this->assertNotNull($entity->accepted_at);
}
/** @test */
public function it_can_undo_accept(): void
{
$entity = EntityWithAcceptedAt::factory()->create([
'accepted_at' => Date::now(),
]);
$entity->undoAccept();
$this->assertNull($entity->accepted_at);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Classic/HasApprovedAtHelpersTest.php | tests/Unit/Traits/Classic/HasApprovedAtHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithApprovedAt;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Date;
final class HasApprovedAtHelpersTest extends TestCase
{
/** @test */
public function it_casts_approved_at_to_datetime(): void
{
$entity = EntityWithApprovedAt::factory()->create([
'approved_at' => '1986-03-28 00:00:00',
]);
$this->assertInstanceOf(Carbon::class, $entity->approved_at);
$this->assertSame('1986-03-28 00:00:00', $entity->approved_at->format('Y-m-d H:i:s'));
}
/** @test */
public function it_can_check_if_entity_is_approved(): void
{
$approvedEntity = EntityWithApprovedAt::factory()->create([
'approved_at' => Date::now(),
]);
$disapprovedEntity = EntityWithApprovedAt::factory()->create([
'approved_at' => null,
]);
$this->assertTrue($approvedEntity->isApproved());
$this->assertFalse($disapprovedEntity->isApproved());
}
/** @test */
public function it_can_check_if_entity_is_not_approved(): void
{
$approvedEntity = EntityWithApprovedAt::factory()->create([
'approved_at' => Date::now(),
]);
$disapprovedEntity = EntityWithApprovedAt::factory()->create([
'approved_at' => null,
]);
$this->assertFalse($approvedEntity->isNotApproved());
$this->assertTrue($disapprovedEntity->isNotApproved());
}
/** @test */
public function it_can_approve(): void
{
$entity = EntityWithApprovedAt::factory()->create([
'approved_at' => null,
]);
$entity->approve();
$this->assertNotNull($entity->approved_at);
}
/** @test */
public function it_can_undo_approve(): void
{
$entity = EntityWithApprovedAt::factory()->create([
'approved_at' => Date::now(),
]);
$entity->undoApprove();
$this->assertNull($entity->approved_at);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Classic/HasInvitedAtHelpersTest.php | tests/Unit/Traits/Classic/HasInvitedAtHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithInvitedAt;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Date;
final class HasInvitedAtHelpersTest extends TestCase
{
/** @test */
public function it_casts_invited_at_to_datetime(): void
{
$entity = EntityWithInvitedAt::factory()->create([
'invited_at' => '1986-03-28 00:00:00',
]);
$this->assertInstanceOf(Carbon::class, $entity->invited_at);
$this->assertSame('1986-03-28 00:00:00', $entity->invited_at->format('Y-m-d H:i:s'));
}
/** @test */
public function it_can_check_if_entity_is_invited(): void
{
$invitedEntity = EntityWithInvitedAt::factory()->create([
'invited_at' => Date::now(),
]);
$uninvitedEntity = EntityWithInvitedAt::factory()->create([
'invited_at' => null,
]);
$this->assertTrue($invitedEntity->isInvited());
$this->assertFalse($uninvitedEntity->isInvited());
}
/** @test */
public function it_can_check_if_entity_is_not_invited(): void
{
$invitedEntity = EntityWithInvitedAt::factory()->create([
'invited_at' => Date::now(),
]);
$uninvitedEntity = EntityWithInvitedAt::factory()->create([
'invited_at' => null,
]);
$this->assertFalse($invitedEntity->isNotInvited());
$this->assertTrue($uninvitedEntity->isNotInvited());
}
/** @test */
public function it_can_invite(): void
{
$entity = EntityWithInvitedAt::factory()->create([
'invited_at' => null,
]);
$entity->invite();
$this->assertNotNull($entity->invited_at);
}
/** @test */
public function it_can_undo_invite(): void
{
$entity = EntityWithInvitedAt::factory()->create([
'invited_at' => Date::now(),
]);
$entity->undoInvite();
$this->assertNull($entity->invited_at);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Classic/HasApprovedFlagHelpersTest.php | tests/Unit/Traits/Classic/HasApprovedFlagHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithApprovedFlag;
use Cog\Tests\Laravel\Flag\TestCase;
final class HasApprovedFlagHelpersTest extends TestCase
{
/** @test */
public function it_casts_is_approved_to_boolean(): void
{
$entity = EntityWithApprovedFlag::factory()->create([
'is_approved' => 1,
]);
$this->assertTrue($entity->is_approved);
}
/** @test */
public function it_not_casts_is_approved_to_boolean(): void
{
$entity = EntityWithApprovedFlag::factory()->make([
'is_approved' => null,
]);
$this->assertNull($entity->is_approved);
}
/** @test */
public function it_can_check_if_entity_is_approved(): void
{
$approvedEntity = EntityWithApprovedFlag::factory()->create([
'is_approved' => true,
]);
$disapprovedEntity = EntityWithApprovedFlag::factory()->create([
'is_approved' => false,
]);
$this->assertTrue($approvedEntity->isApproved());
$this->assertFalse($disapprovedEntity->isApproved());
}
/** @test */
public function it_can_check_if_entity_is_not_approved(): void
{
$approvedEntity = EntityWithApprovedFlag::factory()->create([
'is_approved' => true,
]);
$disapprovedEntity = EntityWithApprovedFlag::factory()->create([
'is_approved' => false,
]);
$this->assertFalse($approvedEntity->isNotApproved());
$this->assertTrue($disapprovedEntity->isNotApproved());
}
/** @test */
public function it_can_approve(): void
{
$entity = EntityWithApprovedFlag::factory()->create([
'is_approved' => false,
]);
$entity->approve();
$this->assertTrue($entity->is_approved);
}
/** @test */
public function it_can_undo_approve(): void
{
$entity = EntityWithApprovedFlag::factory()->create([
'is_approved' => true,
]);
$entity->undoApprove();
$this->assertFalse($entity->is_approved);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Classic/HasAcceptedFlagHelpersTest.php | tests/Unit/Traits/Classic/HasAcceptedFlagHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithAcceptedFlag;
use Cog\Tests\Laravel\Flag\TestCase;
final class HasAcceptedFlagHelpersTest extends TestCase
{
/** @test */
public function it_casts_is_accepted_to_boolean(): void
{
$entity = EntityWithAcceptedFlag::factory()->create([
'is_accepted' => 1,
]);
$this->assertTrue($entity->is_accepted);
}
/** @test */
public function it_not_casts_is_accepted_to_boolean(): void
{
$entity = EntityWithAcceptedFlag::factory()->make([
'is_accepted' => null,
]);
$this->assertNull($entity->is_accepted);
}
/** @test */
public function it_can_check_if_entity_is_accepted(): void
{
$acceptedEntity = EntityWithAcceptedFlag::factory()->create([
'is_accepted' => true,
]);
$rejectedEntity = EntityWithAcceptedFlag::factory()->create([
'is_accepted' => false,
]);
$this->assertTrue($acceptedEntity->isAccepted());
$this->assertFalse($rejectedEntity->isAccepted());
}
/** @test */
public function it_can_check_if_entity_is_not_accepted(): void
{
$acceptedEntity = EntityWithAcceptedFlag::factory()->create([
'is_accepted' => true,
]);
$rejectedEntity = EntityWithAcceptedFlag::factory()->create([
'is_accepted' => false,
]);
$this->assertFalse($acceptedEntity->isNotAccepted());
$this->assertTrue($rejectedEntity->isNotAccepted());
}
/** @test */
public function it_can_accept(): void
{
$entity = EntityWithAcceptedFlag::factory()->create([
'is_accepted' => false,
]);
$entity->accept();
$this->assertTrue($entity->is_accepted);
}
/** @test */
public function it_can_undo_accept(): void
{
$entity = EntityWithAcceptedFlag::factory()->create([
'is_accepted' => true,
]);
$entity->undoAccept();
$this->assertFalse($entity->is_accepted);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Classic/HasVerifiedFlagHelpersTest.php | tests/Unit/Traits/Classic/HasVerifiedFlagHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Classic;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithVerifiedFlag;
use Cog\Tests\Laravel\Flag\TestCase;
final class HasVerifiedFlagHelpersTest extends TestCase
{
/** @test */
public function it_casts_is_verified_to_boolean(): void
{
$entity = EntityWithVerifiedFlag::factory()->create([
'is_verified' => 1,
]);
$this->assertTrue($entity->is_verified);
}
/** @test */
public function it_not_casts_is_verified_to_boolean(): void
{
$entity = EntityWithVerifiedFlag::factory()->make([
'is_verified' => null,
]);
$this->assertNull($entity->is_verified);
}
/** @test */
public function it_can_check_if_entity_is_verified(): void
{
$verifiedEntity = EntityWithVerifiedFlag::factory()->create([
'is_verified' => true,
]);
$unverifiedEntity = EntityWithVerifiedFlag::factory()->create([
'is_verified' => false,
]);
$this->assertTrue($verifiedEntity->isVerified());
$this->assertFalse($unverifiedEntity->isVerified());
}
/** @test */
public function it_can_check_if_entity_is_not_verified(): void
{
$verifiedEntity = EntityWithVerifiedFlag::factory()->create([
'is_verified' => true,
]);
$unverifiedEntity = EntityWithVerifiedFlag::factory()->create([
'is_verified' => false,
]);
$this->assertFalse($verifiedEntity->isNotVerified());
$this->assertTrue($unverifiedEntity->isNotVerified());
}
/** @test */
public function it_can_verify(): void
{
$entity = EntityWithVerifiedFlag::factory()->create([
'is_verified' => false,
]);
$entity->verify();
$this->assertTrue($entity->is_verified);
}
/** @test */
public function it_can_undo_verify(): void
{
$entity = EntityWithVerifiedFlag::factory()->create([
'is_verified' => true,
]);
$entity->undoVerify();
$this->assertFalse($entity->is_verified);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Inverse/HasExpiredAtHelpersTest.php | tests/Unit/Traits/Inverse/HasExpiredAtHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithExpiredAt;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Date;
final class HasExpiredAtHelpersTest extends TestCase
{
/** @test */
public function it_casts_expired_at_to_datetime(): void
{
$entity = EntityWithExpiredAt::factory()->create([
'expired_at' => '1986-03-28 00:00:00',
]);
$this->assertInstanceOf(Carbon::class, $entity->expired_at);
$this->assertSame('1986-03-28 00:00:00', $entity->expired_at->format('Y-m-d H:i:s'));
}
/** @test */
public function it_can_check_if_entity_is_expired(): void
{
$expiredEntity = EntityWithExpiredAt::factory()->create([
'expired_at' => Date::now(),
]);
$unexpiredEntity = EntityWithExpiredAt::factory()->create([
'expired_at' => null,
]);
$this->assertTrue($expiredEntity->isExpired());
$this->assertFalse($unexpiredEntity->isExpired());
}
/** @test */
public function it_can_check_if_entity_is_not_expired(): void
{
$expiredEntity = EntityWithExpiredAt::factory()->create([
'expired_at' => Date::now(),
]);
$unexpiredEntity = EntityWithExpiredAt::factory()->create([
'expired_at' => null,
]);
$this->assertFalse($expiredEntity->isNotExpired());
$this->assertTrue($unexpiredEntity->isNotExpired());
}
/** @test */
public function it_can_expire(): void
{
$entity = EntityWithExpiredAt::factory()->create([
'expired_at' => null,
]);
$entity->expire();
$this->assertNotNull($entity->expired_at);
}
/** @test */
public function it_can_undo_expire(): void
{
$entity = EntityWithExpiredAt::factory()->create([
'expired_at' => Date::now(),
]);
$entity->undoExpire();
$this->assertNull($entity->expired_at);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Inverse/HasArchivedFlagHelpersTest.php | tests/Unit/Traits/Inverse/HasArchivedFlagHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithArchivedFlag;
use Cog\Tests\Laravel\Flag\TestCase;
final class HasArchivedFlagHelpersTest extends TestCase
{
/** @test */
public function it_casts_is_archived_to_boolean(): void
{
$entity = EntityWithArchivedFlag::factory()->create([
'is_archived' => 1,
]);
$this->assertTrue($entity->is_archived);
}
/** @test */
public function it_not_casts_is_archived_to_boolean(): void
{
$entity = EntityWithArchivedFlag::factory()->make([
'is_archived' => null,
]);
$this->assertNull($entity->is_archived);
}
/** @test */
public function it_can_check_if_entity_is_archived(): void
{
$archivedEntity = EntityWithArchivedFlag::factory()->create([
'is_archived' => true,
]);
$unarchivedEntity = EntityWithArchivedFlag::factory()->create([
'is_archived' => false,
]);
$this->assertTrue($archivedEntity->isArchived());
$this->assertFalse($unarchivedEntity->isArchived());
}
/** @test */
public function it_can_check_if_entity_is_not_archived(): void
{
$archivedEntity = EntityWithArchivedFlag::factory()->create([
'is_archived' => true,
]);
$unarchivedEntity = EntityWithArchivedFlag::factory()->create([
'is_archived' => false,
]);
$this->assertFalse($archivedEntity->isNotArchived());
$this->assertTrue($unarchivedEntity->isNotArchived());
}
/** @test */
public function it_can_archive(): void
{
$entity = EntityWithArchivedFlag::factory()->create([
'is_archived' => false,
]);
$entity->archive();
$this->assertTrue($entity->is_archived);
}
/** @test */
public function it_can_undo_archive(): void
{
$entity = EntityWithArchivedFlag::factory()->create([
'is_archived' => true,
]);
$entity->undoArchive();
$this->assertFalse($entity->is_archived);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Inverse/HasEndedFlagHelpersTest.php | tests/Unit/Traits/Inverse/HasEndedFlagHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithEndedFlag;
use Cog\Tests\Laravel\Flag\TestCase;
final class HasEndedFlagHelpersTest extends TestCase
{
/** @test */
public function it_casts_is_ended_to_boolean(): void
{
$entity = EntityWithEndedFlag::factory()->create([
'is_ended' => 1,
]);
$this->assertTrue($entity->is_ended);
}
/** @test */
public function it_not_casts_is_ended_to_boolean(): void
{
$entity = EntityWithEndedFlag::factory()->make([
'is_ended' => null,
]);
$this->assertNull($entity->is_ended);
}
/** @test */
public function it_can_check_if_entity_is_ended(): void
{
$endedEntity = EntityWithEndedFlag::factory()->create([
'is_ended' => true,
]);
$unendedEntity = EntityWithEndedFlag::factory()->create([
'is_ended' => false,
]);
$this->assertTrue($endedEntity->isEnded());
$this->assertFalse($unendedEntity->isEnded());
}
/** @test */
public function it_can_check_if_entity_is_not_ended(): void
{
$endedEntity = EntityWithEndedFlag::factory()->create([
'is_ended' => true,
]);
$unendedEntity = EntityWithEndedFlag::factory()->create([
'is_ended' => false,
]);
$this->assertFalse($endedEntity->isNotEnded());
$this->assertTrue($unendedEntity->isNotEnded());
}
/** @test */
public function it_can_end(): void
{
$entity = EntityWithEndedFlag::factory()->create([
'is_ended' => false,
]);
$entity->end();
$this->assertTrue($entity->is_ended);
}
/** @test */
public function it_can_undo_end(): void
{
$entity = EntityWithEndedFlag::factory()->create([
'is_ended' => true,
]);
$entity->undoEnd();
$this->assertFalse($entity->is_ended);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Inverse/HasDraftedAtHelpersTest.php | tests/Unit/Traits/Inverse/HasDraftedAtHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithDraftedAt;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Date;
final class HasDraftedAtHelpersTest extends TestCase
{
/** @test */
public function it_casts_drafted_at_to_datetime(): void
{
$entity = EntityWithDraftedAt::factory()->create([
'drafted_at' => '1986-03-28 00:00:00',
]);
$this->assertInstanceOf(Carbon::class, $entity->drafted_at);
$this->assertSame('1986-03-28 00:00:00', $entity->drafted_at->format('Y-m-d H:i:s'));
}
/** @test */
public function it_can_check_if_entity_is_drafted(): void
{
$draftedEntity = EntityWithDraftedAt::factory()->create([
'drafted_at' => Date::now(),
]);
$undraftedEntity = EntityWithDraftedAt::factory()->create([
'drafted_at' => null,
]);
$this->assertTrue($draftedEntity->isDrafted());
$this->assertFalse($undraftedEntity->isDrafted());
}
/** @test */
public function it_can_check_if_entity_is_not_drafted(): void
{
$draftedEntity = EntityWithDraftedAt::factory()->create([
'drafted_at' => Date::now(),
]);
$undraftedEntity = EntityWithDraftedAt::factory()->create([
'drafted_at' => null,
]);
$this->assertFalse($draftedEntity->isNotDrafted());
$this->assertTrue($undraftedEntity->isNotDrafted());
}
/** @test */
public function it_can_draft(): void
{
$entity = EntityWithDraftedAt::factory()->create([
'drafted_at' => null,
]);
$entity->draft();
$this->assertNotNull($entity->drafted_at);
}
/** @test */
public function it_can_undo_draft(): void
{
$entity = EntityWithDraftedAt::factory()->create([
'drafted_at' => Date::now(),
]);
$entity->undoDraft();
$this->assertNull($entity->drafted_at);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Inverse/HasEndedAtHelpersTest.php | tests/Unit/Traits/Inverse/HasEndedAtHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithEndedAt;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Date;
final class HasEndedAtHelpersTest extends TestCase
{
/** @test */
public function it_casts_ended_at_to_datetime(): void
{
$entity = EntityWithEndedAt::factory()->create([
'ended_at' => '1986-03-28 00:00:00',
]);
$this->assertInstanceOf(Carbon::class, $entity->ended_at);
$this->assertSame('1986-03-28 00:00:00', $entity->ended_at->format('Y-m-d H:i:s'));
}
/** @test */
public function it_can_check_if_entity_is_ended(): void
{
$endedEntity = EntityWithEndedAt::factory()->create([
'ended_at' => Date::now(),
]);
$unendedEntity = EntityWithEndedAt::factory()->create([
'ended_at' => null,
]);
$this->assertTrue($endedEntity->isEnded());
$this->assertFalse($unendedEntity->isEnded());
}
/** @test */
public function it_can_check_if_entity_is_not_ended(): void
{
$endedEntity = EntityWithEndedAt::factory()->create([
'ended_at' => Date::now(),
]);
$unendedEntity = EntityWithEndedAt::factory()->create([
'ended_at' => null,
]);
$this->assertFalse($endedEntity->isNotEnded());
$this->assertTrue($unendedEntity->isNotEnded());
}
/** @test */
public function it_can_end(): void
{
$entity = EntityWithEndedAt::factory()->create([
'ended_at' => null,
]);
$entity->end();
$this->assertNotNull($entity->ended_at);
}
/** @test */
public function it_can_undo_end(): void
{
$entity = EntityWithEndedAt::factory()->create([
'ended_at' => Date::now(),
]);
$entity->undoEnd();
$this->assertNull($entity->ended_at);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Inverse/HasDraftedFlagHelpersTest.php | tests/Unit/Traits/Inverse/HasDraftedFlagHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithDraftedFlag;
use Cog\Tests\Laravel\Flag\TestCase;
final class HasDraftedFlagHelpersTest extends TestCase
{
/** @test */
public function it_casts_is_drafted_to_boolean(): void
{
$entity = EntityWithDraftedFlag::factory()->create([
'is_drafted' => 1,
]);
$this->assertTrue($entity->is_drafted);
}
/** @test */
public function it_not_casts_is_drafted_to_boolean(): void
{
$entity = EntityWithDraftedFlag::factory()->make([
'is_drafted' => null,
]);
$this->assertNull($entity->is_drafted);
}
/** @test */
public function it_can_check_if_entity_is_drafted(): void
{
$draftedEntity = EntityWithDraftedFlag::factory()->create([
'is_drafted' => true,
]);
$undraftedEntity = EntityWithDraftedFlag::factory()->create([
'is_drafted' => false,
]);
$this->assertTrue($draftedEntity->isDrafted());
$this->assertFalse($undraftedEntity->isDrafted());
}
/** @test */
public function it_can_check_if_entity_is_not_drafted(): void
{
$draftedEntity = EntityWithDraftedFlag::factory()->create([
'is_drafted' => true,
]);
$undraftedEntity = EntityWithDraftedFlag::factory()->create([
'is_drafted' => false,
]);
$this->assertFalse($draftedEntity->isNotDrafted());
$this->assertTrue($undraftedEntity->isNotDrafted());
}
/** @test */
public function it_can_draft(): void
{
$entity = EntityWithDraftedFlag::factory()->create([
'is_drafted' => false,
]);
$entity->draft();
$this->assertTrue($entity->is_drafted);
}
/** @test */
public function it_can_undo_draft(): void
{
$entity = EntityWithDraftedFlag::factory()->create([
'is_drafted' => true,
]);
$entity->undoDraft();
$this->assertFalse($entity->is_drafted);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Inverse/HasArchivedAtHelpersTest.php | tests/Unit/Traits/Inverse/HasArchivedAtHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithArchivedAt;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Date;
final class HasArchivedAtHelpersTest extends TestCase
{
/** @test */
public function it_casts_archived_at_to_datetime(): void
{
$entity = EntityWithArchivedAt::factory()->create([
'archived_at' => '1986-03-28 00:00:00',
]);
$this->assertInstanceOf(Carbon::class, $entity->archived_at);
$this->assertSame('1986-03-28 00:00:00', $entity->archived_at->format('Y-m-d H:i:s'));
}
/** @test */
public function it_can_check_if_entity_is_archived(): void
{
$archivedEntity = EntityWithArchivedAt::factory()->create([
'archived_at' => Date::now(),
]);
$unarchivedEntity = EntityWithArchivedAt::factory()->create([
'archived_at' => null,
]);
$this->assertTrue($archivedEntity->isArchived());
$this->assertFalse($unarchivedEntity->isArchived());
}
/** @test */
public function it_can_check_if_entity_is_not_archived(): void
{
$archivedEntity = EntityWithArchivedAt::factory()->create([
'archived_at' => Date::now(),
]);
$unarchivedEntity = EntityWithArchivedAt::factory()->create([
'archived_at' => null,
]);
$this->assertFalse($archivedEntity->isNotArchived());
$this->assertTrue($unarchivedEntity->isNotArchived());
}
/** @test */
public function it_can_archive(): void
{
$entity = EntityWithArchivedAt::factory()->create([
'archived_at' => null,
]);
$entity->archive();
$this->assertNotNull($entity->archived_at);
}
/** @test */
public function it_can_undo_archive(): void
{
$entity = EntityWithArchivedAt::factory()->create([
'archived_at' => Date::now(),
]);
$entity->undoArchive();
$this->assertNull($entity->archived_at);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Inverse/HasClosedFlagHelpersTest.php | tests/Unit/Traits/Inverse/HasClosedFlagHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithClosedFlag;
use Cog\Tests\Laravel\Flag\TestCase;
final class HasClosedFlagHelpersTest extends TestCase
{
/** @test */
public function it_casts_is_closed_to_boolean(): void
{
$entity = EntityWithClosedFlag::factory()->create([
'is_closed' => 1,
]);
$this->assertTrue($entity->is_closed);
}
/** @test */
public function it_not_casts_is_closed_to_boolean(): void
{
$entity = EntityWithClosedFlag::factory()->make([
'is_closed' => null,
]);
$this->assertNull($entity->is_closed);
}
/** @test */
public function it_can_check_if_entity_is_closed(): void
{
$closedEntity = EntityWithClosedFlag::factory()->create([
'is_closed' => true,
]);
$openedEntity = EntityWithClosedFlag::factory()->create([
'is_closed' => false,
]);
$this->assertTrue($closedEntity->isClosed());
$this->assertFalse($openedEntity->isClosed());
}
/** @test */
public function it_can_check_if_entity_is_not_closed(): void
{
$closedEntity = EntityWithClosedFlag::factory()->create([
'is_closed' => true,
]);
$openedEntity = EntityWithClosedFlag::factory()->create([
'is_closed' => false,
]);
$this->assertFalse($closedEntity->isNotClosed());
$this->assertTrue($openedEntity->isNotClosed());
}
/** @test */
public function it_can_close(): void
{
$entity = EntityWithClosedFlag::factory()->create([
'is_closed' => false,
]);
$entity->close();
$this->assertTrue($entity->is_closed);
}
/** @test */
public function it_can_undo_close(): void
{
$entity = EntityWithClosedFlag::factory()->create([
'is_closed' => true,
]);
$entity->undoClose();
$this->assertFalse($entity->is_closed);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Inverse/HasClosedAtHelpersTest.php | tests/Unit/Traits/Inverse/HasClosedAtHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithClosedAt;
use Cog\Tests\Laravel\Flag\TestCase;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Date;
final class HasClosedAtHelpersTest extends TestCase
{
/** @test */
public function it_casts_closed_at_to_datetime(): void
{
$entity = EntityWithClosedAt::factory()->create([
'closed_at' => '1986-03-28 00:00:00',
]);
$this->assertInstanceOf(Carbon::class, $entity->closed_at);
$this->assertSame('1986-03-28 00:00:00', $entity->closed_at->format('Y-m-d H:i:s'));
}
/** @test */
public function it_can_check_if_entity_is_closed(): void
{
$closedEntity = EntityWithClosedAt::factory()->create([
'closed_at' => Date::now(),
]);
$openedEntity = EntityWithClosedAt::factory()->create([
'closed_at' => null,
]);
$this->assertTrue($closedEntity->isClosed());
$this->assertFalse($openedEntity->isClosed());
}
/** @test */
public function it_can_check_if_entity_is_not_closed(): void
{
$closedEntity = EntityWithClosedAt::factory()->create([
'closed_at' => Date::now(),
]);
$openedEntity = EntityWithClosedAt::factory()->create([
'closed_at' => null,
]);
$this->assertFalse($closedEntity->isNotClosed());
$this->assertTrue($openedEntity->isNotClosed());
}
/** @test */
public function it_can_close(): void
{
$entity = EntityWithClosedAt::factory()->create([
'closed_at' => null,
]);
$entity->close();
$this->assertNotNull($entity->closed_at);
}
/** @test */
public function it_can_undo_close(): void
{
$entity = EntityWithClosedAt::factory()->create([
'closed_at' => Date::now(),
]);
$entity->undoClose();
$this->assertNull($entity->closed_at);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/Unit/Traits/Inverse/HasExpiredFlagHelpersTest.php | tests/Unit/Traits/Inverse/HasExpiredFlagHelpersTest.php | <?php
/*
* This file is part of Laravel Eloquent Flag.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Unit\Traits\Inverse;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithExpiredFlag;
use Cog\Tests\Laravel\Flag\TestCase;
final class HasExpiredFlagHelpersTest extends TestCase
{
/** @test */
public function it_casts_is_expired_to_boolean(): void
{
$entity = EntityWithExpiredFlag::factory()->create([
'is_expired' => 1,
]);
$this->assertTrue($entity->is_expired);
}
/** @test */
public function it_not_casts_is_expired_to_boolean(): void
{
$entity = EntityWithExpiredFlag::factory()->make([
'is_expired' => null,
]);
$this->assertNull($entity->is_expired);
}
/** @test */
public function it_can_check_if_entity_is_expired(): void
{
$expiredEntity = EntityWithExpiredFlag::factory()->create([
'is_expired' => true,
]);
$unexpiredEntity = EntityWithExpiredFlag::factory()->create([
'is_expired' => false,
]);
$this->assertTrue($expiredEntity->isExpired());
$this->assertFalse($unexpiredEntity->isExpired());
}
/** @test */
public function it_can_check_if_entity_is_not_expired(): void
{
$expiredEntity = EntityWithExpiredFlag::factory()->create([
'is_expired' => true,
]);
$unexpiredEntity = EntityWithExpiredFlag::factory()->create([
'is_expired' => false,
]);
$this->assertFalse($expiredEntity->isNotExpired());
$this->assertTrue($unexpiredEntity->isNotExpired());
}
/** @test */
public function it_can_expire(): void
{
$entity = EntityWithExpiredFlag::factory()->create([
'is_expired' => false,
]);
$entity->expire();
$this->assertTrue($entity->is_expired);
}
/** @test */
public function it_can_undo_expire(): void
{
$entity = EntityWithExpiredFlag::factory()->create([
'is_expired' => true,
]);
$entity->undoExpire();
$this->assertFalse($entity->is_expired);
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/database/factories/EntityWithVerifiedFlagFactory.php | tests/database/factories/EntityWithVerifiedFlagFactory.php | <?php
/*
* This file is part of Laravel Ban.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Database\Factories;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithVerifiedFlag;
use Illuminate\Database\Eloquent\Factories\Factory;
final class EntityWithVerifiedFlagFactory extends Factory
{
protected $model = EntityWithVerifiedFlag::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => $this->faker->word(),
'is_verified' => null,
];
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/database/factories/EntityWithPublishedFlagFactory.php | tests/database/factories/EntityWithPublishedFlagFactory.php | <?php
/*
* This file is part of Laravel Ban.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Database\Factories;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithPublishedFlag;
use Illuminate\Database\Eloquent\Factories\Factory;
final class EntityWithPublishedFlagFactory extends Factory
{
protected $model = EntityWithPublishedFlag::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => $this->faker->word(),
'is_published' => null,
];
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/database/factories/EntityWithKeptFlagFactory.php | tests/database/factories/EntityWithKeptFlagFactory.php | <?php
/*
* This file is part of Laravel Ban.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Database\Factories;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithKeptFlag;
use Illuminate\Database\Eloquent\Factories\Factory;
final class EntityWithKeptFlagFactory extends Factory
{
protected $model = EntityWithKeptFlag::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => $this->faker->word(),
'is_kept' => null,
];
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/database/factories/EntityWithExpiredAtFactory.php | tests/database/factories/EntityWithExpiredAtFactory.php | <?php
/*
* This file is part of Laravel Ban.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Database\Factories;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithExpiredAt;
use Illuminate\Database\Eloquent\Factories\Factory;
final class EntityWithExpiredAtFactory extends Factory
{
protected $model = EntityWithExpiredAt::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => $this->faker->word(),
'expired_at' => null,
];
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/database/factories/EntityWithClosedAtFactory.php | tests/database/factories/EntityWithClosedAtFactory.php | <?php
/*
* This file is part of Laravel Ban.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Database\Factories;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithClosedAt;
use Illuminate\Database\Eloquent\Factories\Factory;
final class EntityWithClosedAtFactory extends Factory
{
protected $model = EntityWithClosedAt::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => $this->faker->word(),
'closed_at' => null,
];
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/database/factories/EntityWithActiveFlagFactory.php | tests/database/factories/EntityWithActiveFlagFactory.php | <?php
/*
* This file is part of Laravel Ban.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Database\Factories;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithActiveFlag;
use Illuminate\Database\Eloquent\Factories\Factory;
final class EntityWithActiveFlagFactory extends Factory
{
protected $model = EntityWithActiveFlag::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => $this->faker->word(),
'is_active' => false,
];
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/database/factories/EntityWithApprovedFlagFactory.php | tests/database/factories/EntityWithApprovedFlagFactory.php | <?php
/*
* This file is part of Laravel Ban.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Database\Factories;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithApprovedFlag;
use Illuminate\Database\Eloquent\Factories\Factory;
final class EntityWithApprovedFlagFactory extends Factory
{
protected $model = EntityWithApprovedFlag::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => $this->faker->word(),
'is_approved' => null,
];
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/database/factories/EntityWithAcceptedAtFactory.php | tests/database/factories/EntityWithAcceptedAtFactory.php | <?php
/*
* This file is part of Laravel Ban.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Database\Factories;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithAcceptedAt;
use Illuminate\Database\Eloquent\Factories\Factory;
final class EntityWithAcceptedAtFactory extends Factory
{
protected $model = EntityWithAcceptedAt::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => $this->faker->word(),
'accepted_at' => null,
];
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/database/factories/EntityWithInvitedFlagFactory.php | tests/database/factories/EntityWithInvitedFlagFactory.php | <?php
/*
* This file is part of Laravel Ban.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Database\Factories;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithInvitedFlag;
use Illuminate\Database\Eloquent\Factories\Factory;
final class EntityWithInvitedFlagFactory extends Factory
{
protected $model = EntityWithInvitedFlag::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => $this->faker->word(),
'is_invited' => null,
];
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/database/factories/EntityWithPublishedAtFactory.php | tests/database/factories/EntityWithPublishedAtFactory.php | <?php
/*
* This file is part of Laravel Ban.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Database\Factories;
use Cog\Tests\Laravel\Flag\Stubs\Models\Classic\EntityWithPublishedAt;
use Illuminate\Database\Eloquent\Factories\Factory;
final class EntityWithPublishedAtFactory extends Factory
{
protected $model = EntityWithPublishedAt::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => $this->faker->word(),
'published_at' => null,
];
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
cybercog/laravel-eloquent-flag | https://github.com/cybercog/laravel-eloquent-flag/blob/b78de1f45726511b73723b7f017a4a7f833c2546/tests/database/factories/EntityWithArchivedFlagFactory.php | tests/database/factories/EntityWithArchivedFlagFactory.php | <?php
/*
* This file is part of Laravel Ban.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cog\Tests\Laravel\Flag\Database\Factories;
use Cog\Tests\Laravel\Flag\Stubs\Models\Inverse\EntityWithArchivedFlag;
use Illuminate\Database\Eloquent\Factories\Factory;
final class EntityWithArchivedFlagFactory extends Factory
{
protected $model = EntityWithArchivedFlag::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => $this->faker->word(),
'is_archived' => null,
];
}
}
| php | MIT | b78de1f45726511b73723b7f017a4a7f833c2546 | 2026-01-05T05:04:43.856771Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.