diff --git a/src/Controller/ScanController.php b/src/Controller/ScanController.php index c4eb9a8b..3d4ce484 100644 --- a/src/Controller/ScanController.php +++ b/src/Controller/ScanController.php @@ -47,7 +47,7 @@ class ScanController extends AbstractController } /** - * @Route("/", name="scan_dialog") + * @Route("", name="scan_dialog") */ public function dialog(Request $request): Response { diff --git a/src/DataFixtures/GroupFixtures.php b/src/DataFixtures/GroupFixtures.php index 9707ab6a..5ab20e71 100644 --- a/src/DataFixtures/GroupFixtures.php +++ b/src/DataFixtures/GroupFixtures.php @@ -82,8 +82,8 @@ class GroupFixtures extends Fixture 'suppliers' => 5461, 'manufacturers' => 5461, 'attachment_types' => 1365, - 'tools' => 1365, - 'labels' => 21, + 'tools' => 87381, + 'labels' => 87381, 'parts_category' => 5, 'parts_minamount' => 5, 'parts_lots' => 85, @@ -125,8 +125,8 @@ class GroupFixtures extends Fixture 'suppliers' => 1705, 'manufacturers' => 1705, 'attachment_types' => 681, - 'tools' => 1366, - 'labels' => 165, + 'tools' => 87382, + 'labels' => 173737, 'parts_category' => 9, 'parts_minamount' => 9, 'parts_lots' => 169, @@ -168,8 +168,8 @@ class GroupFixtures extends Fixture 'suppliers' => 5461, 'manufacturers' => 5461, 'attachment_types' => 1365, - 'tools' => 1365, - 'labels' => 85, + 'tools' => 87381, + 'labels' => 91477, 'parts_category' => 5, 'parts_minamount' => 5, 'parts_lots' => 85, diff --git a/src/DataFixtures/LabelProfileFixtures.php b/src/DataFixtures/LabelProfileFixtures.php new file mode 100644 index 00000000..fa1a72b4 --- /dev/null +++ b/src/DataFixtures/LabelProfileFixtures.php @@ -0,0 +1,96 @@ +. + */ + +namespace App\DataFixtures; + + +use App\Entity\LabelSystem\LabelOptions; +use App\Entity\LabelSystem\LabelProfile; +use Doctrine\Bundle\FixturesBundle\Fixture; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Persistence\ObjectManager; + +class LabelProfileFixtures extends Fixture +{ + + protected $em; + + public function __construct(EntityManagerInterface $entityManager) + { + $this->em = $entityManager; + } + + public function load(ObjectManager $manager) + { + $this->em->getConnection()->exec("ALTER TABLE `label_profiles` AUTO_INCREMENT = 1;"); + + $profile1 = new LabelProfile(); + $profile1->setName('Profile 1'); + $profile1->setShowInDropdown(true); + + $option1 = new LabelOptions(); + $option1->setLines("[[NAME]]\n[[DESCRIPION]]"); + $option1->setBarcodeType('none'); + $option1->setSupportedElement('part'); + $profile1->setOptions($option1); + + $manager->persist($profile1); + + $profile2 = new LabelProfile(); + $profile2->setName('Profile 2'); + $profile2->setShowInDropdown(false); + + $option2 = new LabelOptions(); + $option2->setLines("[[NAME]]\n[[DESCRIPION]]"); + $option2->setBarcodeType('qr'); + $option2->setSupportedElement('part'); + $profile2->setOptions($option2); + + $manager->persist($profile2); + + $profile3 = new LabelProfile(); + $profile3->setName('Profile 3'); + $profile3->setShowInDropdown(true); + + $option3 = new LabelOptions(); + $option3->setLines("[[NAME]]\n[[DESCRIPION]]"); + $option3->setBarcodeType('code128'); + $option3->setSupportedElement('part_lot'); + $profile3->setOptions($option3); + + $manager->persist($profile3); + + + $profile4 = new LabelProfile(); + $profile4->setName('Profile 4'); + $profile4->setShowInDropdown(true); + + $option4 = new LabelOptions(); + $option4->setLines("{{ element.name }}"); + $option4->setBarcodeType('code39'); + $option4->setSupportedElement('part'); + $option4->setLinesMode('twig'); + $profile4->setOptions($option4); + + $manager->persist($profile4); + + $manager->flush(); + } +} \ No newline at end of file diff --git a/src/Entity/LabelSystem/LabelProfile.php b/src/Entity/LabelSystem/LabelProfile.php index f2a0884d..0311e64b 100644 --- a/src/Entity/LabelSystem/LabelProfile.php +++ b/src/Entity/LabelSystem/LabelProfile.php @@ -73,6 +73,12 @@ class LabelProfile extends AttachmentContainingDBElement return $this->options; } + public function setOptions(LabelOptions $labelOptions): LabelProfile + { + $this->options = $labelOptions; + return $this; + } + /** * Get the comment of the element. * @return string the comment diff --git a/tests/ApplicationAvailabilityFunctionalTest.php b/tests/ApplicationAvailabilityFunctionalTest.php index 824db532..96181216 100644 --- a/tests/ApplicationAvailabilityFunctionalTest.php +++ b/tests/ApplicationAvailabilityFunctionalTest.php @@ -119,5 +119,12 @@ class ApplicationAvailabilityFunctionalTest extends WebTestCase //Typeahead yield ['/typeahead/builtInResources/search/DIP8']; yield ['/typeahead/tags/search/test']; + + //Label test + yield ['/scan']; + yield ['/label/dialog']; + yield ['/label/dialog?target_id=1&target_type=part']; + yield ['/label/1/dialog']; + yield ['/label/1/dialog?target_id=1&target_type=part&generate=1']; } } diff --git a/tests/Controller/AdminPages/LabelProfileControllerTest.php b/tests/Controller/AdminPages/LabelProfileControllerTest.php new file mode 100644 index 00000000..37328046 --- /dev/null +++ b/tests/Controller/AdminPages/LabelProfileControllerTest.php @@ -0,0 +1,58 @@ +. + */ + +namespace App\Tests\Controller\AdminPages; + + +use App\Entity\LabelSystem\LabelProfile; +use Symfony\Component\Security\Core\Exception\AccessDeniedException; + +class LabelProfileControllerTest extends AbstractAdminControllerTest +{ + protected static $base_path = '/en'.'/label_profile'; + protected static $entity_class = LabelProfile::class; + + /** + * Tests if deleting an entity is working. + * + * @group slow + * @dataProvider deleteDataProvider + */ + public function testDeleteEntity(string $user, bool $delete): void + { + //Test read access + $client = static::createClient([], [ + 'PHP_AUTH_USER' => $user, + 'PHP_AUTH_PW' => 'test', + ]); + + $client->catchExceptions(false); + if (false === $delete) { + $this->expectException(AccessDeniedException::class); + } + + //Test read/list access by access /new overview page + $client->request('DELETE', static::$base_path.'/3'); + + //Page is redirected to '/new', when delete was successful + $this->assertSame($delete, $client->getResponse()->isRedirect(static::$base_path.'/new')); + $this->assertSame($delete, ! $client->getResponse()->isForbidden(), 'Permission Checking not working!'); + } +} \ No newline at end of file