Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ExpressionConverterTest.php
Go to the documentation of this file.
1 <?php
2 /***
3  * Copyright © Magento, Inc. All rights reserved.
4  * See COPYING.txt for license details.
5  */
6 
8 
10 
11 class ExpressionConverterTest extends \PHPUnit\Framework\TestCase
12 {
16  public function testShortenEntityName($in, $prefix, $expectedOut)
17  {
18  $resultEntityName = ExpressionConverter::shortenEntityName($in, $prefix);
19  $this->assertTrue(
20  strpos($resultEntityName, $expectedOut) === 0,
21  "Entity name '$resultEntityName' did not begin with expected value '$expectedOut'"
22  );
23  }
24 
29  {
30  $length64 = '________________________________________________________________';
31  $length40 = '________________________________________';
32  return [
33  'Short identifier' => [
34  'already_short',
35  'pre_',
36  'already_short'
37  ],
38  'Hashed identifer' => [
39  $length64 . '_cannotBeAbbreviated',
40  'pre_',
41  'pre_'
42  ],
43  'Abbreviated identifier' => [
44  $length40 . 'downloadable_notification_index',
45  'pre_',
46  $length40 . 'dl_ntfc_idx'
47  ],
48  ];
49  }
50 
52  {
54  $length64 = '________________________________________________________________';
55  $longPrefix = 'pre_____________________________________';
56  $shortenedName = ExpressionConverter::shortenEntityName($length64 . '_cannotBeAbbreviated', $longPrefix);
57  $this->assertNotSame(0, strpos($shortenedName, 'pre'), 'Entity name not supposed to with long prefix');
58  }
59 }
static shortenEntityName($entityName, $prefix)
$prefix
Definition: name.phtml:25