LockLoaderTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Fgm\ComposerCheck\Tests;
  3. use Fgm\ComposerCheck\LockLoader;
  4. /**
  5. * Class TestLoader allows faking the composer.lock file contents.
  6. */
  7. class TestLoader extends LockLoader {
  8. public function __construct(string $directory) {
  9. }
  10. public function setData($data) {
  11. $this->contents['packages'] = $data['packages'];
  12. $this->contents['packages-dev'] = $data['packages-dev'];
  13. $this->contents['platform'] = $data['platform'];
  14. }
  15. }
  16. /**
  17. * Class LockLoaderTest
  18. *
  19. * @coversDefaultClass Fgm\ComposerCheck\LockLoader
  20. */
  21. class LockLoaderTest extends \PHPUnit_Framework_TestCase {
  22. /**
  23. * @return array $lock
  24. * An array of simplified versions of lock data.
  25. */
  26. public function lockParsingProvider() {
  27. return [
  28. [[
  29. 'packages' => [
  30. 'r1' => 'R1',
  31. ],
  32. 'packages-dev' => [
  33. 'd1' => 'D1',
  34. ],
  35. 'platform' => [
  36. 'p1' => 'P1',
  37. ],
  38. ]],
  39. ];
  40. }
  41. /**
  42. * @dataProvider lockParsingProvider
  43. */
  44. public function testLockParsing($lockData) {
  45. $loader = new TestLoader("");
  46. $loader->setData($lockData);
  47. $loader->parse();
  48. $actualRun = $loader->getRun();
  49. $actualDev = $loader->getDev();
  50. }
  51. }