InitCommandTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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\Test\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 testParseEmptyAuthorString()
  24. {
  25. $command = new InitCommand;
  26. $this->setExpectedException('InvalidArgumentException');
  27. $command->parseAuthorString('');
  28. }
  29. public function testParseAuthorStringWithInvalidEmail()
  30. {
  31. $command = new InitCommand;
  32. $this->setExpectedException('InvalidArgumentException');
  33. $command->parseAuthorString('John Smith <john>');
  34. }
  35. }