3 declare(strict_types
=1);
5 namespace PhpMyAdmin\Tests
;
7 use PhpMyAdmin\BrowseForeigners
;
8 use PhpMyAdmin\Template
;
10 class BrowseForeignersTest
extends AbstractTestCase
12 /** @var BrowseForeigners */
13 private $browseForeigners;
16 * Setup for test cases
18 protected function setUp(): void
22 $GLOBALS['cfg']['LimitChars'] = 50;
23 $GLOBALS['cfg']['MaxRows'] = 25;
24 $GLOBALS['cfg']['RepeatCells'] = 100;
25 $GLOBALS['cfg']['ShowAll'] = false;
26 $this->browseForeigners
= new BrowseForeigners(new Template());
30 * Test for BrowseForeigners::getForeignLimit
32 public function testGetForeignLimit(): void
35 $this->browseForeigners
->getForeignLimit('Show all')
40 $this->browseForeigners
->getForeignLimit(null)
47 $this->browseForeigners
->getForeignLimit(null)
50 $GLOBALS['cfg']['MaxRows'] = 50;
51 $browseForeigners = new BrowseForeigners(new Template());
55 $browseForeigners->getForeignLimit(null)
60 $browseForeigners->getForeignLimit('xyz')
65 * Test for BrowseForeigners::getHtmlForGotoPage
67 public function testGetHtmlForGotoPage(): void
72 $this->browseForeigners
,
73 BrowseForeigners
::class,
81 $foreignData['disp_row'] = [];
82 $foreignData['the_total'] = 5;
87 $this->browseForeigners
,
88 BrowseForeigners
::class,
94 $foreignData['the_total'] = 30;
95 $result = $this->callFunction(
96 $this->browseForeigners
,
97 BrowseForeigners
::class,
102 $this->assertStringStartsWith(
107 $this->assertStringEndsWith(
112 $this->assertStringContainsString(
113 '<select class="pageselector ajax" name="pos"',
117 $this->assertStringContainsString(
118 '<option selected="selected" '
119 . 'style="font-weight: bold" value="0">',
123 $this->assertStringContainsString(
124 '<option value="25"',
130 * Test for BrowseForeigners::getDescriptionAndTitle
132 public function testGetDescriptionAndTitle(): void
134 $desc = 'foobar<baz';
142 $this->browseForeigners
,
143 BrowseForeigners
::class,
144 'getDescriptionAndTitle',
149 $GLOBALS['cfg']['LimitChars'] = 5;
150 $browseForeigners = new BrowseForeigners(new Template());
159 BrowseForeigners
::class,
160 'getDescriptionAndTitle',
167 * Test for BrowseForeigners::getHtmlForRelationalFieldSelection
169 public function testGetHtmlForRelationalFieldSelection(): void
175 $foreignData['disp_row'] = '';
178 $_POST['rownumber'] = 1;
179 $_POST['foreign_filter'] = '5';
180 $result = $this->browseForeigners
->getHtmlForRelationalFieldSelection(
189 $this->assertStringContainsString(
190 '<form class="ajax" '
191 . 'id="browse_foreign_form" name="browse_foreign_from" '
192 . 'action="index.php?route=/browse-foreigners',
195 $this->assertStringContainsString(
200 $this->assertStringContainsString(
205 $this->assertStringContainsString(
206 '<input type="hidden" name="field" value="foo">',
210 $this->assertStringContainsString(
211 '<input type="hidden" name="fieldkey" value="bar">',
215 $this->assertStringContainsString(
216 '<input type="hidden" name="rownumber" value="1">',
220 $this->assertStringContainsString(
221 '<span class="formelement">',
225 $this->assertStringContainsString(
226 '<label for="input_foreign_filter">',
230 $this->assertStringContainsString(
231 '<input type="text" name="foreign_filter" '
232 . 'id="input_foreign_filter" '
233 . 'value="5" data-old="5" '
238 $this->assertStringContainsString(
239 '<input class="btn btn-primary" type="submit" name="submit_foreign_filter" value="Go">',
243 $this->assertStringContainsString(
244 '<span class="formelement">',
248 $this->assertStringContainsString(
249 '<table width="100%" id="browse_foreign_table">',
253 $foreignData['disp_row'] = [];
254 $foreignData['the_total'] = 5;
255 $result = $this->browseForeigners
->getHtmlForRelationalFieldSelection(
264 $this->assertStringContainsString(
265 '<table width="100%" id="browse_foreign_table">',
269 $this->assertStringContainsString(