29 lines
		
	
	
		
			635 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
		
		
			
		
	
	
			29 lines
		
	
	
		
			635 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| 
								 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								namespace NoccyLabs\React\CommandBus;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								use PHPUnit\Framework\Attributes\CoversClass;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#[CoversClass(Command::class)]
							 | 
						||
| 
								 | 
							
								class CommandTest extends \PHPUnit\Framework\TestCase
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    public function testCommandName()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $command = new Command("foobar", function () {});
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        $this->assertEquals('foobar', $command->getName());
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    public function testCommandExecution()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $hit = false;
							 | 
						||
| 
								 | 
							
								        $command = new Command("foobar", function () use (&$hit) { $hit=true; });
							 | 
						||
| 
								 | 
							
								        $context = new Context("foobar", []);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        $command->call($context);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        $this->assertEquals(true, $hit);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								}
							 |