InitCommandTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Test\Command;
  12. use Composer\Command\InitCommand;
  13. use Composer\TestCase;
  14. class InitCommandTest extends TestCase
  15. {
  16. public function testParseValidAuthorString()
  17. {
  18. $command = new InitCommand;
  19. $author = $command->parseAuthorString('John Smith <john@example.com>');
  20. $this->assertEquals('John Smith', $author['name']);
  21. $this->assertEquals('john@example.com', $author['email']);
  22. }
  23. public function testParseValidUtf8AuthorString()
  24. {
  25. $command = new InitCommand;
  26. $author = $command->parseAuthorString('Matti Meikäläinen <matti@example.com>');
  27. $this->assertEquals('Matti Meikäläinen', $author['name']);
  28. $this->assertEquals('matti@example.com', $author['email']);
  29. }
  30. public function testParseEmptyAuthorString()
  31. {
  32. $command = new InitCommand;
  33. $this->setExpectedException('InvalidArgumentException');
  34. $command->parseAuthorString('');
  35. }
  36. public function testParseAuthorStringWithInvalidEmail()
  37. {
  38. $command = new InitCommand;
  39. $this->setExpectedException('InvalidArgumentException');
  40. $command->parseAuthorString('John Smith <john>');
  41. }
  42. }