| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Created by PhpStorm. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * User: imhotek | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Date: 13/05/17 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * Time: 13:32 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | namespace ConferenceTools\Tickets\Domain\ReadModel\TicketCounts; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use ConferenceTools\Tickets\Domain\ValueObject\Money; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use ConferenceTools\Tickets\Domain\ValueObject\Price; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use ConferenceTools\Tickets\Domain\ValueObject\TaxRate; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use ConferenceTools\Tickets\Domain\ValueObject\TicketType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use PHPUnit\Framework\TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | class TicketCounterTest extends TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | { | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 20 |  | View Code Duplication |     public function testCreate() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         $price = Price::fromNetCost(new Money(100, 'GBP'), new TaxRate(20)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         $ticketType = new TicketType('test', $price, 'Test ticket'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         $sut = new TicketCounter($ticketType, 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         self::assertEquals($ticketType, $sut->getTicketType()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         self::assertEquals(10, $sut->getRemaining()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 31 |  | View Code Duplication |     public function testTicketsReserved() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         $price = Price::fromNetCost(new Money(100, 'GBP'), new TaxRate(20)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         $ticketType = new TicketType('test', $price, 'Test ticket'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         $sut = new TicketCounter($ticketType, 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         $sut->ticketsReserved(5); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         self::assertEquals(5, $sut->getRemaining()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                        
                            
            
                                                                    
                                                                                                        
            
            
                | 42 |  | View Code Duplication |     public function testTicketsReleased() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |         $price = Price::fromNetCost(new Money(100, 'GBP'), new TaxRate(20)); | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |         $ticketType = new TicketType('test', $price, 'Test ticket'); | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |         $sut = new TicketCounter($ticketType, 10); | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |         $sut->ticketsReleased(5); | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |         self::assertEquals(15, $sut->getRemaining()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 52 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 53 |  |  |  | 
            
                        
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.