| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | namespace AlgoWeb\xsdTypes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * Generated Test Class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | class xsYearMonthDurationTest extends \PHPUnit_Framework_TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |      * Sets up the fixture, for example, opens a network connection. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |      * This method is called before a test is executed. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     protected function setUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |         parent::setUp(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      * Tears down the fixture, for example, closes a network connection. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      * This method is called after a test is executed. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     protected function tearDown() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         parent::tearDown(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |          * @dataProvider testXsYearMonthDurationValidDataProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     public function testXsYearMonthDurationValid($duration, $message) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         $d = new xsYearMonthDuration($duration); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         $e = (string)$d; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         $this->assertEquals($duration,$e,$message); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     public function testXsYearMonthDurationValidDataProvider() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |             array('P2Y6M', '2 years, 6 months'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |             array('P20M', '20 months (the number of months can be more than 12)'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             array('P0Y20M', '20 months (0 is permitted as a number, but is not required)'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |             array('P0Y', '0 years'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |             array('-P60Y', 'minus 60 years'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      * @dataProvider testXsYearMonthDurationInvalidDataProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     public function testXsYearMonthDurationInvalid($duration, $message) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |             $d = new xsYearMonthDuration($duration); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |             $e = (string)$d; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |             $this->fail($message); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             $this->assertEquals('',$e,$message); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 58 |  |  |     public function testXsYearMonthDurationInvalidDataProvider() { | 
            
                                                        
            
                                    
            
            
                | 59 |  |  |         return array( | 
            
                                                        
            
                                    
            
            
                | 60 |  |  |             array('P2Y6M5DT12H35M30S', 'components other than years or months are not allowed'), | 
            
                                                        
            
                                    
            
            
                | 61 |  |  |             array('P-20M', 'the minus sign must appear first'), | 
            
                                                        
            
                                    
            
            
                | 62 |  |  |             array('P20MT', '"T" must not be present'), | 
            
                                                        
            
                                    
            
            
                | 63 |  |  |             array('P1YM', 'no value is specified for months, so "M" must not be present'), | 
            
                                                        
            
                                    
            
            
                | 64 |  |  |             array('-P15.5Y', 'numbers cannot be expressed as a decimal'), | 
            
                                                        
            
                                    
            
            
                | 65 |  |  |             array('1Y2M', '"P" must always be present'), | 
            
                                                        
            
                                    
            
            
                | 66 |  |  |             array('P2M1Y', 'years must appear before months'), | 
            
                                                        
            
                                    
            
            
                | 67 |  |  |             array('P', 'at least one number and designator are required'), | 
            
                                                        
            
                                    
            
            
                | 68 |  |  |             array('', 'an empty value is not valid, unless xsi:nil is used'), | 
            
                                                        
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 70 |  |  |         ); | 
            
                                                        
            
                                    
            
            
                | 71 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 72 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 73 |  |  |  |