public function BasicTest::testNaturalSortNumbers in Views Natural Sort 8.2
File
- tests/
src/ Kernel/ BasicTest.php, line 153
Class
- BasicTest
- @group views_natural_sort
Namespace
Drupal\Tests\views_natural_sort\KernelCode
public function testNaturalSortNumbers() {
$node1 = Node::create([
'type' => 'views_natural_sort_test_content',
'title' => '1 apple',
]);
$node1
->save();
$node2 = Node::create([
'type' => 'views_natural_sort_test_content',
'title' => '2 apples',
]);
$node2
->save();
$node3 = Node::create([
'type' => 'views_natural_sort_test_content',
'title' => '10 apples',
]);
$node3
->save();
$node4 = Node::create([
'type' => 'views_natural_sort_test_content',
'title' => '-1 apples',
]);
$node4
->save();
$node5 = Node::create([
'type' => 'views_natural_sort_test_content',
'title' => '-10 apples',
]);
$node5
->save();
$node6 = Node::create([
'type' => 'views_natural_sort_test_content',
'title' => '-2 apples',
]);
$node6
->save();
$node7 = Node::create([
'type' => 'views_natural_sort_test_content',
'title' => '-3.550 apples',
]);
$node7
->save();
$node8 = Node::create([
'type' => 'views_natural_sort_test_content',
'title' => '-3.5501 apples',
]);
$node8
->save();
$node9 = Node::create([
'type' => 'views_natural_sort_test_content',
'title' => '3.5501 apples',
]);
$node9
->save();
$node0 = Node::create([
'type' => 'views_natural_sort_test_content',
'title' => '3.550 apples',
]);
$node0
->save();
$view = Views::getView('views_natural_sort_test');
$view
->setDisplay();
$view
->preview('default');
$this
->assertIdenticalResultset($view, [
[
'title' => '-10 apples',
],
[
'title' => '-3.5501 apples',
],
[
'title' => '-3.550 apples',
],
[
'title' => '-2 apples',
],
[
'title' => '-1 apples',
],
[
'title' => '1 apple',
],
[
'title' => '2 apples',
],
[
'title' => '3.550 apples',
],
[
'title' => '3.5501 apples',
],
[
'title' => '10 apples',
],
], [
'title' => 'title',
]);
}