From c03ddf08914358daac8b354f06284dcb8e8eb90f Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 30 Dec 2021 21:52:18 +0100 Subject: [PATCH] Move API Status tests --- tests/datasets/api.fixture.php | 103 ++++++++++++++++++- tests/legacy/ApiTest.php | 87 ---------------- tests/src/Factory/Api/Twitter/StatusTest.php | 85 +++++++++++++++ 3 files changed, 187 insertions(+), 88 deletions(-) create mode 100644 tests/src/Factory/Api/Twitter/StatusTest.php diff --git a/tests/datasets/api.fixture.php b/tests/datasets/api.fixture.php index 5f87159c49..a764c31a7b 100644 --- a/tests/datasets/api.fixture.php +++ b/tests/datasets/api.fixture.php @@ -105,7 +105,11 @@ return [ 'uri' => '6', 'guid' => '6', ], - + [ + 'id' => 7, + 'uri' => '7', + 'guid' => '7', + ], [ 'id' => 42, 'uri' => 'http://localhost/profile/selfcontact', @@ -342,6 +346,34 @@ return [ 'body' => 'Friend user status', 'plink' => 'http://localhost/display/6', ], + [ + 'uri-id' => 7, + 'title' => 'item_title', + 'body' => 'perspiciatis impedit voluptatem quis molestiae ea qui ' . + 'reiciendis dolorum aut ducimus sunt consequatur inventore dolor ' . + 'officiis pariatur doloremque nemo culpa aut quidem qui dolore ' . + 'laudantium atque commodi alias voluptatem non possimus aperiam ' . + 'ipsum rerum consequuntur aut amet fugit quia aliquid praesentium ' . + 'repellendus quibusdam et et inventore mollitia rerum sit autem ' . + 'pariatur maiores ipsum accusantium perferendis vel sit possimus ' . + 'veritatis nihil distinctio qui eum repellat officia illum quos ' . + 'impedit quam iste esse unde qui suscipit aut facilis ut inventore ' . + 'omnis exercitationem quo magnam consequatur maxime aut illum ' . + 'soluta quaerat natus unde aspernatur et sed beatae nihil ullam ' . + 'temporibus corporis ratione blanditiis perspiciatis impedit ' . + 'voluptatem quis molestiae ea qui reiciendis dolorum aut ducimus ' . + 'sunt consequatur inventore dolor officiis pariatur doloremque ' . + 'nemo culpa aut quidem qui dolore laudantium atque commodi alias ' . + 'voluptatem non possimus aperiam ipsum rerum consequuntur aut ' . + 'amet fugit quia aliquid praesentium repellendus quibusdam et et ' . + 'inventore mollitia rerum sit autem pariatur maiores ipsum accusantium ' . + 'perferendis vel sit possimus veritatis nihil distinctio qui eum ' . + 'repellat officia illum quos impedit quam iste esse unde qui ' . + 'suscipit aut facilis ut inventore omnis exercitationem quo magnam ' . + 'consequatur maxime aut illum soluta quaerat natus unde aspernatur ' . + 'et sed beatae nihil ullam temporibus corporis ratione blanditiis', + 'plink' => 'http://localhost/display/6', + ], ], 'post' => [ [ @@ -434,6 +466,21 @@ return [ 'visible' => 1, 'deleted' => 0, ], + [ + 'uri-id' => 7, + 'parent-uri-id' => 7, + 'thr-parent-id' => 7, + 'gravity' => GRAVITY_PARENT, + 'network' => Protocol::DFRN, + 'owner-id' => 42, + 'author-id' => 44, + 'causer-id' => 44, + 'vid' => 8, + 'private' => Item::PUBLIC, + 'global' => true, + 'visible' => 1, + 'deleted' => 0, + ], ], 'post-user' => [ [ @@ -687,6 +734,27 @@ return [ 'deleted' => 0, 'wall' => 0, ], + [ + 'id' => 13, + 'uri-id' => 7, + 'visible' => 1, + 'contact-id' => 44, + 'author-id' => 44, + 'owner-id' => 42, + 'causer-id' => 44, + 'uid' => 0, + 'vid' => 8, + 'unseen' => 0, + 'parent-uri-id' => 7, + 'thr-parent-id' => 7, + 'private' => Item::PUBLIC, + 'global' => true, + 'gravity' => GRAVITY_PARENT, + 'network' => Protocol::DFRN, + 'origin' => 0, + 'deleted' => 0, + 'wall' => 0, + ], ], 'post-thread' => [ [ @@ -710,6 +778,13 @@ return [ 'causer-id' => 44, 'network' => Protocol::DFRN, ], + [ + 'uri-id' => 7, + 'author-id' => 44, + 'owner-id' => 44, + 'causer-id' => 44, + 'network' => Protocol::DFRN, + ], ], 'post-thread-user' => [ [ @@ -790,6 +865,32 @@ return [ 'starred' => 0, 'origin' => 0, ], + [ + 'uri-id' => 7, + 'uid' => 42, + 'wall' => 1, + 'post-user-id' => 7, + 'author-id' => 44, + 'owner-id' => 44, + 'causer-id' => 44, + 'contact-id' => 44, + 'network' => Protocol::DFRN, + 'starred' => 0, + 'origin' => 1, + ], + [ + 'uri-id' => 7, + 'uid' => 0, + 'wall' => 0, + 'post-user-id' => 12, + 'author-id' => 44, + 'owner-id' => 44, + 'causer-id' => 44, + 'contact-id' => 44, + 'network' => Protocol::DFRN, + 'starred' => 0, + 'origin' => 0, + ], ], 'notify' => [ [ diff --git a/tests/legacy/ApiTest.php b/tests/legacy/ApiTest.php index db43fde421..206dff2a89 100644 --- a/tests/legacy/ApiTest.php +++ b/tests/legacy/ApiTest.php @@ -679,93 +679,6 @@ class ApiTest extends FixtureTest // api_statuses_mediap('json'); } - /** - * Test the api_convert_item() function. - * - * @return void - */ - public function testApiConvertItem() - { - /* - $result = api_convert_item( - [ - 'network' => 'feed', - 'title' => 'item_title', - 'uri-id' => 1, - // We need a long string to test that it is correctly cut - 'body' => 'perspiciatis impedit voluptatem quis molestiae ea qui ' . - 'reiciendis dolorum aut ducimus sunt consequatur inventore dolor ' . - 'officiis pariatur doloremque nemo culpa aut quidem qui dolore ' . - 'laudantium atque commodi alias voluptatem non possimus aperiam ' . - 'ipsum rerum consequuntur aut amet fugit quia aliquid praesentium ' . - 'repellendus quibusdam et et inventore mollitia rerum sit autem ' . - 'pariatur maiores ipsum accusantium perferendis vel sit possimus ' . - 'veritatis nihil distinctio qui eum repellat officia illum quos ' . - 'impedit quam iste esse unde qui suscipit aut facilis ut inventore ' . - 'omnis exercitationem quo magnam consequatur maxime aut illum ' . - 'soluta quaerat natus unde aspernatur et sed beatae nihil ullam ' . - 'temporibus corporis ratione blanditiis perspiciatis impedit ' . - 'voluptatem quis molestiae ea qui reiciendis dolorum aut ducimus ' . - 'sunt consequatur inventore dolor officiis pariatur doloremque ' . - 'nemo culpa aut quidem qui dolore laudantium atque commodi alias ' . - 'voluptatem non possimus aperiam ipsum rerum consequuntur aut ' . - 'amet fugit quia aliquid praesentium repellendus quibusdam et et ' . - 'inventore mollitia rerum sit autem pariatur maiores ipsum accusantium ' . - 'perferendis vel sit possimus veritatis nihil distinctio qui eum ' . - 'repellat officia illum quos impedit quam iste esse unde qui ' . - 'suscipit aut facilis ut inventore omnis exercitationem quo magnam ' . - 'consequatur maxime aut illum soluta quaerat natus unde aspernatur ' . - 'et sed beatae nihil ullam temporibus corporis ratione blanditiis', - 'plink' => 'item_plink' - ] - ); - self::assertStringStartsWith('item_title', $result['text']); - self::assertStringStartsWith('

item_title


perspiciatis impedit voluptatem', $result['html']); - */ - } - - /** - * Test the api_convert_item() function with an empty item body. - * - * @return void - */ - public function testApiConvertItemWithoutBody() - { - /* - $result = api_convert_item( - [ - 'network' => 'feed', - 'title' => 'item_title', - 'uri-id' => -1, - 'body' => '', - 'plink' => 'item_plink' - ] - ); - self::assertEquals("item_title", $result['text']); - self::assertEquals('

item_title


item_plink', $result['html']); - */ - } - - /** - * Test the api_convert_item() function with the title in the body. - * - * @return void - */ - public function testApiConvertItemWithTitleInBody() - { - /* - $result = api_convert_item( - [ - 'title' => 'item_title', - 'body' => 'item_title item_body', - 'uri-id' => 1, - ] - ); - self::assertEquals('item_title item_body', $result['text']); - self::assertEquals('

item_title


item_title item_body', $result['html']); - */ - } - /** * Test the api_get_attachments() function. * diff --git a/tests/src/Factory/Api/Twitter/StatusTest.php b/tests/src/Factory/Api/Twitter/StatusTest.php new file mode 100644 index 0000000000..52814baba8 --- /dev/null +++ b/tests/src/Factory/Api/Twitter/StatusTest.php @@ -0,0 +1,85 @@ +createFromItemId(13, ApiTest::SELF_USER['id']); + $status = $statusObj->toArray(); + + self::assertStringStartsWith('item_title', $status['text']); + self::assertStringStartsWith('

item_title


perspiciatis impedit voluptatem', $status['html']); + } + + /** + * Test the api_convert_item() function with an empty item body. + * + * @return void + */ + public function testApiConvertItemWithoutBody() + { + self::markTestIncomplete('Needs a dataset first'); + + /* + $result = api_convert_item( + [ + 'network' => 'feed', + 'title' => 'item_title', + 'uri-id' => -1, + 'body' => '', + 'plink' => 'item_plink' + ] + ); + self::assertEquals("item_title", $result['text']); + self::assertEquals('

item_title


item_plink', $result['html']); + */ + } + + /** + * Test the api_convert_item() function with the title in the body. + * + * @return void + */ + public function testApiConvertItemWithTitleInBody() + { + self::markTestIncomplete('Needs a dataset first'); + + /* + $result = api_convert_item( + [ + 'title' => 'item_title', + 'body' => 'item_title item_body', + 'uri-id' => 1, + ] + ); + self::assertEquals('item_title item_body', $result['text']); + self::assertEquals('

item_title


item_title item_body', $result['html']); + */ + } +}