Esempio n. 1
0
 /**
  * Test validation in the setters
  */
 public function testFaultyProperties()
 {
     try {
         new Messaging(str_repeat('a', 10), 'NL');
     } catch (\Exception $e) {
         $this->assertInstanceOf('TijsVerkoyen\\Bpost\\Exception', $e);
         $this->assertEquals(sprintf('Invalid value, possible values are: %1$s.', implode(', ', Messaging::getPossibleTypeValues())), $e->getMessage());
     }
     try {
         new Messaging('infoDistributed', str_repeat('a', 10));
     } catch (\Exception $e) {
         $this->assertInstanceOf('TijsVerkoyen\\Bpost\\Exception', $e);
         $this->assertEquals(sprintf('Invalid value, possible values are: %1$s.', implode(', ', Messaging::getPossibleLanguageValues())), $e->getMessage());
     }
     try {
         new Messaging('infoDistributed', 'NL', str_repeat('a', 51));
     } catch (\Exception $e) {
         $this->assertInstanceOf('TijsVerkoyen\\Bpost\\Exception', $e);
         $this->assertEquals('Invalid length, maximum is 50.', $e->getMessage());
     }
     try {
         new Messaging('infoDistributed', 'NL', null, str_repeat('a', 21));
     } catch (\Exception $e) {
         $this->assertInstanceOf('TijsVerkoyen\\Bpost\\Exception', $e);
         $this->assertEquals('Invalid length, maximum is 20.', $e->getMessage());
     }
 }