]> git.mxchange.org Git - friendica.git/commitdiff
Add tests for BBCode::fetchShareAttributes
authorHypolite Petovan <hypolite@mrpetovan.com>
Sat, 25 Jun 2022 15:46:12 +0000 (11:46 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 25 Jun 2022 15:46:53 +0000 (11:46 -0400)
tests/src/Content/Text/BBCodeTest.php

index a5a27057fb8581033433a489c07ea015c1f0619c..9f293b706cca6a0b1cf4d2e71fa75afd66d3f131 100644 (file)
@@ -467,4 +467,130 @@ Karl Marx - Die ursprüngliche Akkumulation
 
                self::assertEquals($expected, $actual);
        }
+
+       public function dataFetchShareAttributes(): array
+       {
+               return [
+                       'no-tag' => [
+                               'expected' => [],
+                               'text' => 'Venture the only home we\'ve ever known laws of physics tendrils of gossamer clouds a still more glorious dawn awaits Sea of Tranquility. With pretty stories for which there\'s little good evidence the ash of stellar alchemy corpus callosum preserve and cherish that pale blue dot descended from astronomers preserve and cherish that pale blue dot. A mote of dust suspended in a sunbeam paroxysm of global death two ghostly white figures in coveralls and helmets are softly dancing descended from astronomers star stuff harvesting star light gathered by gravity and billions upon billions upon billions upon billions upon billions upon billions upon billions.',
+                       ],
+                       'just-open' => [
+                               'expected' => [],
+                               'text' => '[share]',
+                       ],
+                       'empty-tag' => [
+                               'expected' => [
+                                       'author' => '',
+                                   'profile' => '',
+                                   'avatar' => '',
+                                   'link' => '',
+                                   'posted' => '',
+                                   'guid' => '',
+                                   'comment' => '',
+                                   'shared' => '',
+                               ],
+                               'text' => '[share][/share]',
+                       ],
+                       'comment-shared' => [
+                               'expected' => [
+                                       'author' => '',
+                                       'profile' => '',
+                                       'avatar' => '',
+                                       'link' => '',
+                                       'posted' => '',
+                                       'guid' => '',
+                                       'comment' => 'comment',
+                                       'shared' => 'shared',
+                               ],
+                               'text' => ' comment
+                               [share]
+                               shared
+                               [/share]',
+                       ],
+                       'all-attributes' => [
+                               'expected' => [
+                                       'author' => 'Hypolite Petovan',
+                                       'profile' => 'https://friendica.mrpetovan.com/profile/hypolite',
+                                       'avatar' => 'https://friendica.mrpetovan.com/photo/20682437145daa4e85f019a278584494-5.png',
+                                       'link' => 'https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243',
+                                       'posted' => '2022-06-16 12:34:10',
+                                       'guid' => '735a2029-1062-ab23-42e4-f9c631220243',
+                                       'comment' => '',
+                                       'shared' => 'George Lucas: I made a science-fiction universe with a straightforward anti-authoritarianism plot where even the libertarian joins the rebellion.
+Disney: So a morally grey “choose your side” story, right?
+Lucas: For the right price, yes.',
+                               ],
+                               'text' => "[share
+                                   author='Hypolite Petovan'
+                                   profile='https://friendica.mrpetovan.com/profile/hypolite'
+                                   avatar='https://friendica.mrpetovan.com/photo/20682437145daa4e85f019a278584494-5.png'
+                                   link='https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243'
+                                   posted='2022-06-16 12:34:10'
+                                   guid='735a2029-1062-ab23-42e4-f9c631220243'
+                           ]George Lucas: I made a science-fiction universe with a straightforward anti-authoritarianism plot where even the libertarian joins the rebellion.
+Disney: So a morally grey “choose your side” story, right?
+Lucas: For the right price, yes.[/share]",
+                       ],
+                       'optional-attributes' => [
+                               'expected' => [
+                                       'author' => 'Hypolite Petovan',
+                                       'profile' => 'https://friendica.mrpetovan.com/profile/hypolite',
+                                       'avatar' => 'https://friendica.mrpetovan.com/photo/20682437145daa4e85f019a278584494-5.png',
+                                       'link' => 'https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243',
+                                       'posted' => '2022-06-16 12:34:10',
+                                       'guid' => '',
+                                       'comment' => '',
+                                       'shared' => 'George Lucas: I made a science-fiction universe with a straightforward anti-authoritarianism plot where even the libertarian joins the rebellion.
+Disney: So a morally grey “choose your side” story, right?
+Lucas: For the right price, yes.',
+                               ],
+                               'text' => "[share
+                                   author='Hypolite Petovan'
+                                   profile='https://friendica.mrpetovan.com/profile/hypolite'
+                                   avatar='https://friendica.mrpetovan.com/photo/20682437145daa4e85f019a278584494-5.png'
+                                   link='https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243'
+                                   posted='2022-06-16 12:34:10'
+                           ]George Lucas: I made a science-fiction universe with a straightforward anti-authoritarianism plot where even the libertarian joins the rebellion.
+Disney: So a morally grey “choose your side” story, right?
+Lucas: For the right price, yes.[/share]",
+                       ],
+                       'double-quotes' => [
+                               'expected' => [
+                                       'author' => 'Hypolite Petovan',
+                                       'profile' => 'https://friendica.mrpetovan.com/profile/hypolite',
+                                       'avatar' => 'https://friendica.mrpetovan.com/photo/20682437145daa4e85f019a278584494-5.png',
+                                       'link' => 'https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243',
+                                       'posted' => '2022-06-16 12:34:10',
+                                       'guid' => '',
+                                       'comment' => '',
+                                       'shared' => 'George Lucas: I made a science-fiction universe with a straightforward anti-authoritarianism plot where even the libertarian joins the rebellion.
+Disney: So a morally grey “choose your side” story, right?
+Lucas: For the right price, yes.',
+                               ],
+                               'text' => '[share
+                                   author="Hypolite Petovan"
+                                   profile="https://friendica.mrpetovan.com/profile/hypolite"
+                                   avatar="https://friendica.mrpetovan.com/photo/20682437145daa4e85f019a278584494-5.png"
+                                   link="https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243"
+                                   posted="2022-06-16 12:34:10"
+                           ]George Lucas: I made a science-fiction universe with a straightforward anti-authoritarianism plot where even the libertarian joins the rebellion.
+Disney: So a morally grey “choose your side” story, right?
+Lucas: For the right price, yes.[/share]',
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider dataFetchShareAttributes
+        *
+        * @param array $expected Expected attribute array
+        * @param string $text    Input text
+        */
+       public function testFetchShareAttributes(array $expected, string $text)
+       {
+               $actual = BBCode::fetchShareAttributes($text);
+
+               self::assertEquals($expected, $actual);
+       }
 }