Вот упрощенная версия моей настройки:
Код: Выделить всё
public function testExample()
{
$model = Mockery::mock(Model::class)->shouldIgnoreMissing();
// Mocking a property
$model->shouldReceive('getAttribute')
->with('title')
->andReturn('Test Page');
$model->title = 'Test Page'; // I also tried this
$result = $this->doSomething($model);
$this->assertEquals('/test-page', $result);
}
public function doSomething($model): string
{
print_r([$model->title, $model->title ?? 'default']);
...
...
}
Код: Выделить всё
Array
(
[0] => Test Page
[1] => default
}
Есть ли способ сделать нулевой оператор объединения ( ??) надежно работают с макетами Mockery в PHP?
Обратите внимание, что я использую PHP 8.2, phpUnit 10.5 с Laravel 11.33.2
Подробнее здесь: https://stackoverflow.com/questions/793 ... g-operator
Мобильная версия