| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | use Wambo\Catalog\Model\Content; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * Class ContentTests tests the Wambo\Catalog\Model\Content class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | class ContentTests extends PHPUnit_Framework_TestCase | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |      * If the given content data is valid a Content model with the given title, summary and description | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |      * should be returned | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |      * @dataProvider getValidContentData | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |      * @param string $title | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      * @param string $summary | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |      * @param string $description | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     public function getContent_ValidContentGiven_ContentIsReturned( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         $title, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         $summary, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         $description | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         // act | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         $content = new Content($title, $summary, $description); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         // assert | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         $this->assertNotEmpty($content->getTitle(), "The title of the content model should not be empty"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         $this->assertNotEmpty($content->getSummaryText(), "The summary of the content model should not be empty"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         $this->assertNotEmpty($content->getProductDescription(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |             "The description of the content model should not be empty"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * If the given content data is invalid a ContentException should be thrown | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * @dataProvider                   getContentWithInvalidAttributes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * @expectedException Wambo\Catalog\Error\ContentException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * @expectedExceptionMessageRegExp /The (title|summary text) should not be (shorter|longer) than \d+ characters/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      * @param string $title | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * @param string $summary | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * @param string $description | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     public function getContent_InvalidAttributes_ContentExceptionIsThrown($title, $summary, $description) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         // act | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         new Content($title, $summary, $description); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      * Get a list of valid content data for testing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * @return array | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 58 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |     public static function getValidContentData() | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |         return array( | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |             // normal content | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |             [ | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |                 "A title", | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |                 "A product summary", | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |                 "A detailed product description" | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |             ], | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |             // empty description | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |             [ | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |                 "A title", | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |                 "A product summary", | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |                 "A detailed product description ..." | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |             ], | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |             // long title and summary | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |             [ | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |                 "A looooooooooooooooooooooooooooooooooooooooooooooooong title", | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |                 "ABCdefghijklmnopqrstuvwxyzöüä.ABCdefghijklmnopqrstuvwxyzöüä.ABCdefghijklmnopqrstuvwxyzöüä.ABCdefghijklmnopqrstuvwxyzöüä.", | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |                 "A detailed product description ..." | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |             ] | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      * Get a list of valid content data for testing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     public static function getContentWithInvalidAttributes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |             // title empty | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |             ["", "Summary", "Description..."], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |             // title too long | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |                 "ABCdefghijklmnopqrstuvwxyzöüä.ABCdefghijklmnopqrstuvwxyzöüä.ABCdefghijklmnopqrstuvwxyzöüä.", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |                 "Summary", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |                 "Description..." | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |             // summary empty | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |             ["A title", "", ""], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |             // summary too short | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |             ["A title", "abc", ""], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |             // summary too long | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |                 "A title", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |                 "ABCdefghijklmnopqrstuvwxyzöüä.ABCdefghijklmnopqrstuvwxyzöüä.ABCdefghijklmnopqrstuvwxyzöüä.ABCdefghijklmnopqrstuvwxyzöüä.ABCdefghijklmnopqrstuvwxyzöüä.", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |                 "" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |             ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 118 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 119 |  |  |  | 
            
                        
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.