partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

MetaPartTest.php (2072B)


      1 <?php
      2 
      3 namespace PartKeepr\PartBundle\Tests;
      4 
      5 use Doctrine\Common\DataFixtures\ProxyReferenceRepository;
      6 use PartKeepr\CoreBundle\Tests\WebTestCase;
      7 use PartKeepr\PartBundle\Entity\Part;
      8 
      9 class MetaPartTest extends WebTestCase
     10 {
     11     /**
     12      * @var ProxyReferenceRepository
     13      */
     14     protected $fixtures;
     15 
     16     public function setUp()
     17     {
     18         $this->fixtures = $this->loadFixtures(
     19             [
     20                 'PartKeepr\StorageLocationBundle\DataFixtures\CategoryDataLoader',
     21                 'PartKeepr\StorageLocationBundle\DataFixtures\StorageLocationLoader',
     22                 'PartKeepr\PartBundle\DataFixtures\CategoryDataLoader',
     23                 'PartKeepr\PartBundle\DataFixtures\PartDataLoader',
     24                 'PartKeepr\ManufacturerBundle\Tests\DataFixtures\ManufacturerDataLoader',
     25                 'PartKeepr\DistributorBundle\Tests\DataFixtures\DistributorDataLoader',
     26             ]
     27         )->getReferenceRepository();
     28     }
     29 
     30     public function testMetaPartMatching()
     31     {
     32         /**
     33          * @var Part $metaPart1
     34          */
     35         $metaPart1 = $this->fixtures->getReference("metapart.1");
     36         $metaSourcePart1 = $this->fixtures->getReference("metapart.source.1");
     37         $metaSourcePart2 = $this->fixtures->getReference("metapart.source.2");
     38         $metaSourcePart3 = $this->fixtures->getReference("metapart.source.3");
     39 
     40         $matches = $this->getContainer()->get("partkeepr.part_service")->getMatchingMetaParts($metaPart1);
     41 
     42         $this->assertContains($metaSourcePart1, $matches);
     43         $this->assertContains($metaSourcePart2, $matches);
     44         $this->assertNotContains($metaSourcePart3, $matches);
     45 
     46         /**
     47          * @var Part $metaPart2
     48          */
     49         $metaPart2 = $this->fixtures->getReference("metapart.2");
     50 
     51         $matches2 = $this->getContainer()->get("partkeepr.part_service")->getMatchingMetaParts($metaPart2);
     52 
     53         $this->assertNotContains($metaSourcePart1, $matches2);
     54         $this->assertContains($metaSourcePart2, $matches2);
     55         $this->assertNotContains($metaSourcePart3, $matches2);
     56     }
     57 }