You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LazyCompletePackageTest.php 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /*
  3. * This file is part of the Fxp Composer Asset Plugin package.
  4. *
  5. * (c) François Pluchino <francois.pluchino@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Fxp\Composer\AssetPlugin\Tests\Package;
  11. use Composer\Package\CompletePackage;
  12. use Fxp\Composer\AssetPlugin\Package\LazyCompletePackage;
  13. use Fxp\Composer\AssetPlugin\Package\LazyPackageInterface;
  14. use Fxp\Composer\AssetPlugin\Package\Loader\LazyLoaderInterface;
  15. /**
  16. * Tests of lazy asset package loader.
  17. *
  18. * @author François Pluchino <francois.pluchino@gmail.com>
  19. */
  20. class LazyCompletePackageTest extends \PHPUnit_Framework_TestCase
  21. {
  22. /**
  23. * @var LazyPackageInterface
  24. */
  25. protected $package;
  26. protected function setUp()
  27. {
  28. $this->package = new LazyCompletePackage('foo', '1.0.0.0', '1.0');
  29. }
  30. protected function tearDown()
  31. {
  32. $this->package = null;
  33. }
  34. public function getConfigLazyLoader()
  35. {
  36. return array(
  37. array(null),
  38. array('lazy'),
  39. array('lazy-exception'),
  40. );
  41. }
  42. /**
  43. * @param string $lazyType
  44. *
  45. * @dataProvider getConfigLazyLoader
  46. */
  47. public function testMissingAssetType($lazyType)
  48. {
  49. if (null !== $lazyType) {
  50. $lp = 'lazy' === $lazyType
  51. ? new CompletePackage($this->package->getName(),
  52. $this->package->getVersion(), $this->package->getPrettyVersion())
  53. : false;
  54. $loader = $this->getMock('Fxp\Composer\AssetPlugin\Package\Loader\LazyLoaderInterface');
  55. $loader
  56. ->expects($this->any())
  57. ->method('load')
  58. ->will($this->returnValue($lp));
  59. /* @var LazyLoaderInterface$loader */
  60. $this->package->setLoader($loader);
  61. }
  62. $this->assertSame('library', $this->package->getType());
  63. $this->assertSame(array(), $this->package->getTransportOptions());
  64. $this->assertNull($this->package->getTargetDir());
  65. $this->assertSame(array(), $this->package->getExtra());
  66. $this->assertSame(array(), $this->package->getBinaries());
  67. $this->assertNull($this->package->getInstallationSource());
  68. $this->assertNull($this->package->getSourceType());
  69. $this->assertNull($this->package->getSourceUrl());
  70. $this->assertNull($this->package->getSourceReference());
  71. $this->assertNull($this->package->getSourceMirrors());
  72. $this->assertSame(array(), $this->package->getSourceUrls());
  73. $this->assertNull($this->package->getDistType());
  74. $this->assertNull($this->package->getDistUrl());
  75. $this->assertNull($this->package->getDistReference());
  76. $this->assertNull($this->package->getDistSha1Checksum());
  77. $this->assertNull($this->package->getDistMirrors());
  78. $this->assertSame(array(), $this->package->getDistUrls());
  79. $this->assertNull($this->package->getReleaseDate());
  80. $this->assertSame(array(), $this->package->getRequires());
  81. $this->assertSame(array(), $this->package->getConflicts());
  82. $this->assertSame(array(), $this->package->getProvides());
  83. $this->assertSame(array(), $this->package->getReplaces());
  84. $this->assertSame(array(), $this->package->getDevRequires());
  85. $this->assertSame(array(), $this->package->getSuggests());
  86. $this->assertSame(array(), $this->package->getAutoload());
  87. $this->assertSame(array(), $this->package->getDevAutoload());
  88. $this->assertSame(array(), $this->package->getIncludePaths());
  89. $this->assertNull($this->package->getNotificationUrl());
  90. $this->assertSame(array(), $this->package->getArchiveExcludes());
  91. $this->assertSame(array(), $this->package->getScripts());
  92. $this->assertNull($this->package->getRepositories());
  93. $this->assertSame(array(), $this->package->getLicense());
  94. $this->assertNull($this->package->getKeywords());
  95. $this->assertNull($this->package->getAuthors());
  96. $this->assertNull($this->package->getDescription());
  97. $this->assertNull($this->package->getHomepage());
  98. $this->assertSame(array(), $this->package->getSupport());
  99. }
  100. }