123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <?php
- /*
- * This file is part of PHP CS Fixer.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- * Dariusz Rumiński <dariusz.ruminski@gmail.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
- namespace PhpCsFixer\Tests\Fixer\Import;
- use PhpCsFixer\Test\AbstractFixerTestCase;
- /**
- * @author Carlos Cirello <carlos.cirello.nl@gmail.com>
- *
- * @internal
- *
- * @covers \PhpCsFixer\Fixer\Import\NoLeadingImportSlashFixer
- */
- final class NoLeadingImportSlashFixerTest extends AbstractFixerTestCase
- {
- /**
- * @param string $expected
- * @param null|string $input
- *
- * @dataProvider provideFixCases
- */
- public function testFix($expected, $input = null)
- {
- $this->doTest($expected, $input);
- }
- /**
- * @param string $expected
- * @param null|string $input
- *
- * @dataProvider provideFix54Cases
- * @requires PHP 5.4
- */
- public function testFix54($expected, $input = null)
- {
- $this->doTest($expected, $input);
- }
- public function provideFixCases()
- {
- return array(
- array(
- '<?php
- use \A\B;
- ',
- ),
- array(
- '<?php
- $a = function(\B\C $a) use ($b){
- };
- ',
- ),
- array(
- '<?php
- namespace NS;
- use A\B;
- ',
- '<?php
- namespace NS;
- use \A\B;
- ',
- ),
- array(
- '<?php
- namespace NS{
- use A\B;
- }
- namespace NS2{
- use C\D;
- }
- ',
- '<?php
- namespace NS{
- use \A\B;
- }
- namespace NS2{
- use \C\D;
- }
- ',
- ),
- array(
- '<?php
- use \C;
- use \C\X;
- namespace Foo {
- use A;
- use A\X;
- new X();
- }
- namespace Bar {
- use B;
- use B\X;
- new X();
- }
- ',
- '<?php
- use \C;
- use \C\X;
- namespace Foo {
- use \A;
- use \A\X;
- new X();
- }
- namespace Bar {
- use \B;
- use \B\X;
- new X();
- }
- ',
- ),
- array(
- '<?php
- namespace Foo\Bar;
- use Baz;
- class Foo implements Baz {}
- ',
- '<?php
- namespace Foo\Bar;
- use \Baz;
- class Foo implements Baz {}
- ',
- ),
- );
- }
- public function provideFix54Cases()
- {
- return array(
- array(
- '<?php
- trait SomeTrait {
- use \A;
- }
- ',
- ),
- array(
- '<?php
- namespace NS{
- use A\B;
- trait Tr8A{
- use \B, \C;
- }
- }
- namespace NS2{
- use C\D;
- }
- ',
- '<?php
- namespace NS{
- use \A\B;
- trait Tr8A{
- use \B, \C;
- }
- }
- namespace NS2{
- use \C\D;
- }
- ',
- ),
- array(
- '<?php
- trait Foo {}
- class Bar {
- use \Foo;
- }
- ',
- ),
- );
- }
- }
|