2021-08-25 19:33:00 +02:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace tests\Integration;
|
|
|
|
|
|
|
|
use OCA\GPodderSync\Core\EpisodeAction\EpisodeActionSaver;
|
|
|
|
use OCP\AppFramework\App;
|
2021-10-05 12:30:52 +02:00
|
|
|
use OCP\AppFramework\IAppContainer;
|
2021-08-25 19:33:00 +02:00
|
|
|
use Test\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group DB
|
|
|
|
*/
|
|
|
|
class EpisodeActionSaverGuidMigrationTest extends TestCase
|
|
|
|
{
|
2021-08-25 22:24:06 +02:00
|
|
|
private const USER_ID_0 = "testuser0";
|
2021-08-25 19:33:00 +02:00
|
|
|
|
2021-10-05 12:30:52 +02:00
|
|
|
private IAppContainer $container;
|
2021-08-25 19:33:00 +02:00
|
|
|
|
|
|
|
public function setUp(): void {
|
|
|
|
parent::setUp();
|
|
|
|
$app = new App('gpoddersync');
|
|
|
|
$this->container = $app->getContainer();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCreateEpisodeActionWithoutGuidThenCreateAgainWithGuid() : void
|
|
|
|
{
|
|
|
|
/** @var EpisodeActionSaver $episodeActionSaver */
|
|
|
|
$episodeActionSaver = $this->container->get(EpisodeActionSaver::class);
|
|
|
|
|
2021-08-25 22:24:06 +02:00
|
|
|
$episodeUrl = uniqid("test_https://dts.podtrac.com/redirect.mp3/chrt.fm/track");
|
|
|
|
$guid = uniqid("test_gid://art19-episode-locator/V0/Ktd");
|
2021-08-25 19:33:00 +02:00
|
|
|
|
|
|
|
$savedEpisodeActionEntityWithoutGuid = $episodeActionSaver->saveEpisodeActions(
|
2021-10-06 19:11:50 +02:00
|
|
|
[["podcast" => 'https://rss.art19.com/dr-death-s3-miracle-man', "episode" => $episodeUrl, "action" => "PLAY", "timestamp" => "2021-08-22T23:58:56", "started" => 47, "position" => 54, "total" => 2252]],
|
2021-08-25 19:33:00 +02:00
|
|
|
self::USER_ID_0
|
|
|
|
)[0];
|
|
|
|
|
|
|
|
$savedEpisodeActionEntityWithGuid = $episodeActionSaver->saveEpisodeActions(
|
2021-10-06 19:11:50 +02:00
|
|
|
[["podcast" => 'https://rss.art19.com/dr-death-s3-miracle-man', "episode" => $episodeUrl, "guid" => $guid, "action" => "PLAY", "timestamp" => "2021-08-22T23:58:56", "started" => 47, "position" => 54, "total" => 2252]],
|
2021-08-25 19:33:00 +02:00
|
|
|
self::USER_ID_0
|
|
|
|
)[0];
|
|
|
|
|
|
|
|
self::assertSame($savedEpisodeActionEntityWithoutGuid->getId(), $savedEpisodeActionEntityWithGuid->getId());
|
|
|
|
}
|
2021-08-25 19:51:43 +02:00
|
|
|
|
|
|
|
public function testCreateEpisodeActionWithGuidThenCreateAgainWithGuidButDifferentEpisodeUrl() : void
|
|
|
|
{
|
|
|
|
/** @var EpisodeActionSaver $episodeActionSaver */
|
|
|
|
$episodeActionSaver = $this->container->get(EpisodeActionSaver::class);
|
|
|
|
|
2021-08-25 22:24:06 +02:00
|
|
|
$episodeUrl = uniqid("test_https://dts.podtrac.com/redirect.mp3/chrt.fm/track");
|
|
|
|
$guid = uniqid("test_gid://art19-episode-locator/V0/Ktd");
|
2021-08-25 19:51:43 +02:00
|
|
|
|
|
|
|
$savedEpisodeActionEntity = $episodeActionSaver->saveEpisodeActions(
|
2021-10-06 19:11:50 +02:00
|
|
|
[["podcast" => 'https://rss.art19.com/dr-death-s3-miracle-man', "episode" => $episodeUrl, "guid" => $guid, "action" => "PLAY", "timestamp" => "2021-08-22T23:58:56", "started" => 47, "position" => 54, "total" => 2252]],
|
2021-08-25 19:51:43 +02:00
|
|
|
self::USER_ID_0
|
|
|
|
)[0];
|
|
|
|
|
|
|
|
$savedEpisodeActionEntityWithDifferentEpisodeUrl = $episodeActionSaver->saveEpisodeActions(
|
2021-10-06 19:11:50 +02:00
|
|
|
[["podcast" => 'https://rss.art19.com/dr-death-s3-miracle-man', "episode" => $episodeUrl . "_different", "guid" => $guid, "action" => "PLAY", "timestamp" => "2021-08-22T23:58:56", "started" => 47, "position" => 54, "total" => 2252]],
|
|
|
|
self::USER_ID_0
|
2021-08-25 19:51:43 +02:00
|
|
|
)[0];
|
|
|
|
|
|
|
|
self::assertSame($savedEpisodeActionEntity->getId(), $savedEpisodeActionEntityWithDifferentEpisodeUrl->getId());
|
|
|
|
}
|
2021-10-05 12:30:52 +02:00
|
|
|
|
2021-08-25 19:33:00 +02:00
|
|
|
}
|