InitCommandTest.php 866 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace Composer\Test\Command;
  3. use Composer\Command\InitCommand;
  4. use Composer\Test\TestCase;
  5. class InitCommandTest extends TestCase
  6. {
  7. function testParseValidAuthorString()
  8. {
  9. $command = new InitCommand;
  10. $author = $command->parseAuthorString('John Smith <john@example.com>');
  11. $this->assertEquals('John Smith', $author['name']);
  12. $this->assertEquals('john@example.com', $author['email']);
  13. }
  14. function testParseEmptyAuthorString()
  15. {
  16. $command = new InitCommand;
  17. $this->setExpectedException('InvalidArgumentException');
  18. $command->parseAuthorString('');
  19. }
  20. function testParseAuthorStringWithInvalidEmail()
  21. {
  22. $command = new InitCommand;
  23. $this->setExpectedException('InvalidArgumentException');
  24. $command->parseAuthorString('John Smith <john>');
  25. }
  26. }