sonarrradarrplexorganizrnginxdashboardhtpcserverhomepagesabnzbdheimdallembycouchpotatonzbgetbookmarkapplication-dashboardmuximuxlandingpagestartpagelanding
		
		
		
		
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							55 lines
						
					
					
						
							1.5 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							55 lines
						
					
					
						
							1.5 KiB
						
					
					
				
								<?php declare(strict_types=1);
							 | 
						|
								
							 | 
						|
								namespace PhpParser\Builder;
							 | 
						|
								
							 | 
						|
								use PhpParser\Comment;
							 | 
						|
								use PhpParser\Node;
							 | 
						|
								use PhpParser\Node\Name;
							 | 
						|
								use PhpParser\Node\Stmt;
							 | 
						|
								use PHPUnit\Framework\TestCase;
							 | 
						|
								
							 | 
						|
								class TraitUseTest extends TestCase
							 | 
						|
								{
							 | 
						|
								    protected function createTraitUseBuilder(...$traits) {
							 | 
						|
								        return new TraitUse(...$traits);
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    public function testAnd() {
							 | 
						|
								        $node = $this->createTraitUseBuilder('SomeTrait')
							 | 
						|
								            ->and('AnotherTrait')
							 | 
						|
								            ->getNode()
							 | 
						|
								        ;
							 | 
						|
								
							 | 
						|
								        $this->assertEquals(
							 | 
						|
								            new Stmt\TraitUse([
							 | 
						|
								                new Name('SomeTrait'),
							 | 
						|
								                new Name('AnotherTrait')
							 | 
						|
								            ]),
							 | 
						|
								            $node
							 | 
						|
								        );
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    public function testWith() {
							 | 
						|
								        $node = $this->createTraitUseBuilder('SomeTrait')
							 | 
						|
								            ->with(new Stmt\TraitUseAdaptation\Alias(null, 'foo', null, 'bar'))
							 | 
						|
								            ->with((new TraitUseAdaptation(null, 'test'))->as('baz'))
							 | 
						|
								            ->getNode()
							 | 
						|
								        ;
							 | 
						|
								
							 | 
						|
								        $this->assertEquals(
							 | 
						|
								            new Stmt\TraitUse([new Name('SomeTrait')], [
							 | 
						|
								                new Stmt\TraitUseAdaptation\Alias(null, 'foo', null, 'bar'),
							 | 
						|
								                new Stmt\TraitUseAdaptation\Alias(null, 'test', null, 'baz')
							 | 
						|
								            ]),
							 | 
						|
								            $node
							 | 
						|
								        );
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    public function testInvalidAdaptationNode() {
							 | 
						|
								        $this->expectException(\LogicException::class);
							 | 
						|
								        $this->expectExceptionMessage('Adaptation must have type TraitUseAdaptation');
							 | 
						|
								        $this->createTraitUseBuilder('Test')
							 | 
						|
								            ->with(new Stmt\Echo_([]))
							 | 
						|
								        ;
							 | 
						|
								    }
							 | 
						|
								}
							 | 
						|
								
							 |