Inheritance: implements Mmoreram\PHPFormatter\Sorter\Interfaces\SorterInterface
 /**
  * Test skip empty
  */
 public function testGroupSkip()
 {
     $parsedData = $this->useSorter->setGroups(['Test2', 'TestEmpty', '_main', 'Test3'])->setSortType(UseSorter::SORT_TYPE_ALPHABETIC)->setSortDirection(UseSorter::SORT_DIRECTION_ASC)->setGroupType(UseSorter::GROUP_TYPE_EACH)->setGroupSkipEmpty(true)->sort($this->data);
     $result = "\nuse Test2\\Myclass3;\nuse Test2\\Myclass4;\n\nuse Test1\\Myclass1;\nuse Test1\\Myclass2;\nuse Test1\\MyFolder5\\File as MyFile;\nuse Test4\\Myclass3;\n\nuse Test3\\File;\nuse Test3\\MyFolder\\Myclass;\n";
     $realResult = "<?php\n\n/**\n * Copyright\n */\n\nnamespace PHPFormatter\\Tests\\Mocks;\n{$result}\n/**\n * Class SimpleMock\n */\nclass SimpleMock\n{}";
     $this->assertEquals($realResult, $parsedData);
 }
 /**
  * Create UseSorter Object given a configuration
  *
  * @param array $options Options
  *
  * @return UseSorter Use sorter instance
  */
 private function createUseSorter(array $options)
 {
     /**
      * Creates the new UseSorter file, given config values
      */
     $useSorter = new UseSorter();
     $useSorter->setGroups($options['group'])->setGroupType($options['group-type'])->setGroupSkipEmpty($options['group-skip-empty'])->setSortType($options['sort-type'])->setSortDirection($options['sort-direction']);
     return $useSorter;
 }
Example #3
0
 /**
  * Test sort
  *
  * @dataProvider dataSort
  */
 public function testSort($groups, $sortType, $sortDirection, $groupType, $result)
 {
     $parsedData = $this->useSorter->setGroups($groups)->setSortType($sortType)->setSortDirection($sortDirection)->setGroupType($groupType)->sort($this->data);
     $realResult = "<?php\n\n/**\n * Copyright\n */\n\nnamespace PHPFormatter\\Tests\\Mocks;\n{$result}\n/**\n * Class SimpleMock\n */\nclass SimpleMock\n{}";
     $this->assertEquals($realResult, $parsedData);
 }