makeIni()); $definition = $ini->playlist($code); $pls = new Playlist($code, $definition); $this->assertSame($code, $pls->code); $this->assertSame($definition['name'], $pls->name); $this->assertSame($definition['desc'], $pls->desc); $this->assertSame($definition['url'], $pls->url); $this->assertSame($definition['src'], $pls->src); } /** * Проверяет успешное создание объекта при отсутствии значений опциональных параметров * * @return void * @throws FileReadException * @throws IniParsingException * @throws PlaylistNotFoundException */ public function testOptionalParams(): void { $code = 'foo'; $ini = new IniFile($this->makeIni()); $definition = $ini->playlist($code); unset($definition['name']); unset($definition['desc']); unset($definition['src']); $pls = new Playlist($code, $definition); $this->assertSame($code, $pls->code); $this->assertNull($pls->name); $this->assertNull($pls->desc); $this->assertSame($definition['url'], $pls->url); $this->assertNull($pls->src); } /** * Проверяет исключение при попытке чтения ini-файла по некорректнмоу пути * * @return void * @throws FileReadException * @throws IniParsingException * @throws PlaylistNotFoundException */ public function testPlaylistWithoutUrlException(): void { $code = 'foo'; $this->expectException(PlaylistWithoutUrlException::class); $this->expectExceptionMessage("Плейлист '{$code}' имеет неверный url"); $ini = new IniFile($this->makeIni()); $definition = $ini->playlist($code); unset($definition['url']); new Playlist($code, $definition); } public function testGetCheckResult(): void { $code = 'foo'; $ini = new IniFile($this->makeIni()); $definition = $ini->playlist($code); $pls = new Playlist($code, $definition); $redis = $this->createPartialMock(Redis::class, ['get']); $redis->expects($this->once())->method('get')->with($code)->willReturn(null); $pls->getCheckResult(); } }