WebformObjectHelperTest.php in Webform 8.5        
                          
                  
                        
  
  
  
  
File
  tests/src/Unit/Utility/WebformObjectHelperTest.php
  
    View source  
  <?php
namespace Drupal\Tests\webform\Unit\Utility;
use Drupal\webform\Utility\WebformObjectHelper;
use Drupal\Tests\UnitTestCase;
class WebformObjectHelperTest extends UnitTestCase {
  
  public function testSortByProperty($object, array $expected) {
    $result = (array) WebformObjectHelper::sortByProperty($object);
    $this
      ->assertEquals(implode('|', array_keys($expected)), implode('|', array_keys($result)));
  }
  
  public function providerSortByProperty() {
    $object = new \stdClass();
    $object->c = 'c';
    $object->a = 'a';
    $object->b = 'b';
    $tests[] = [
      $object,
      [
        'a' => 'a',
        'b' => 'b',
        'c' => 'c',
      ],
    ];
    $object = new \stdClass();
    $object->c = 'c';
    $object->b = 'b';
    $object->a = 'a';
    $tests[] = [
      $object,
      [
        'a' => 'a',
        'b' => 'b',
        'c' => 'c',
      ],
    ];
    $object = new \stdClass();
    $object->b = 'b';
    $object->a = 'a';
    $object->_ = '_';
    $tests[] = [
      $object,
      [
        '_' => '_',
        'a' => 'a',
        'b' => 'b',
      ],
    ];
    return $tests;
  }
}