volnistii11
Пытаюсь реализовать заглушку метода ReadOffices внутри метода SearchOffices, но у меня не выходит, в консоле пишет :
Код (Text):
1) TestStub::testSearch Failed asserting that null is identical to Array &0 ( ‘offices’ => Array &1 ( 0 => Array &2 ( ‘id’ => 3 ‘address’ => ‘Moscow 21 Snezhnaya Street’ ‘workingHours’ => ‘8:00-20:00’ ‘rentalPrice($)’ => 4300 ) ) ).Что я делаю не так? index.php
PHP:
<?php class Offices { public function ReadOffices() { } public function SearchOffices() { $jsonOffices = $this->ReadOffices(); return $jsonOffices; } }test.class.php
PHP:
<?php require ‘index.php’; class TestStub extends PHPUnitFrameworkTestCase { public function testSearch() { //Создаем заглушку $stub = $this->createMock(Offices::class); //Настраиваем заглушку ReadOffices $stub->method(‘ReadOffices’) ->willReturn([ ‘offices’ => [ 0 => [ ‘id’ => 3, ‘address’ => ‘Moscow 21 Snezhnaya Street’, ‘workingHours’ => ‘8:00-20:00’, ‘rentalPrice($)’ => 4300 ] ] ]); //Тестируем метод SearchOffices $this->assertSame([ ‘offices’ => [ 0 => [ ‘id’ => 3, ‘address’ => ‘Moscow 21 Snezhnaya Street’, ‘workingHours’ => ‘8:00-20:00’, ‘rentalPrice($)’ => 4300 ] ] ],$stub->SearchOffices()); } }