Exemplo n.º 1
0
 public function testPrepareCommandOnHhvm()
 {
     if (!defined('HHVM_VERSION')) {
         $this->markTestSkipped('Skip tests for HHVM compiler when running on PHP compiler.');
     }
     $this->assertSame($this->fixEscape('"hhvm" --php -l "foo.php"'), AccessibleObject::create(new Linter('hhvm'))->prepareCommand('foo.php'));
 }
Exemplo n.º 2
0
 /**
  * @covers Symfony\CS\FixerFactory::attachConfig
  */
 public function testMethodAttachConfig()
 {
     $factory = new FixerFactory();
     $fixer = new Psr0Fixer();
     $factory->registerFixer($fixer);
     $mock = $this->getMock('Symfony\\CS\\ConfigInterface');
     $testInstance = $factory->attachConfig($mock);
     $property = AccessibleObject::create($fixer)->config;
     $this->assertSame($mock, $property);
 }
 private function assertTokens(Tokens $expectedTokens, Tokens $inputTokens)
 {
     foreach ($expectedTokens as $index => $expectedToken) {
         $inputToken = $inputTokens[$index];
         $this->assertTrue($expectedToken->equals($inputToken), sprintf('The token at index %d must be %s, got %s', $index, $expectedToken->toJson(), $inputToken->toJson()));
     }
     $this->assertSame($expectedTokens->count(), $inputTokens->count(), 'The collection must have the same length than the expected one.');
     $foundTokenKinds = array_keys(AccessibleObject::create($expectedTokens)->foundTokenKinds);
     foreach ($foundTokenKinds as $tokenKind) {
         $this->assertTrue($inputTokens->isTokenKindFound($tokenKind), sprintf('The token kind %s must be found in fixed tokens collection.', $tokenKind));
     }
 }
Exemplo n.º 4
0
 public function provideCustomTokenPrefixCases()
 {
     $transformers = Transformers::create();
     $items = AccessibleObject::create($transformers)->items;
     $cases = array();
     foreach ($items as $item) {
         foreach ($item->getCustomTokenNames() as $name) {
             $cases[] = array($name);
         }
     }
     return $cases;
 }
 public function provideTestFixCases()
 {
     $methodsMap = AccessibleObject::create($this->getFixer())->configuration;
     $cases = array(array('<?php $self->foo();'));
     foreach ($methodsMap as $methodBefore => $methodAfter) {
         $cases[] = array("<?php \$sth->{$methodBefore}(1, 1);");
         $cases[] = array("<?php \$sth->{$methodAfter}(1, 1);");
         $cases[] = array("<?php \$this->{$methodAfter}(1, 2);", "<?php \$this->{$methodBefore}(1, 2);");
         $cases[] = array("<?php \$this->{$methodAfter}(1, 2); \$this->{$methodAfter}(1, 2);", "<?php \$this->{$methodBefore}(1, 2); \$this->{$methodBefore}(1, 2);");
         $cases[] = array("<?php \$this->{$methodAfter}(1, 2, 'descr');", "<?php \$this->{$methodBefore}(1, 2, 'descr');");
         $cases[] = array("<?php \$this->/*aaa*/{$methodAfter} \t /**bbb*/  ( /*ccc*/1  , 2);", "<?php \$this->/*aaa*/{$methodBefore} \t /**bbb*/  ( /*ccc*/1  , 2);");
         $cases[] = array("<?php \$this->{$methodAfter}(\$expectedTokens->count() + 10, \$tokens->count() ? 10 : 20 , 'Test');", "<?php \$this->{$methodBefore}(\$expectedTokens->count() + 10, \$tokens->count() ? 10 : 20 , 'Test');");
     }
     return $cases;
 }
 public function testCwd()
 {
     $this->resolver->setCwd('foo');
     $property = AccessibleObject::create($this->resolver)->cwd;
     $this->assertSame('foo', $property);
 }
 public function testCreate()
 {
     $object = AccessibleObject::create(new \stdClass());
     $this->assertInstanceOf('Symfony\\CS\\Test\\AccessibleObject', $object);
 }