/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Foundation/FoundationCacheBasedMaintenanceModeTest.php
59 строк
2 KB
Jason McCreary
[13.x] Mockery cleanup (#61117)
10 авг 2026, 20:23
Не верифицирован
10 авг 2026, 20:23
2ee40ee
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Foundation; use Illuminate\Contracts\Cache\Factory; use Illuminate\Contracts\Cache\Repository; use Illuminate\Foundation\CacheBasedMaintenanceMode; use Mockery; use PHPUnit\Framework\TestCase; class FoundationCacheBasedMaintenanceModeTest extends TestCase { public function test_it_determines_whether_maintenance_mode_is_active() { $cache = Mockery::mock(Factory::class, Repository::class); $cache->expects('store')->times(2)->with('store-key')->andReturnSelf(); $manager = new CacheBasedMaintenanceMode($cache, 'store-key', 'key'); $cache->expects('has')->with('key')->andReturnFalse(); $this->assertFalse($manager->active()); $cache->expects('has')->with('key')->andReturnTrue(); $this->assertTrue($manager->active()); } public function test_it_retrieves_payload_from_cache() { $cache = Mockery::mock(Factory::class, Repository::class); $cache->expects('store')->with('store-key')->andReturnSelf(); $manager = new CacheBasedMaintenanceMode($cache, 'store-key', 'key'); $cache->expects('get')->with('key')->andReturn(['payload']); $this->assertSame(['payload'], $manager->data()); } public function test_it_stores_payload_in_cache() { $cache = Mockery::spy(Factory::class, Repository::class); $cache->expects('store')->with('store-key')->andReturnSelf(); $manager = new CacheBasedMaintenanceMode($cache, 'store-key', 'key'); $manager->activate(['payload']); $cache->shouldHaveReceived('put')->once()->with('key', ['payload']); } public function test_it_removes_payload_from_cache() { $cache = Mockery::spy(Factory::class, Repository::class); $cache->expects('store')->with('store-key')->andReturnSelf(); $manager = new CacheBasedMaintenanceMode($cache, 'store-key', 'key'); $manager->deactivate(); $cache->shouldHaveReceived('forget')->once()->with('key'); } }