BaseTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. use PHPUnit\Framework\TestCase;
  3. use Docker\Composer\FileFormat2;
  4. use Symfony\Component\Yaml\Yaml;
  5. require __DIR__."/../vendor/autoload.php";
  6. class BaseTest extends TestCase
  7. {
  8. public function testSimpleUsage()
  9. {
  10. $composer = new FileFormat2();
  11. $composer->addService("Base")->image("ubuntu:16.10");
  12. $composer->addService("Ftth")->image("ubuntu:17.10");
  13. $composer->addService("ubuntu")->image("ubuntu");
  14. $composer->addService("custom")->build("./custom");
  15. $composer->addService("test1")->build("./custom1")->addVolumes('volumen_test1_test2', '/opt/test1');
  16. $composer->addService("test2")->build("./custom2")->addVolumes('volumen_test1_test2', '/opt/test2');
  17. $composer->getVolumes()->addVolumen('volumen_test1_test2', 'local');
  18. $rtr = Yaml::parse($composer->render());
  19. $this->assertEquals(
  20. array (
  21. "version"=> "2.2",
  22. "services" => array (
  23. "Base" => array("image" => "ubuntu:16.10"),
  24. "Ftth" => array ( "image" => "ubuntu:17.10"),
  25. "ubuntu" => array ( "image" => "ubuntu"),
  26. "custom" => array ( "build" => array("context" => "./custom")),
  27. "test1" => array ( "build" => array("context" => "./custom1"),"volumes" => array('volumen_test1_test2:/opt/test1')),
  28. "test2" => array ( "build" => array("context" => "./custom2"),"volumes" => array('volumen_test1_test2:/opt/test2')),
  29. ),
  30. "volumes" => array('volumen_test1_test2' => array('driver' => 'local'))
  31. ), $rtr);
  32. }
  33. }