mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-18 13:10:08 -07:00
Add ZipService tests, Add ApplicationAvailabilityTest
This commit is contained in:
parent
31889a95da
commit
6685658a89
@ -33,7 +33,9 @@
|
|||||||
<span class="truncate-multiline"><small>{{ model.name }}</small></span>
|
<span class="truncate-multiline"><small>{{ model.name }}</small></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<span><small>{{ model.category.name }}</small></span>
|
{% if model.category is not null %}
|
||||||
|
<span><small>{{ model.category.name }}</small></span>
|
||||||
|
{% endif %}
|
||||||
{% if quantity %}<span class="right floated">{{ quantity }}x</span>{% endif %}
|
{% if quantity %}<span class="right floated">{{ quantity }}x</span>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -71,7 +73,9 @@
|
|||||||
<div class="meta">
|
<div class="meta">
|
||||||
<span class="left floated">{{ set.id }}</span>
|
<span class="left floated">{{ set.id }}</span>
|
||||||
<br>
|
<br>
|
||||||
<span title="{{ set.theme.fullName }}" class="left floated truncate"><small>{{ set.theme.fullName }}</small></span>
|
{% if set.theme is not null %}
|
||||||
|
<span title="{{ set.theme.fullName }}" class="left floated truncate"><small>{{ set.theme.fullName }}</small></span>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<small>
|
<small>
|
||||||
|
@ -39,7 +39,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ 'set.theme' | trans }}</td>
|
<td>{{ 'set.theme' | trans }}</td>
|
||||||
<td><a href="{{ path('set_index',{'theme' : set.theme.id }) }}">{{ set.theme ? set.theme.fullName }}</a></td>
|
<td>
|
||||||
|
{% if set.theme is not null %}
|
||||||
|
<a href="{{ path('set_index',{'theme' : set.theme.id }) }}">{{ set.theme ? set.theme.fullName }}</a>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ 'set.parts' | trans }}</td><td>
|
<td>{{ 'set.parts' | trans }}</td><td>
|
||||||
|
@ -3,6 +3,7 @@ fos_elastica:
|
|||||||
default: { host: '%elastica_host%', port: '%elastica_port%', logger: true }
|
default: { host: '%elastica_host%', port: '%elastica_port%', logger: true }
|
||||||
indexes:
|
indexes:
|
||||||
app:
|
app:
|
||||||
|
index_name: app_%kernel.environment%
|
||||||
settings:
|
settings:
|
||||||
index:
|
index:
|
||||||
analysis:
|
analysis:
|
||||||
|
@ -48,6 +48,14 @@ class Inventory_Part
|
|||||||
*/
|
*/
|
||||||
protected $inventory;
|
protected $inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $quantity
|
||||||
|
*/
|
||||||
|
public function setQuantity($quantity)
|
||||||
|
{
|
||||||
|
$this->quantity = $quantity;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get count.
|
* Get count.
|
||||||
*
|
*
|
||||||
|
@ -35,6 +35,18 @@ class SetService
|
|||||||
$this->inventorySetRepository = $em->getRepository(Inventory_Set::class);
|
$this->inventorySetRepository = $em->getRepository(Inventory_Set::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find set by id
|
||||||
|
*
|
||||||
|
* @param $id
|
||||||
|
*
|
||||||
|
* @return Set
|
||||||
|
*/
|
||||||
|
public function findSet($id)
|
||||||
|
{
|
||||||
|
return $this->setRepository->find($id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all sets in the set inventory.
|
* Get all sets in the set inventory.
|
||||||
*
|
*
|
||||||
|
@ -117,7 +117,7 @@ class ZipService
|
|||||||
* @param Set $set
|
* @param Set $set
|
||||||
* @param bool $spare If true - add only spare parts, false - add only regular parts, null - add all parts
|
* @param bool $spare If true - add only spare parts, false - add only regular parts, null - add all parts
|
||||||
*/
|
*/
|
||||||
public function addSetGroupedByColor(Set $set, $spare = null)
|
private function addSetGroupedByColor(Set $set, $spare = null)
|
||||||
{
|
{
|
||||||
$colors = $this->setService->getModelsGroupedByColor($set, $spare);
|
$colors = $this->setService->getModelsGroupedByColor($set, $spare);
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ class ZipService
|
|||||||
* @param Set $set
|
* @param Set $set
|
||||||
* @param bool $spare If true - add only spare parts, false - add only regular parts, null - add all parts
|
* @param bool $spare If true - add only spare parts, false - add only regular parts, null - add all parts
|
||||||
*/
|
*/
|
||||||
public function addSet(Set $set, $spare = null)
|
private function addSet(Set $set, $spare = null)
|
||||||
{
|
{
|
||||||
$models = $this->setService->getModels($set, $spare);
|
$models = $this->setService->getModels($set, $spare);
|
||||||
|
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\AppBundle;
|
|
||||||
|
|
||||||
use Tests\AppBundle\Fixtures\LoadBaseData;
|
|
||||||
|
|
||||||
class ApplicationAvailabilityTest extends BaseTest
|
|
||||||
{
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
|
||||||
$this->setUpDb();
|
|
||||||
|
|
||||||
$this->loadFixtures([
|
|
||||||
LoadBaseData::class
|
|
||||||
]);
|
|
||||||
|
|
||||||
parent::setUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider urlProvider
|
|
||||||
*/
|
|
||||||
public function testPageIsSuccessful($url)
|
|
||||||
{
|
|
||||||
$client = $this->makeClient();
|
|
||||||
$client->request('GET', $url);
|
|
||||||
|
|
||||||
$this->assertTrue( $client->getResponse()->isSuccessful());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function urlProvider()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
array('/'),
|
|
||||||
array('/models')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -13,27 +13,22 @@ use Symfony\Component\HttpKernel\KernelInterface;
|
|||||||
|
|
||||||
abstract class BaseTest extends WebTestCase
|
abstract class BaseTest extends WebTestCase
|
||||||
{
|
{
|
||||||
protected $_container;
|
|
||||||
|
|
||||||
/* @var FilesystemInterface $filesystem */
|
/* @var FilesystemInterface $filesystem */
|
||||||
protected $filesystem;
|
protected $filesystem;
|
||||||
|
|
||||||
/** @var EntityManagerInterface */
|
/** @var EntityManagerInterface */
|
||||||
protected $em;
|
protected $em;
|
||||||
|
|
||||||
public function __construct()
|
public function setUp()
|
||||||
{
|
{
|
||||||
self::bootKernel();
|
|
||||||
$this->_container = self::$kernel->getContainer();
|
|
||||||
$this->filesystem = $this->get('oneup_flysystem.media_filesystem');
|
$this->filesystem = $this->get('oneup_flysystem.media_filesystem');
|
||||||
$this->em = $this->get('doctrine.orm.entity_manager');
|
$this->em = $this->get('doctrine.orm.entity_manager');
|
||||||
parent::__construct();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUpDb()
|
public function setUpDb()
|
||||||
{
|
{
|
||||||
// Make sure we are in the test environment
|
// Make sure we are in the test environment
|
||||||
if ('test' !== self::$kernel->getEnvironment()) {
|
if ('test' !== $this->get('kernel')->getEnvironment()) {
|
||||||
throw new \LogicException('setUpDb must be executed in the test environment');
|
throw new \LogicException('setUpDb must be executed in the test environment');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,11 +40,11 @@ abstract class BaseTest extends WebTestCase
|
|||||||
|
|
||||||
protected function get($service)
|
protected function get($service)
|
||||||
{
|
{
|
||||||
return $this->_container->get($service);
|
return $this->getContainer()->get($service);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getParameter($parameter)
|
protected function getParameter($parameter)
|
||||||
{
|
{
|
||||||
return $this->_container->getParameter($parameter);
|
return $this->getContainer()->getParameter($parameter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
36
tests/AppBundle/Controller/ApplicationAvailabilityTest.php
Normal file
36
tests/AppBundle/Controller/ApplicationAvailabilityTest.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\AppBundle;
|
||||||
|
|
||||||
|
use Tests\AppBundle\Controller\BaseControllerTest;
|
||||||
|
|
||||||
|
class ApplicationAvailabilityTest extends BaseControllerTest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @dataProvider urlProvider
|
||||||
|
*/
|
||||||
|
public function testPageIsSuccessful($url) {
|
||||||
|
$client = static::createClient();
|
||||||
|
|
||||||
|
$client->request('GET', $url);
|
||||||
|
|
||||||
|
$this->assertTrue( $client->getResponse()->isSuccessful());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function urlProvider()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('/'),
|
||||||
|
array('/colors/'),
|
||||||
|
array('/bricks/'),
|
||||||
|
array('/bricks/1'),
|
||||||
|
array('/bricks/1/sets'),
|
||||||
|
array('/sets/'),
|
||||||
|
array('/sets/8049-1'),
|
||||||
|
array('/sets/8049-1/inventory'),
|
||||||
|
array('/sets/8049-1/models'),
|
||||||
|
array('/sets/8049-1/colors'),
|
||||||
|
array('/parts/1')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
19
tests/AppBundle/Controller/BaseControllerTest.php
Normal file
19
tests/AppBundle/Controller/BaseControllerTest.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\AppBundle\Controller;
|
||||||
|
|
||||||
|
use Liip\FunctionalTestBundle\Test\WebTestCase;
|
||||||
|
use Tests\AppBundle\Fixtures\LoadBaseData;
|
||||||
|
|
||||||
|
abstract class BaseControllerTest extends WebTestCase
|
||||||
|
{
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
// If you are using the Doctrine Fixtures Bundle you could load these here
|
||||||
|
$this->loadFixtures([
|
||||||
|
LoadBaseData::class
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->runCommand('fos:elastica:populate');
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: hubnedav
|
|
||||||
* Date: 8.6.17
|
|
||||||
* Time: 16:05
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Tests\AppBundle\Controller;
|
|
||||||
|
|
||||||
|
|
||||||
class DefaultControllerTest
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@ -6,6 +6,10 @@ namespace Tests\AppBundle\Fixtures;
|
|||||||
use AppBundle\Entity\Color;
|
use AppBundle\Entity\Color;
|
||||||
use AppBundle\Entity\LDraw\Author;
|
use AppBundle\Entity\LDraw\Author;
|
||||||
use AppBundle\Entity\LDraw\Model;
|
use AppBundle\Entity\LDraw\Model;
|
||||||
|
use AppBundle\Entity\Rebrickable\Inventory;
|
||||||
|
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
||||||
|
use AppBundle\Entity\Rebrickable\Part;
|
||||||
|
use AppBundle\Entity\Rebrickable\Set;
|
||||||
use Doctrine\Common\DataFixtures\FixtureInterface;
|
use Doctrine\Common\DataFixtures\FixtureInterface;
|
||||||
use Doctrine\Common\Persistence\ObjectManager;
|
use Doctrine\Common\Persistence\ObjectManager;
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||||
@ -25,17 +29,54 @@ class LoadBaseData implements FixtureInterface, ContainerAwareInterface
|
|||||||
|
|
||||||
public function load(ObjectManager $manager)
|
public function load(ObjectManager $manager)
|
||||||
{
|
{
|
||||||
|
// Add sample author
|
||||||
$author = new Author();
|
$author = new Author();
|
||||||
$author->setName('Author');
|
$author->setName('Author');
|
||||||
|
$manager->persist($author);
|
||||||
|
|
||||||
|
// Add sample model
|
||||||
$model = new Model();
|
$model = new Model();
|
||||||
$model->setId(1);
|
$model->setId(1);
|
||||||
$model->setAuthor($author);
|
$model->setAuthor($author);
|
||||||
$model->setModified(new \DateTime());
|
$model->setModified(new \DateTime());
|
||||||
$model->setName('Name');
|
$model->setName('Name');
|
||||||
|
$model->setPath('models/1.stl');
|
||||||
$manager->persist($model);
|
$manager->persist($model);
|
||||||
|
|
||||||
|
// Add sample part
|
||||||
|
$part = new Part();
|
||||||
|
$part->setId(1);
|
||||||
|
$part->setName('Name');
|
||||||
|
$part->setModel($model);
|
||||||
|
$manager->persist($part);
|
||||||
|
|
||||||
|
$set = new Set();
|
||||||
|
$set->setName('Set');
|
||||||
|
$set->setId('8049-1');
|
||||||
|
$set->setPartCount(1);
|
||||||
|
$set->setYear(2011);
|
||||||
|
$manager->persist($set);
|
||||||
|
|
||||||
|
$color = new Color();
|
||||||
|
$color->setId(1);
|
||||||
|
$color->setName('Black');
|
||||||
|
$color->setRgb('000000');
|
||||||
|
$color->setTransparent(false);
|
||||||
|
$manager->persist($color);
|
||||||
|
|
||||||
|
$inventory = new Inventory();
|
||||||
|
$inventory->setSet($set);
|
||||||
|
$inventory->setVersion(1);
|
||||||
|
$manager->persist($inventory);
|
||||||
|
|
||||||
|
$inventoryPart = new Inventory_Part();
|
||||||
|
$inventoryPart->setColor($color);
|
||||||
|
$inventoryPart->setQuantity(5);
|
||||||
|
$inventoryPart->setPart($part);
|
||||||
|
$inventoryPart->setInventory($inventory);
|
||||||
|
$inventoryPart->setSpare(false);
|
||||||
|
$manager->persist($inventoryPart);
|
||||||
|
|
||||||
$manager->flush();
|
$manager->flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
BIN
tests/AppBundle/Fixtures/models/1.stl
Normal file
BIN
tests/AppBundle/Fixtures/models/1.stl
Normal file
Binary file not shown.
@ -29,8 +29,10 @@ class ModelLoaderTest extends BaseTest
|
|||||||
/** @var AliasRepository */
|
/** @var AliasRepository */
|
||||||
private $aliasRepository;
|
private $aliasRepository;
|
||||||
|
|
||||||
protected function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
$this->modelRepository = $this->em->getRepository(Model::class);
|
$this->modelRepository = $this->em->getRepository(Model::class);
|
||||||
$this->aliasRepository = $this->em->getRepository(Alias::class);
|
$this->aliasRepository = $this->em->getRepository(Alias::class);
|
||||||
|
|
@ -16,6 +16,8 @@ class StlConverterTest extends BaseTest
|
|||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
$ldview = $this->getParameter('ldview_bin');
|
$ldview = $this->getParameter('ldview_bin');
|
||||||
|
|
||||||
$stlFixer = $this->createMock(StlFixerService::class);
|
$stlFixer = $this->createMock(StlFixerService::class);
|
||||||
@ -26,11 +28,11 @@ class StlConverterTest extends BaseTest
|
|||||||
|
|
||||||
public function testConvertToStl()
|
public function testConvertToStl()
|
||||||
{
|
{
|
||||||
$adapter = new Local(__DIR__.'/fixtures/ldraw');
|
$adapter = new Local(__DIR__ . '/fixtures/ldraw');
|
||||||
$ldrawLibraryContext = new Filesystem($adapter);
|
$ldrawLibraryContext = new Filesystem($adapter);
|
||||||
$this->stlConverter->setLDrawLibraryContext($ldrawLibraryContext);
|
$this->stlConverter->setLDrawLibraryContext($ldrawLibraryContext);
|
||||||
|
|
||||||
$this->assertNotNull($this->stlConverter->datToStl(__DIR__.'/fixtures/ldraw/parts/983.dat'));
|
$this->assertNotNull($this->stlConverter->datToStl(__DIR__ . '/fixtures/ldraw/parts/983.dat'));
|
||||||
|
|
||||||
$this->assertTrue($this->filesystem->has('models/983.stl'));
|
$this->assertTrue($this->filesystem->has('models/983.stl'));
|
||||||
|
|
||||||
@ -42,16 +44,16 @@ class StlConverterTest extends BaseTest
|
|||||||
*/
|
*/
|
||||||
public function testLDContextMissing()
|
public function testLDContextMissing()
|
||||||
{
|
{
|
||||||
$this->stlConverter->datToStl(__DIR__.'/fixtures/ldraw/parts/983.dat');
|
$this->stlConverter->datToStl(__DIR__ . '/fixtures/ldraw/parts/983.dat');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConvertToPng()
|
public function testConvertToPng()
|
||||||
{
|
{
|
||||||
$adapter = new Local(__DIR__.'/fixtures/ldraw');
|
$adapter = new Local(__DIR__ . '/fixtures/ldraw');
|
||||||
$ldrawLibraryContext = new Filesystem($adapter);
|
$ldrawLibraryContext = new Filesystem($adapter);
|
||||||
$this->stlConverter->setLDrawLibraryContext($ldrawLibraryContext);
|
$this->stlConverter->setLDrawLibraryContext($ldrawLibraryContext);
|
||||||
|
|
||||||
$this->assertNotNull($this->stlConverter->datToPng(__DIR__.'/fixtures/ldraw/parts/983.dat'));
|
$this->assertNotNull($this->stlConverter->datToPng(__DIR__ . '/fixtures/ldraw/parts/983.dat'));
|
||||||
|
|
||||||
$this->assertTrue($this->filesystem->has('images/983.png'));
|
$this->assertTrue($this->filesystem->has('images/983.png'));
|
||||||
|
|
@ -21,8 +21,10 @@ class StlFixer extends BaseTest
|
|||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
$this->stlFixer = new StlFixerService($this->getParameter('admesh_bin'));
|
$this->stlFixer = new StlFixerService($this->getParameter('admesh_bin'));
|
||||||
$this->input = __DIR__.'/fixtures/ascii.stl';
|
$this->input = __DIR__ . '/fixtures/ascii.stl';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
public function tearDown()
|
@ -20,7 +20,9 @@ class StlRendererTest extends BaseTest
|
|||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$layout = $this->get('kernel')->getRootDir().'/Resources/povray_layout/layout.tmpl';
|
parent::setUp();
|
||||||
|
|
||||||
|
$layout = __DIR__ . '/fixtures/layout.tmpl';
|
||||||
$povray = $this->getParameter('povray_bin');
|
$povray = $this->getParameter('povray_bin');
|
||||||
$stl2pov = $this->getParameter('stl2pov_bin');
|
$stl2pov = $this->getParameter('stl2pov_bin');
|
||||||
|
|
||||||
@ -34,7 +36,7 @@ class StlRendererTest extends BaseTest
|
|||||||
|
|
||||||
public function testRendering()
|
public function testRendering()
|
||||||
{
|
{
|
||||||
$this->stlRenderer->render(__DIR__.'/fixtures/973c00.stl',$this->filesystem->getAdapter()->getPathPrefix());
|
$this->stlRenderer->render(__DIR__ . '/fixtures/973c00.stl',$this->filesystem->getAdapter()->getPathPrefix());
|
||||||
$this->assertTrue($this->filesystem->has('973c00.png'));
|
$this->assertTrue($this->filesystem->has('973c00.png'));
|
||||||
}
|
}
|
||||||
}
|
}
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
52
tests/AppBundle/Service/Stl/StlRenderer/fixtures/layout.tmpl
Normal file
52
tests/AppBundle/Service/Stl/StlRenderer/fixtures/layout.tmpl
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#declare main_mesh = m_MYSOLID;
|
||||||
|
#include "math.inc"
|
||||||
|
#include "finish.inc"
|
||||||
|
#include "transforms.inc"
|
||||||
|
#include "colors.inc"
|
||||||
|
|
||||||
|
background {color rgb 1}
|
||||||
|
|
||||||
|
light_source { <-10,-15,15> color White }
|
||||||
|
light_source { <-11,-4,10> color White }
|
||||||
|
light_source { <-10,14,20> color White }
|
||||||
|
|
||||||
|
|
||||||
|
global_settings {
|
||||||
|
assumed_gamma 2.1
|
||||||
|
}
|
||||||
|
|
||||||
|
#declare Min = min_extent( main_mesh );
|
||||||
|
#declare Max = max_extent( main_mesh );
|
||||||
|
|
||||||
|
#declare MaxLength = max(
|
||||||
|
Max.x-Min.x,
|
||||||
|
Max.y-Min.y,
|
||||||
|
Max.z-Min.z
|
||||||
|
);
|
||||||
|
|
||||||
|
// Calculate camera distace factor - if object is large on Y axis and Z axis move the camera further
|
||||||
|
#declare cameraDistance = (((Max.y-Min.y)*(1/MaxLength) > 0.3) & ((Max.z-Min.z)*(1/MaxLength) > 0.95) ? 1: 0.9);
|
||||||
|
|
||||||
|
camera
|
||||||
|
{
|
||||||
|
location <-1.5*cameraDistance, -1*cameraDistance, 1.1*cameraDistance>
|
||||||
|
angle 45
|
||||||
|
sky z
|
||||||
|
look_at 0
|
||||||
|
translate <0,0.05,-0.15>
|
||||||
|
right -1*x
|
||||||
|
}
|
||||||
|
|
||||||
|
object
|
||||||
|
{
|
||||||
|
main_mesh
|
||||||
|
Center_Trans(main_mesh, x+y+z)
|
||||||
|
|
||||||
|
texture
|
||||||
|
{
|
||||||
|
pigment{ color rgb<0, 0.34, 0.6> }
|
||||||
|
finish { phong .51}
|
||||||
|
}
|
||||||
|
scale (1/MaxLength)
|
||||||
|
}
|
||||||
|
|
60
tests/AppBundle/Service/ZipServiceTest.php
Normal file
60
tests/AppBundle/Service/ZipServiceTest.php
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\AppBundle\Service;
|
||||||
|
|
||||||
|
use AppBundle\Service\ModelService;
|
||||||
|
use AppBundle\Service\SetService;
|
||||||
|
use AppBundle\Service\ZipService;
|
||||||
|
use Tests\AppBundle\BaseTest;
|
||||||
|
use Tests\AppBundle\Fixtures\LoadBaseData;
|
||||||
|
|
||||||
|
class ZipServiceTest extends BaseTest
|
||||||
|
{
|
||||||
|
/** @var ZipService */
|
||||||
|
private $zipService;
|
||||||
|
|
||||||
|
/** @var ModelService */
|
||||||
|
private $modelService;
|
||||||
|
|
||||||
|
/** @var SetService */
|
||||||
|
private $setService;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->loadFixtures([
|
||||||
|
LoadBaseData::class
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->modelService = $this->get(ModelService::class);
|
||||||
|
$this->setService = $this->get(SetService::class);
|
||||||
|
|
||||||
|
$this->filesystem->write('models/1.stl',file_get_contents(__DIR__.'/../Fixtures/models/1.stl'));
|
||||||
|
|
||||||
|
$this->zipService = new ZipService($this->filesystem,$this->modelService,$this->setService);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tearDown()
|
||||||
|
{
|
||||||
|
$this->filesystem->delete('models/1.stl');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testModelZip()
|
||||||
|
{
|
||||||
|
$model = $this->modelService->findModel(1);
|
||||||
|
|
||||||
|
$path = $this->zipService->createFromModel($model, 'modelzip');
|
||||||
|
|
||||||
|
$this->assertFileExists($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetZip()
|
||||||
|
{
|
||||||
|
$set = $this->setService->findSet('8049-1');
|
||||||
|
|
||||||
|
$path = $this->zipService->createFromSet($set, 'setzip');
|
||||||
|
|
||||||
|
$this->assertFileExists($path);
|
||||||
|
}
|
||||||
|
}
|
@ -22,7 +22,7 @@ class LDModelParserTest extends TestCase
|
|||||||
|
|
||||||
public function testValid()
|
public function testValid()
|
||||||
{
|
{
|
||||||
$resource = file_get_contents(__DIR__.'/fixtures/valid.dat');
|
$resource = file_get_contents(__DIR__ . '/fixtures/valid.dat');
|
||||||
|
|
||||||
$array = [
|
$array = [
|
||||||
"id" => "1234",
|
"id" => "1234",
|
||||||
@ -53,13 +53,13 @@ class LDModelParserTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalid()
|
public function testInvalid()
|
||||||
{
|
{
|
||||||
$resource = file_get_contents(__DIR__.'/fixtures/invalid.dat');
|
$resource = file_get_contents(__DIR__ . '/fixtures/invalid.dat');
|
||||||
|
|
||||||
$this->parser->parse($resource);
|
$this->parser->parse($resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testStickers() {
|
public function testStickers() {
|
||||||
$resource = file_get_contents(__DIR__.'/fixtures/stickers.txt');
|
$resource = file_get_contents(__DIR__ . '/fixtures/stickers.txt');
|
||||||
|
|
||||||
foreach (preg_split('/^---DAT/m', $resource) as $dat) {
|
foreach (preg_split('/^---DAT/m', $resource) as $dat) {
|
||||||
$this->assertEquals('Sticker', $this->parser->parse($dat)['type']);
|
$this->assertEquals('Sticker', $this->parser->parse($dat)['type']);
|
||||||
@ -68,7 +68,7 @@ class LDModelParserTest extends TestCase
|
|||||||
|
|
||||||
public function testAlias()
|
public function testAlias()
|
||||||
{
|
{
|
||||||
$resource = file_get_contents(__DIR__.'/fixtures/alias.txt');
|
$resource = file_get_contents(__DIR__ . '/fixtures/alias.txt');
|
||||||
|
|
||||||
foreach (preg_split('/^---DAT/m', $resource) as $dat) {
|
foreach (preg_split('/^---DAT/m', $resource) as $dat) {
|
||||||
$this->assertEquals('parent', $this->parser->parse($dat)['parent']);
|
$this->assertEquals('parent', $this->parser->parse($dat)['parent']);
|
@ -13,7 +13,7 @@ class RelationMapperTest extends TestCase
|
|||||||
public function testLoad()
|
public function testLoad()
|
||||||
{
|
{
|
||||||
$mapper = new RelationMapper(new ArrayCache());
|
$mapper = new RelationMapper(new ArrayCache());
|
||||||
$mapper->loadResource(__DIR__.'/fixtures/resources.yml', 'resources');
|
$mapper->loadResource(__DIR__ . '/fixtures/resources.yml', 'resources');
|
||||||
|
|
||||||
$this->assertEquals('bar', $mapper->find('foo','resources'));
|
$this->assertEquals('bar', $mapper->find('foo','resources'));
|
||||||
$this->assertEquals('bar', $mapper->find('bar','resources'));
|
$this->assertEquals('bar', $mapper->find('bar','resources'));
|
||||||
@ -35,7 +35,7 @@ class RelationMapperTest extends TestCase
|
|||||||
public function testLoadInvalidResource()
|
public function testLoadInvalidResource()
|
||||||
{
|
{
|
||||||
$mapper = new RelationMapper(new ArrayCache());
|
$mapper = new RelationMapper(new ArrayCache());
|
||||||
$resource = __DIR__.'/fixtures/invalid.yml';
|
$resource = __DIR__ . '/fixtures/invalid.yml';
|
||||||
$mapper->loadResource($resource, 'resources');
|
$mapper->loadResource($resource, 'resources');
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\AppBundle\Service;
|
|
||||||
|
|
||||||
use Tests\AppBundle\BaseTest;
|
|
||||||
|
|
||||||
class ZipServiceTest extends BaseTest
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user