Updated how we parse guid.yaml file

This commit is contained in:
Abdulmhsen B. A. A.
2024-10-06 17:30:21 +03:00
parent db6f3edfe5
commit db486f8c1e
7 changed files with 119 additions and 99 deletions

43
FAQ.md
View File

@@ -960,7 +960,8 @@ version: 0.0
# The key must be in lower case. and it's an array.
guids:
- type: string # must be exactly string do not change it.
- id: universally-unique-identifier # the guid id
type: string # must be exactly string do not change it.
name: guid_mydb # the name must start with guid_ with no spaces and lower case.
description: "My custom database guid" # description of the guid.
# Validator object. to validate the guid.
@@ -974,37 +975,41 @@ guids:
- "1234567a" # invalid guid examples.
- "a111234567" # invalid guid examples.
# Extend Plex client to support the new guid.
plex:
- legacy: true # Tag the mapper as legacy GUID for mapping.
links:
# mapping the com.plexapp.agents.foo guid from plex backends into the guid_mydb in WatchState.
# plex legacy guids starts with com.plexapp.agents., you must set options.legacy to true.
- id: universally-unique-identifier # the link id
type: plex # the client to link the guid to. plex, jellyfin, emby.
options: # options used by the client.
legacy: true # Tag the mapper as legacy GUID for mapping.
# Required map object. to map the new guid to WatchState guid.
map:
from: com.plexapp.agents.foo # map.from this string.
to: guid_mydb # map.to this guid.
# (Optional) Replace helper. Sometimes you need to replace the guid identifier to another.
# The replacement happens before the mapping, so if you replace the guid identifier, you should also
# update the map.from to match the new identifier.
replace:
from: com.plexapp.agents.foobar:// # Replace from this string
to: com.plexapp.agents.foo:// # Into this string.
# (Optional) Replace helper. Sometimes you need to replace the guid identifier to another.
# The replacement happens before the mapping, so if you replace the guid identifier, you should also
# update the map.from to match the new identifier.
replace:
from: com.plexapp.agents.foobar:// # Replace from this string
to: com.plexapp.agents.foo:// # Into this string.
# Extend Jellyfin client to support the new guid.
jellyfin:
# Required map object. to map the new guid to WatchState guid.
- map:
# mapping the foo guid from jellyfin backends into the guid_mydb in WatchState.
- id: universally-unique-identifier # the link id
type: jellyfin # the client to link the guid to. plex, jellyfin, emby.
map:
from: foo # map.from this string.
to: guid_mydb # map.to this guid.
# Extend Emby client to support the new guid.
emby:
# Required map object. to map the new guid to WatchState guid.
- map:
# mapping the foo guid from emby backends into the guid_mydb in WatchState.
- id: universally-unique-identifier # the link id
type: emby # the client to link the guid to. plex, jellyfin, emby.
map:
from: foo # map.from this string.
to: guid_mydb # map.to this guid.
```
As you can see from the config, it's roughly how we expected it to be. The `guids` array is where you define your new
guids. The `plex`, `jellyfin` and `emby` objects are where you map the new guid to the WatchState guid.
guids. the `links` array is where you map from backends guids to the new guid into the WatchState guid.
Everything in this file should be in lower case. If error occurs, the tool will log a warning and ignore the guid,
By default, we only show `ERROR` levels in log file, You can lower it by setting `WS_LOGGER_FILE_LEVEL` environment variable

View File

@@ -6,6 +6,7 @@ namespace App\Backends\Jellyfin;
use App\Backends\Common\Context;
use App\Backends\Common\GuidInterface as iGuid;
use App\Backends\Emby\EmbyClient;
use App\Libs\Config;
use App\Libs\Exceptions\Backends\InvalidArgumentException;
use App\Libs\Guid;
@@ -38,7 +39,9 @@ class JellyfinGuid implements iGuid
*/
public function __construct(protected LoggerInterface $logger)
{
$this->type = str_contains(static::class, 'EmbyGuid') ? 'emby' : 'jellyfin';
$this->type = strtolower(
str_contains(static::class, 'EmbyGuid') ? EmbyClient::CLIENT_NAME : JellyfinClient::CLIENT_NAME
);
$file = Config::get('guid.file', null);
@@ -108,10 +111,10 @@ class JellyfinGuid implements iGuid
]));
}
$mapping = ag($yaml, $this->type, []);
$mapping = ag($yaml, 'links', []);
if (false === is_array($mapping)) {
throw new InvalidArgumentException(r("The GUIDs file '{file}' {type} sub key is not an array.", [
throw new InvalidArgumentException(r("The GUIDs file '{file}' links sub key is not an array.", [
'type' => $this->type,
'file' => $file,
]));
@@ -121,9 +124,10 @@ class JellyfinGuid implements iGuid
return;
}
foreach ($mapping as $key => $map) {
if (false === is_array($map)) {
$this->logger->warning("Ignoring '{type}.{key}'. Value must be an object. '{given}' is given.", [
$this->logger->warning("Ignoring 'links.{key}'. Value must be an object. '{given}' is given.", [
'key' => $key,
'type' => $this->type,
'given' => get_debug_type($map),
@@ -131,10 +135,14 @@ class JellyfinGuid implements iGuid
continue;
}
if ($this->type !== ag($map, 'type', 'not_set')) {
continue;
}
$mapper = ag($map, 'map', null);
if (false === is_array($mapper)) {
$this->logger->warning("Ignoring '{type}.{key}'. map value must be an object. '{given}' is given.", [
$this->logger->warning("Ignoring 'links.{key}'. map value must be an object. '{given}' is given.", [
'key' => $key,
'type' => $this->type,
'given' => get_debug_type($mapper),
@@ -146,7 +154,7 @@ class JellyfinGuid implements iGuid
$to = ag($mapper, 'to', null);
if (empty($from) || false === is_string($from)) {
$this->logger->warning("Ignoring '{type}.{key}'. map.from field is empty or not a string.", [
$this->logger->warning("Ignoring 'links.{key}'. map.from field is empty or not a string.", [
'type' => $this->type,
'key' => $key,
]);
@@ -154,7 +162,7 @@ class JellyfinGuid implements iGuid
}
if (empty($to) || false === is_string($to)) {
$this->logger->warning("Ignoring '{type}.{key}'. map.to field is empty or not a string.", [
$this->logger->warning("Ignoring 'links.{key}'. map.to field is empty or not a string.", [
'type' => $this->type,
'key' => $key,
]);
@@ -162,7 +170,7 @@ class JellyfinGuid implements iGuid
}
if (false === Guid::validateGUIDName($to)) {
$this->logger->warning("Ignoring '{type}.{key}'. map.to '{to}' field does not starts with 'guid_'.", [
$this->logger->warning("Ignoring 'links.{key}'. map.to '{to}' field does not starts with 'guid_'.", [
'type' => $this->type,
'key' => $key,
'to' => $to,
@@ -171,7 +179,7 @@ class JellyfinGuid implements iGuid
}
if (false === in_array($to, $supported)) {
$this->logger->warning("Ignoring '{type}.{key}'. map.to field is not a supported GUID type.", [
$this->logger->warning("Ignoring 'links.{key}'. map.to field is not a supported GUID type.", [
'type' => $this->type,
'key' => $key,
'to' => $to,

View File

@@ -147,10 +147,10 @@ final class PlexGuid implements iGuid
]));
}
$mapping = ag($yaml, 'plex', []);
$mapping = ag($yaml, 'links', []);
if (false === is_array($mapping)) {
throw new InvalidArgumentException(r("The GUIDs file '{file}' plex sub key is not an array.", [
throw new InvalidArgumentException(r("The GUIDs file '{file}' links sub key is not an array.", [
'file' => $file,
]));
}
@@ -159,19 +159,25 @@ final class PlexGuid implements iGuid
return;
}
$type = strtolower(PlexClient::CLIENT_NAME);
foreach ($mapping as $key => $map) {
if (false === is_array($map)) {
$this->logger->warning("Ignoring 'plex.{key}'. Value must be an object. '{given}' is given.", [
$this->logger->warning("Ignoring 'links.{key}'. Value must be an object. '{given}' is given.", [
'key' => $key,
'given' => get_debug_type($map),
]);
continue;
}
if ($type !== ag($map, 'type', 'not_set')) {
continue;
}
if (null !== ($replace = ag($map, 'replace', null))) {
if (false === is_array($replace)) {
$this->logger->warning(
"Ignoring 'plex.{key}'. replace value must be an object. '{given}' is given.",
"Ignoring 'links.{key}'. replace value must be an object. '{given}' is given.",
[
'key' => $key,
'given' => get_debug_type($replace),
@@ -184,14 +190,14 @@ final class PlexGuid implements iGuid
$to = ag($replace, 'to', null);
if (empty($from) || false === is_string($from)) {
$this->logger->warning("Ignoring 'plex.{key}'. replace.from field is empty or not a string.", [
$this->logger->warning("Ignoring 'links.{key}'. replace.from field is empty or not a string.", [
'key' => $key,
]);
continue;
}
if (false === is_string($to)) {
$this->logger->warning("Ignoring 'plex.{key}'. replacer.to field is not a string.", [
$this->logger->warning("Ignoring 'links.{key}'. replacer.to field is not a string.", [
'key' => $key,
]);
continue;
@@ -202,7 +208,7 @@ final class PlexGuid implements iGuid
if (null !== ($mapper = ag($map, 'map', null))) {
if (false === is_array($mapper)) {
$this->logger->warning("Ignoring 'plex.{key}'. map value must be an object. '{given}' is given.", [
$this->logger->warning("Ignoring 'links.{key}'. map value must be an object. '{given}' is given.", [
'key' => $key,
'given' => get_debug_type($mapper),
]);
@@ -213,47 +219,51 @@ final class PlexGuid implements iGuid
$to = ag($mapper, 'to', null);
if (empty($from) || false === is_string($from)) {
$this->logger->warning("Ignoring 'plex.{key}'. map.from field is empty or not a string.", [
$this->logger->warning("Ignoring 'links.{key}'. map.from field is empty or not a string.", [
'key' => $key,
]);
continue;
}
if (empty($to) || false === is_string($to)) {
$this->logger->warning("Ignoring 'plex.{key}'. map.to field is empty or not a string.", [
$this->logger->warning("Ignoring 'links.{key}'. map.to field is empty or not a string.", [
'key' => $key,
]);
continue;
}
if (false === str_starts_with($to, 'guid_')) {
$this->logger->warning("Ignoring 'plex.{key}'. map.to '{to}' field does not starts with 'guid_'.", [
'key' => $key,
'to' => $to,
]);
$this->logger->warning(
"Ignoring 'links.{key}'. map.to '{to}' field does not starts with 'guid_'.",
[
'key' => $key,
'to' => $to,
]
);
continue;
}
if (false === in_array($to, $supported)) {
$this->logger->warning("Ignoring 'plex.{key}'. map.to field is not a supported GUID type.", [
$this->logger->warning("Ignoring 'links.{key}'. map.to field is not a supported GUID type.", [
'key' => $key,
'to' => $to,
]);
continue;
}
if (false === (bool)ag($map, 'legacy', true)) {
if (false === (bool)ag($map, 'options.legacy', true)) {
$this->guidMapper[$from] = $to;
continue;
}
if (true === in_array($from, $this->guidLegacy)) {
$this->logger->warning("Ignoring 'plex.{key}'. map.from already exists.", [
$this->logger->warning("Ignoring 'links.{key}'. map.from already exists.", [
'key' => $key,
'from' => $from,
]);
continue;
}
$this->guidLegacy[] = $from;
$agentGuid = explode('://', after($from, 'agents.'));
$this->guidMapper[$agentGuid[0]] = $to;

View File

@@ -179,12 +179,12 @@ class EmbyGuidTest extends TestCase
try {
$this->checkException(
closure: function () use ($tmpFile) {
file_put_contents($tmpFile, Yaml::dump(['emby' => 'foo']));
file_put_contents($tmpFile, Yaml::dump(['links' => 'foo']));
$this->getClass()->parseGUIDFile($tmpFile);
},
reason: "Should throw an exception when there are no GUIDs mapping.",
exception: InvalidArgumentException::class,
exceptionMessage: 'emby sub key is not an array'
exceptionMessage: 'links sub key is not an array'
);
} finally {
if (file_exists($tmpFile)) {
@@ -201,11 +201,11 @@ class EmbyGuidTest extends TestCase
$this->handler->clear();
file_put_contents($tmpFile, Yaml::dump(ag_set($yaml, 'emby.0', 'ff')));
file_put_contents($tmpFile, Yaml::dump(ag_set($yaml, 'links.0', 'ff')));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
$this->logged(Level::Warning, 'Value must be an object.', true),
'Assert replace key is an object.'
'Assert links.0 key is an object.'
);
} finally {
if (file_exists($tmpFile)) {
@@ -217,15 +217,15 @@ class EmbyGuidTest extends TestCase
$tmpFile = tempnam(sys_get_temp_dir(), 'guid');
try {
$yaml = ag_set(['emby' => []], 'emby.0.map', 'foo');
$yaml = ag_set(['links' => [['type' => 'emby']]], 'links.0.map', 'foo');
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
$this->logged(Level::Warning, 'map value must be an object.', true),
'Assert replace key is an object.'
'Assert map key is an object.'
);
$yaml = ag_set($yaml, 'emby.0', ['map' => []]);
$yaml = ag_set($yaml, 'links.0.map', []);
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
@@ -233,7 +233,7 @@ class EmbyGuidTest extends TestCase
'Assert to field is a string.'
);
$yaml = ag_set($yaml, 'emby.0.map.from', 'foo');
$yaml = ag_set($yaml, 'links.0.map.from', 'foo');
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
@@ -241,7 +241,7 @@ class EmbyGuidTest extends TestCase
'Assert to field is a string.'
);
$yaml = ag_set($yaml, 'emby.0.map.to', 'foobar');
$yaml = ag_set($yaml, 'links.0.map.to', 'foobar');
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
@@ -249,7 +249,7 @@ class EmbyGuidTest extends TestCase
'Assert to field is a string.'
);
$yaml = ag_set($yaml, 'emby.0.map.to', 'guid_foobar');
$yaml = ag_set($yaml, 'links.0.map.to', 'guid_foobar');
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
@@ -257,7 +257,7 @@ class EmbyGuidTest extends TestCase
'Assert to field is a string.'
);
$yaml = ag_set($yaml, 'emby.0.map', [
$yaml = ag_set($yaml, 'links.0.map', [
'from' => 'tsdb',
'to' => Guid::GUID_IMDB,
]);
@@ -274,16 +274,15 @@ class EmbyGuidTest extends TestCase
);
$this->handler->clear();
$yaml = ag_set($yaml, 'emby.0', [
'legacy' => false,
'map' => [
'from' => 'imthedb',
'to' => 'guid_imdb',
]
$yaml = ag_set($yaml, 'links.0.map', [
'from' => 'imthedb',
'to' => 'guid_imdb',
]);
file_put_contents($tmpFile, Yaml::dump($yaml));
$class = $this->getClass();
$class->parseGUIDFile($tmpFile);
$this->assertArrayHasKey(
'imthedb',
ag($class->getConfig(), 'guidMapper', []),

View File

@@ -179,12 +179,12 @@ class JellyfinGuidTest extends TestCase
try {
$this->checkException(
closure: function () use ($tmpFile) {
file_put_contents($tmpFile, Yaml::dump(['jellyfin' => 'foo']));
file_put_contents($tmpFile, Yaml::dump(['links' => 'foo']));
$this->getClass()->parseGUIDFile($tmpFile);
},
reason: "Should throw an exception when there are no GUIDs mapping.",
exception: InvalidArgumentException::class,
exceptionMessage: 'jellyfin sub key is not an array'
exceptionMessage: 'links sub key is not an array'
);
} finally {
if (file_exists($tmpFile)) {
@@ -195,13 +195,13 @@ class JellyfinGuidTest extends TestCase
$tmpFile = tempnam(sys_get_temp_dir(), 'guid');
try {
$this->handler->clear();
$yaml = ['jellyfin' => []];
$yaml = ['links' => []];
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->assertCount(0, $this->handler->getRecords(), "There should be no messages logged for empty list.");
$this->handler->clear();
file_put_contents($tmpFile, Yaml::dump(ag_set($yaml, 'jellyfin.0', 'ff')));
file_put_contents($tmpFile, Yaml::dump(ag_set($yaml, 'links.0', 'ff')));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
$this->logged(Level::Warning, 'Value must be an object.', true),
@@ -217,15 +217,15 @@ class JellyfinGuidTest extends TestCase
$tmpFile = tempnam(sys_get_temp_dir(), 'guid');
try {
$yaml = ag_set(['jellyfin' => []], 'jellyfin.0.map', 'foo');
$yaml = ag_set(['links' => [0 => ['type' => 'jellyfin']]], 'links.0.map', 'foo');
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
$this->logged(Level::Warning, 'map value must be an object.', true),
'Assert replace key is an object.'
'Assert map key is an object.'
);
$yaml = ag_set($yaml, 'jellyfin.0', ['map' => []]);
$yaml = ag_set($yaml, 'links.0.map', []);
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
@@ -233,7 +233,7 @@ class JellyfinGuidTest extends TestCase
'Assert to field is a string.'
);
$yaml = ag_set($yaml, 'jellyfin.0.map.from', 'foo');
$yaml = ag_set($yaml, 'links.0.map.from', 'foo');
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
@@ -241,7 +241,7 @@ class JellyfinGuidTest extends TestCase
'Assert to field is a string.'
);
$yaml = ag_set($yaml, 'jellyfin.0.map.to', 'foobar');
$yaml = ag_set($yaml, 'links.0.map.to', 'foobar');
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
@@ -249,7 +249,7 @@ class JellyfinGuidTest extends TestCase
'Assert to field is a string.'
);
$yaml = ag_set($yaml, 'jellyfin.0.map.to', 'guid_foobar');
$yaml = ag_set($yaml, 'links.0.map.to', 'guid_foobar');
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
@@ -257,7 +257,7 @@ class JellyfinGuidTest extends TestCase
'Assert to field is a string.'
);
$yaml = ag_set($yaml, 'jellyfin.0.map', [
$yaml = ag_set($yaml, 'links.0.map', [
'from' => 'tsdb',
'to' => Guid::GUID_IMDB,
]);
@@ -274,12 +274,9 @@ class JellyfinGuidTest extends TestCase
);
$this->handler->clear();
$yaml = ag_set($yaml, 'jellyfin.0', [
'legacy' => false,
'map' => [
'from' => 'imthedb',
'to' => 'guid_imdb',
]
$yaml = ag_set($yaml, 'links.0.map', [
'from' => 'imthedb',
'to' => 'guid_imdb',
]);
file_put_contents($tmpFile, Yaml::dump($yaml));
$class = $this->getClass();

View File

@@ -108,7 +108,7 @@ class PlexGuidTest extends TestCase
try {
$this->checkException(
closure: function () use ($tmpFile) {
file_put_contents($tmpFile, 'version: 2.0');
file_put_contents($tmpFile, 'version: 99.0');
$this->getClass()->parseGUIDFile($tmpFile);
},
reason: "Failed to throw exception when the GUID file version is not supported.",
@@ -179,12 +179,12 @@ class PlexGuidTest extends TestCase
try {
$this->checkException(
closure: function () use ($tmpFile) {
file_put_contents($tmpFile, Yaml::dump(['plex' => 'foo']));
file_put_contents($tmpFile, Yaml::dump(['links' => 'foo']));
$this->getClass()->parseGUIDFile($tmpFile);
},
reason: "Should throw an exception when there are no GUIDs mapping.",
exception: InvalidArgumentException::class,
exceptionMessage: 'plex sub key is not an array'
exceptionMessage: 'links sub key is not an array'
);
} finally {
if (file_exists($tmpFile)) {
@@ -195,21 +195,21 @@ class PlexGuidTest extends TestCase
$tmpFile = tempnam(sys_get_temp_dir(), 'guid');
try {
$this->handler->clear();
$yaml = ['plex' => [[]]];
$yaml = ['links' => [['type' => 'plex']]];
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertCount(0, $this->handler->getRecords(), "There should be no messages logged for empty list.");
$this->handler->clear();
file_put_contents($tmpFile, Yaml::dump(ag_set($yaml, 'plex.0', 'ff')));
file_put_contents($tmpFile, Yaml::dump(ag_set($yaml, 'links.0', 'ff')));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
$this->logged(Level::Warning, 'Value must be an object.', true),
'Assert replace key is an object.'
);
$yaml = ag_set($yaml, 'plex.0.replace', 'foo');
$yaml = ag_set($yaml, 'links.0.replace', 'foo');
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
@@ -217,7 +217,7 @@ class PlexGuidTest extends TestCase
'Assert replace key is an object.'
);
$yaml = ag_set($yaml, 'plex.0', ['replace' => []]);
$yaml = ag_set($yaml, 'links.0.replace', []);
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
@@ -225,7 +225,7 @@ class PlexGuidTest extends TestCase
'Assert to field is a string.'
);
$yaml = ag_set($yaml, 'plex.0.replace.from', 'foo');
$yaml = ag_set($yaml, 'links.0.replace.from', 'foo');
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
@@ -233,7 +233,7 @@ class PlexGuidTest extends TestCase
'Assert to field is a string.'
);
$yaml = ag_set($yaml, 'plex.0.replace.to', 'bar');
$yaml = ag_set($yaml, 'links.0.replace.to', 'bar');
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertCount(0, $this->handler->getRecords(), "There should be no error messages logged.");
@@ -247,7 +247,7 @@ class PlexGuidTest extends TestCase
$tmpFile = tempnam(sys_get_temp_dir(), 'guid');
try {
$yaml = ag_set(['plex' => []], 'plex.0.map', 'foo');
$yaml = ag_set(['links' => [['type' => 'plex']]], 'links.0.map', 'foo');
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
@@ -255,7 +255,7 @@ class PlexGuidTest extends TestCase
'Assert replace key is an object.'
);
$yaml = ag_set($yaml, 'plex.0', ['map' => []]);
$yaml = ag_set($yaml, 'links.0.map', []);
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
@@ -263,7 +263,7 @@ class PlexGuidTest extends TestCase
'Assert to field is a string.'
);
$yaml = ag_set($yaml, 'plex.0.map.from', 'foo');
$yaml = ag_set($yaml, 'links.0.map.from', 'foo');
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
@@ -271,7 +271,7 @@ class PlexGuidTest extends TestCase
'Assert to field is a string.'
);
$yaml = ag_set($yaml, 'plex.0.map.to', 'foobar');
$yaml = ag_set($yaml, 'links.0.map.to', 'foobar');
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
@@ -279,7 +279,7 @@ class PlexGuidTest extends TestCase
'Assert to field is a string.'
);
$yaml = ag_set($yaml, 'plex.0.map.to', 'guid_foobar');
$yaml = ag_set($yaml, 'links.0.map.to', 'guid_foobar');
file_put_contents($tmpFile, Yaml::dump($yaml));
$this->getClass()->parseGUIDFile($tmpFile);
$this->assertTrue(
@@ -287,7 +287,7 @@ class PlexGuidTest extends TestCase
'Assert to field is a string.'
);
$yaml = ag_set($yaml, 'plex.0.map', [
$yaml = ag_set($yaml, 'links.0.map', [
'from' => 'com.plexapp.agents.imdb',
'to' => 'guid_imdb',
]);
@@ -298,7 +298,7 @@ class PlexGuidTest extends TestCase
'Assert to field is a string.'
);
$yaml = ag_set($yaml, 'plex.0.map', [
$yaml = ag_set($yaml, 'links.0.map', [
'from' => 'com.plexapp.agents.ccdb',
'to' => 'guid_imdb',
]);
@@ -315,8 +315,11 @@ class PlexGuidTest extends TestCase
);
$this->handler->clear();
$yaml = ag_set($yaml, 'plex.0', [
'legacy' => false,
$yaml = ag_set($yaml, 'links.0', [
'type' => 'plex',
'options' => [
'legacy' => false,
],
'map' => [
'from' => 'com.plexapp.agents.imthedb',
'to' => 'guid_imdb',

View File

@@ -49,9 +49,7 @@ class VttConverterTest extends TestCase
VTT;
$data = VttConverter::parse($text);
dump($data);
return $data;
return VttConverter::parse($text);
},
reason: 'Invalid VTT file',
exception: \InvalidArgumentException::class,