diff --git a/migrations/Version20240328095507.php b/migrations/Version20240328105838.php similarity index 77% rename from migrations/Version20240328095507.php rename to migrations/Version20240328105838.php index 67d38f5..25275bb 100644 --- a/migrations/Version20240328095507.php +++ b/migrations/Version20240328105838.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; /** * Auto-generated Migration: Please modify to your needs! */ -final class Version20240328095507 extends AbstractMigration +final class Version20240328105838 extends AbstractMigration { public function getDescription(): string { @@ -21,14 +21,14 @@ final class Version20240328095507 extends AbstractMigration { // this up() migration is auto-generated, please modify it to your needs $this->addSql('CREATE TABLE comment (id INT AUTO_INCREMENT NOT NULL, owner_id INT NOT NULL, posting_id INT NOT NULL, message LONGTEXT NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_9474526C7E3C61F9 (owner_id), INDEX IDX_9474526C9AE985F6 (posting_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE contact (id INT AUTO_INCREMENT NOT NULL, partner_id INT NOT NULL, image_id INT DEFAULT NULL, first_name VARCHAR(255) NOT NULL, last_name VARCHAR(255) NOT NULL, birthday DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', position VARCHAR(255) DEFAULT NULL, phone VARCHAR(255) DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_4C62E6389393F8FE (partner_id), INDEX IDX_4C62E6383DA5256D (image_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE contact (id INT AUTO_INCREMENT NOT NULL, partner_id INT NOT NULL, image_id INT DEFAULT NULL, created_by_id INT NOT NULL, first_name VARCHAR(255) NOT NULL, last_name VARCHAR(255) NOT NULL, birthday DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', position VARCHAR(255) DEFAULT NULL, phone VARCHAR(255) DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_4C62E6389393F8FE (partner_id), INDEX IDX_4C62E6383DA5256D (image_id), INDEX IDX_4C62E638B03A8386 (created_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); $this->addSql('CREATE TABLE document (id INT AUTO_INCREMENT NOT NULL, created_by_id INT NOT NULL, partner_id INT DEFAULT NULL, product_id INT DEFAULT NULL, document_object_id INT NOT NULL, name VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_D8698A76B03A8386 (created_by_id), INDEX IDX_D8698A769393F8FE (partner_id), INDEX IDX_D8698A764584665A (product_id), INDEX IDX_D8698A7631157E8A (document_object_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE document_object (id INT AUTO_INCREMENT NOT NULL, file_path VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE media_object (id INT AUTO_INCREMENT NOT NULL, file_path VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE partner (id INT AUTO_INCREMENT NOT NULL, logo_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, street VARCHAR(255) DEFAULT NULL, street_no VARCHAR(255) DEFAULT NULL, zip VARCHAR(255) DEFAULT NULL, city VARCHAR(255) DEFAULT NULL, country VARCHAR(255) DEFAULT NULL, website VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_312B3E16F98F144A (logo_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE document_object (id INT AUTO_INCREMENT NOT NULL, created_by_id INT NOT NULL, file_path VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_16CF1A8AB03A8386 (created_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE media_object (id INT AUTO_INCREMENT NOT NULL, created_by_id INT NOT NULL, file_path VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_14D43132B03A8386 (created_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE partner (id INT AUTO_INCREMENT NOT NULL, logo_id INT DEFAULT NULL, created_by_id INT NOT NULL, name VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, street VARCHAR(255) DEFAULT NULL, street_no VARCHAR(255) DEFAULT NULL, zip VARCHAR(255) DEFAULT NULL, city VARCHAR(255) DEFAULT NULL, country VARCHAR(255) DEFAULT NULL, website VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_312B3E16F98F144A (logo_id), INDEX IDX_312B3E16B03A8386 (created_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); $this->addSql('CREATE TABLE partner_follow (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, partner_id INT NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_55FFED0BA76ED395 (user_id), INDEX IDX_55FFED0B9393F8FE (partner_id), UNIQUE INDEX unique_follow (user_id, partner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); $this->addSql('CREATE TABLE posting (id INT AUTO_INCREMENT NOT NULL, owner_id INT NOT NULL, partner_id INT NOT NULL, contact_id INT DEFAULT NULL, sale_id INT DEFAULT NULL, headline VARCHAR(255) NOT NULL, message LONGTEXT NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_BD275D737E3C61F9 (owner_id), INDEX IDX_BD275D739393F8FE (partner_id), INDEX IDX_BD275D73E7A1254A (contact_id), INDEX IDX_BD275D734A7E4868 (sale_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE product (id INT AUTO_INCREMENT NOT NULL, image_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_D34A04AD3DA5256D (image_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE product (id INT AUTO_INCREMENT NOT NULL, image_id INT DEFAULT NULL, created_by_id INT NOT NULL, name VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_D34A04AD3DA5256D (image_id), INDEX IDX_D34A04ADB03A8386 (created_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); $this->addSql('CREATE TABLE sale (id INT AUTO_INCREMENT NOT NULL, owner_id INT NOT NULL, partner_id INT NOT NULL, product_id INT NOT NULL, turnover INT NOT NULL, profit INT DEFAULT NULL, comment LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_E54BC0057E3C61F9 (owner_id), INDEX IDX_E54BC0059393F8FE (partner_id), INDEX IDX_E54BC0054584665A (product_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); $this->addSql('CREATE TABLE task (id INT AUTO_INCREMENT NOT NULL, created_by_id INT NOT NULL, assigned_to_id INT NOT NULL, partner_id INT DEFAULT NULL, contact_id INT DEFAULT NULL, headline VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, due_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', prio VARCHAR(255) NOT NULL, completed TINYINT(1) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_527EDB25B03A8386 (created_by_id), INDEX IDX_527EDB25F4BD7827 (assigned_to_id), INDEX IDX_527EDB259393F8FE (partner_id), INDEX IDX_527EDB25E7A1254A (contact_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); $this->addSql('CREATE TABLE task_note (id INT AUTO_INCREMENT NOT NULL, owner_id INT NOT NULL, task_id INT NOT NULL, message LONGTEXT NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_BC0E6E6F7E3C61F9 (owner_id), INDEX IDX_BC0E6E6F8DB60186 (task_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); @@ -37,11 +37,15 @@ final class Version20240328095507 extends AbstractMigration $this->addSql('ALTER TABLE comment ADD CONSTRAINT FK_9474526C9AE985F6 FOREIGN KEY (posting_id) REFERENCES posting (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE contact ADD CONSTRAINT FK_4C62E6389393F8FE FOREIGN KEY (partner_id) REFERENCES partner (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE contact ADD CONSTRAINT FK_4C62E6383DA5256D FOREIGN KEY (image_id) REFERENCES media_object (id) ON DELETE SET NULL'); + $this->addSql('ALTER TABLE contact ADD CONSTRAINT FK_4C62E638B03A8386 FOREIGN KEY (created_by_id) REFERENCES `user` (id)'); $this->addSql('ALTER TABLE document ADD CONSTRAINT FK_D8698A76B03A8386 FOREIGN KEY (created_by_id) REFERENCES `user` (id)'); $this->addSql('ALTER TABLE document ADD CONSTRAINT FK_D8698A769393F8FE FOREIGN KEY (partner_id) REFERENCES partner (id)'); $this->addSql('ALTER TABLE document ADD CONSTRAINT FK_D8698A764584665A FOREIGN KEY (product_id) REFERENCES product (id)'); $this->addSql('ALTER TABLE document ADD CONSTRAINT FK_D8698A7631157E8A FOREIGN KEY (document_object_id) REFERENCES document_object (id)'); + $this->addSql('ALTER TABLE document_object ADD CONSTRAINT FK_16CF1A8AB03A8386 FOREIGN KEY (created_by_id) REFERENCES `user` (id)'); + $this->addSql('ALTER TABLE media_object ADD CONSTRAINT FK_14D43132B03A8386 FOREIGN KEY (created_by_id) REFERENCES `user` (id)'); $this->addSql('ALTER TABLE partner ADD CONSTRAINT FK_312B3E16F98F144A FOREIGN KEY (logo_id) REFERENCES media_object (id) ON DELETE SET NULL'); + $this->addSql('ALTER TABLE partner ADD CONSTRAINT FK_312B3E16B03A8386 FOREIGN KEY (created_by_id) REFERENCES `user` (id)'); $this->addSql('ALTER TABLE partner_follow ADD CONSTRAINT FK_55FFED0BA76ED395 FOREIGN KEY (user_id) REFERENCES `user` (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE partner_follow ADD CONSTRAINT FK_55FFED0B9393F8FE FOREIGN KEY (partner_id) REFERENCES partner (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE posting ADD CONSTRAINT FK_BD275D737E3C61F9 FOREIGN KEY (owner_id) REFERENCES `user` (id) ON DELETE CASCADE'); @@ -49,6 +53,7 @@ final class Version20240328095507 extends AbstractMigration $this->addSql('ALTER TABLE posting ADD CONSTRAINT FK_BD275D73E7A1254A FOREIGN KEY (contact_id) REFERENCES contact (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE posting ADD CONSTRAINT FK_BD275D734A7E4868 FOREIGN KEY (sale_id) REFERENCES sale (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE product ADD CONSTRAINT FK_D34A04AD3DA5256D FOREIGN KEY (image_id) REFERENCES media_object (id) ON DELETE SET NULL'); + $this->addSql('ALTER TABLE product ADD CONSTRAINT FK_D34A04ADB03A8386 FOREIGN KEY (created_by_id) REFERENCES `user` (id)'); $this->addSql('ALTER TABLE sale ADD CONSTRAINT FK_E54BC0057E3C61F9 FOREIGN KEY (owner_id) REFERENCES `user` (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE sale ADD CONSTRAINT FK_E54BC0059393F8FE FOREIGN KEY (partner_id) REFERENCES partner (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE sale ADD CONSTRAINT FK_E54BC0054584665A FOREIGN KEY (product_id) REFERENCES product (id) ON DELETE CASCADE'); @@ -68,11 +73,15 @@ final class Version20240328095507 extends AbstractMigration $this->addSql('ALTER TABLE comment DROP FOREIGN KEY FK_9474526C9AE985F6'); $this->addSql('ALTER TABLE contact DROP FOREIGN KEY FK_4C62E6389393F8FE'); $this->addSql('ALTER TABLE contact DROP FOREIGN KEY FK_4C62E6383DA5256D'); + $this->addSql('ALTER TABLE contact DROP FOREIGN KEY FK_4C62E638B03A8386'); $this->addSql('ALTER TABLE document DROP FOREIGN KEY FK_D8698A76B03A8386'); $this->addSql('ALTER TABLE document DROP FOREIGN KEY FK_D8698A769393F8FE'); $this->addSql('ALTER TABLE document DROP FOREIGN KEY FK_D8698A764584665A'); $this->addSql('ALTER TABLE document DROP FOREIGN KEY FK_D8698A7631157E8A'); + $this->addSql('ALTER TABLE document_object DROP FOREIGN KEY FK_16CF1A8AB03A8386'); + $this->addSql('ALTER TABLE media_object DROP FOREIGN KEY FK_14D43132B03A8386'); $this->addSql('ALTER TABLE partner DROP FOREIGN KEY FK_312B3E16F98F144A'); + $this->addSql('ALTER TABLE partner DROP FOREIGN KEY FK_312B3E16B03A8386'); $this->addSql('ALTER TABLE partner_follow DROP FOREIGN KEY FK_55FFED0BA76ED395'); $this->addSql('ALTER TABLE partner_follow DROP FOREIGN KEY FK_55FFED0B9393F8FE'); $this->addSql('ALTER TABLE posting DROP FOREIGN KEY FK_BD275D737E3C61F9'); @@ -80,6 +89,7 @@ final class Version20240328095507 extends AbstractMigration $this->addSql('ALTER TABLE posting DROP FOREIGN KEY FK_BD275D73E7A1254A'); $this->addSql('ALTER TABLE posting DROP FOREIGN KEY FK_BD275D734A7E4868'); $this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04AD3DA5256D'); + $this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04ADB03A8386'); $this->addSql('ALTER TABLE sale DROP FOREIGN KEY FK_E54BC0057E3C61F9'); $this->addSql('ALTER TABLE sale DROP FOREIGN KEY FK_E54BC0059393F8FE'); $this->addSql('ALTER TABLE sale DROP FOREIGN KEY FK_E54BC0054584665A'); diff --git a/src/ApiResource/ContactApi.php b/src/ApiResource/ContactApi.php index 78b6f9e..3490fda 100644 --- a/src/ApiResource/ContactApi.php +++ b/src/ApiResource/ContactApi.php @@ -34,10 +34,10 @@ use Symfony\Component\Validator\Constraints\NotBlank; security: 'is_granted("ROLE_USER")', ), new Post( - security: 'is_granted("ROLE_ADMIN")', + security: 'is_granted("ROLE_USER")', ), new Patch( - security: 'is_granted("ROLE_ADMIN")', + security: 'is_granted("ROLE_USER")', ), // new Delete( // security: 'is_granted("ROLE_ADMIN")', diff --git a/src/DataFixtures/AppFixtures.php b/src/DataFixtures/AppFixtures.php index c0f7f42..3b67548 100644 --- a/src/DataFixtures/AppFixtures.php +++ b/src/DataFixtures/AppFixtures.php @@ -88,18 +88,21 @@ class AppFixtures extends Fixture PartnerFactory::createMany(100, [ + 'logo' => MediaObjectLogoFactory::random(), 'createdBy' => $adminD ] ); ContactFactory::createMany(200, [ + 'image' => MediaObjectContactFactory::random(), 'createdBy' => $adminD ] ); ProductFactory::createMany(100, [ + 'image' => MediaObjectProductFactory::createOne(), 'createdBy' => $adminD ] ); diff --git a/src/Entity/Contact.php b/src/Entity/Contact.php index bc9137d..65b49a1 100644 --- a/src/Entity/Contact.php +++ b/src/Entity/Contact.php @@ -43,6 +43,7 @@ class Contact #[ORM\Column(length: 255, nullable: true)] private ?string $email = null; + #[ORM\ManyToOne] #[ORM\JoinColumn(nullable: false)] private ?User $createdBy = null; diff --git a/src/Entity/DocumentObject.php b/src/Entity/DocumentObject.php index ccc4c00..255f8c1 100644 --- a/src/Entity/DocumentObject.php +++ b/src/Entity/DocumentObject.php @@ -72,6 +72,7 @@ class DocumentObject #[ORM\Column(nullable: true)] public ?string $filePath = null; + #[ORM\ManyToOne] #[ORM\JoinColumn(nullable: false)] private ?User $createdBy = null; diff --git a/src/Entity/MediaObject.php b/src/Entity/MediaObject.php index fe417db..b18cc8e 100644 --- a/src/Entity/MediaObject.php +++ b/src/Entity/MediaObject.php @@ -72,6 +72,7 @@ class MediaObject #[ORM\Column(nullable: true)] public ?string $filePath = null; + #[ORM\ManyToOne] #[ORM\JoinColumn(nullable: false)] private ?User $createdBy = null; diff --git a/src/Entity/Partner.php b/src/Entity/Partner.php index 934b975..ece57a8 100644 --- a/src/Entity/Partner.php +++ b/src/Entity/Partner.php @@ -44,10 +44,11 @@ class Partner #[ORM\Column(length: 255, nullable: true)] private ?string $website = null; - #[ORM\ManyToOne(targetEntity: MediaObject::class)] + #[ORM\ManyToOne] #[ORM\JoinColumn(nullable: true, onDelete: "SET NULL")] private ?MediaObject $logo = null; + #[ORM\ManyToOne] #[ORM\JoinColumn(nullable: false)] private ?User $createdBy = null; diff --git a/src/Entity/Product.php b/src/Entity/Product.php index 8a450f1..f16a495 100644 --- a/src/Entity/Product.php +++ b/src/Entity/Product.php @@ -26,6 +26,7 @@ class Product #[ORM\JoinColumn(nullable: true, onDelete: "SET NULL")] private ?MediaObject $image = null; + #[ORM\ManyToOne] #[ORM\JoinColumn(nullable: false)] private ?User $createdBy = null; diff --git a/src/Factory/ContactFactory.php b/src/Factory/ContactFactory.php index 736e960..12bfff6 100644 --- a/src/Factory/ContactFactory.php +++ b/src/Factory/ContactFactory.php @@ -55,7 +55,6 @@ final class ContactFactory extends ModelFactory 'phone' => self::faker()->phoneNumber(), 'email' => self::faker()->email(), 'partner' => PartnerFactory::random(), - 'image' => MediaObjectContactFactory::random(), 'createdBy' => UserFactory::random() ]; } diff --git a/src/Factory/PartnerFactory.php b/src/Factory/PartnerFactory.php index e557b29..b4bafa0 100644 --- a/src/Factory/PartnerFactory.php +++ b/src/Factory/PartnerFactory.php @@ -58,7 +58,6 @@ final class PartnerFactory extends ModelFactory 'zip' => self::faker()->numberBetween(1000,10000), 'city' => self::faker()->randomElement(FakeValues::CITIES), 'country' => self::faker()->randomElement(FakeValues::COUNTRIES), - 'logo' => MediaObjectLogoFactory::random(), 'website' => 'https://spawntree.de/', 'createdBy' => UserFactory::random() ]; diff --git a/src/Factory/ProductFactory.php b/src/Factory/ProductFactory.php index 912a7e4..e7ff6de 100644 --- a/src/Factory/ProductFactory.php +++ b/src/Factory/ProductFactory.php @@ -50,7 +50,6 @@ final class ProductFactory extends ModelFactory return [ 'name' => self::faker()->randomElement(FakeValues::PRODUCTS), 'description' => self::faker()->text(), - 'image' => MediaObjectProductFactory::createOne(), 'createdBy' => UserFactory::random() ]; } diff --git a/tests/Functional/CommentResourceTest.php b/tests/Functional/CommentResourceTest.php index 7356ef5..eb51a9e 100644 --- a/tests/Functional/CommentResourceTest.php +++ b/tests/Functional/CommentResourceTest.php @@ -39,7 +39,6 @@ class CommentResourceTest extends KernelTestCase public function testPostComment(): void { - MediaObjectUserFactory::createOne(); $user = UserFactory::createOne( [ 'firstName' => 'Peter', @@ -48,7 +47,6 @@ class CommentResourceTest extends KernelTestCase 'email' => 'peter@test.de', ] ); - MediaObjectLogoFactory::createOne(); ProductFactory::createOne(); PartnerFactory::createOne(); SaleFactory::createOne(); diff --git a/tests/Functional/ContactResourceTest.php b/tests/Functional/ContactResourceTest.php index 78fe28a..8d94a28 100644 --- a/tests/Functional/ContactResourceTest.php +++ b/tests/Functional/ContactResourceTest.php @@ -33,8 +33,7 @@ class ContactResourceTest extends KernelTestCase public function testPostContact(): void { - MediaObjectLogoFactory::createOne(); - $partner = PartnerFactory::createOne(); + $user = UserFactory::createOne( [ 'firstName' => 'Peter', @@ -43,6 +42,7 @@ class ContactResourceTest extends KernelTestCase 'email' => 'peter@test.de', ] ); + $partner = PartnerFactory::createOne(); $mediaObject = MediaObjectContactFactory::createOne(); diff --git a/tests/Functional/DocumentObjectResourceTest.php b/tests/Functional/DocumentObjectResourceTest.php index a4c9581..185020a 100644 --- a/tests/Functional/DocumentObjectResourceTest.php +++ b/tests/Functional/DocumentObjectResourceTest.php @@ -46,7 +46,6 @@ class DocumentObjectResourceTest extends KernelTestCase $file = new UploadedFile($dstFile, 'image.png'); - MediaObjectUserFactory::createOne(); $user = UserFactory::createOne( [ 'firstName' => 'Peter', @@ -112,7 +111,6 @@ class DocumentObjectResourceTest extends KernelTestCase public function testDeleteDocumentObject() { - $mediaObject = MediaObjectLogoFactory::createOne(); $user = UserFactory::createOne( [ 'firstName' => 'Peter', diff --git a/tests/Functional/DocumentResourceTest.php b/tests/Functional/DocumentResourceTest.php index 0ebb82a..e22bed8 100644 --- a/tests/Functional/DocumentResourceTest.php +++ b/tests/Functional/DocumentResourceTest.php @@ -41,7 +41,6 @@ class DocumentResourceTest extends KernelTestCase public function testCreateDocument(): void { - MediaObjectUserFactory::createOne(); $user = UserFactory::createOne( [ 'firstName' => 'Peter', @@ -50,8 +49,6 @@ class DocumentResourceTest extends KernelTestCase 'email' => 'peter@test.de', ] ); - MediaObjectLogoFactory::createOne(); - MediaObjectProductFactory::createOne(); $partner = PartnerFactory::createOne(); $product = ProductFactory::createOne(); $documentObject = DocumentObjectFactory::createOne(); @@ -84,31 +81,30 @@ class DocumentResourceTest extends KernelTestCase ; } - public function testDeleteDocument() - { - MediaObjectUserFactory::createOne(); - $user = UserFactory::createOne( - [ - 'firstName' => 'Peter', - 'lastName' => 'Test', - 'password' => 'test', - 'email' => 'peter@test.de', - 'roles' => ["ROLE_ADMIN"] - ] - ); - $token = $this->JWTManager->create($user->object()); - DocumentObjectFactory::createOne(); - PartnerFactory::createOne(); - ProductFactory::createOne(); - $document = DocumentFactory::createOne(); - - $this->browser() - ->delete('/api/documents/' . $document->getId(), [ - 'headers' => [ - 'Authorization' => 'Bearer ' . $token, - ], - ]) - ->assertSuccessful() - ; - } +// public function testDeleteDocument() +// { +// $user = UserFactory::createOne( +// [ +// 'firstName' => 'Peter', +// 'lastName' => 'Test', +// 'password' => 'test', +// 'email' => 'peter@test.de', +// 'roles' => ["ROLE_ADMIN"] +// ] +// ); +// $token = $this->JWTManager->create($user->object()); +// DocumentObjectFactory::createOne(); +// PartnerFactory::createOne(); +// ProductFactory::createOne(); +// $document = DocumentFactory::createOne(); +// +// $this->browser() +// ->delete('/api/documents/' . $document->getId(), [ +// 'headers' => [ +// 'Authorization' => 'Bearer ' . $token, +// ], +// ]) +// ->assertSuccessful() +// ; +// } } diff --git a/tests/Functional/MediaObjectResourceTest.php b/tests/Functional/MediaObjectResourceTest.php index 490b6c9..da27f0e 100644 --- a/tests/Functional/MediaObjectResourceTest.php +++ b/tests/Functional/MediaObjectResourceTest.php @@ -43,13 +43,13 @@ class MediaObjectResourceTest extends KernelTestCase $file = new UploadedFile($dstFile, 'image.png'); - MediaObjectUserFactory::createOne(); $user = UserFactory::createOne( [ 'firstName' => 'Peter', 'lastName' => 'Test', 'password' => 'test', 'email' => 'peter@test.de', + 'roles' => ["ROLE_ADMIN"] ] ); $token = $this->JWTManager->create($user->object()); @@ -104,8 +104,6 @@ class MediaObjectResourceTest extends KernelTestCase public function testDeleteMediaObject() { - MediaObjectUserFactory::createOne(); - $mediaObject = MediaObjectLogoFactory::createOne(); $user = UserFactory::createOne( [ 'firstName' => 'Peter', @@ -114,6 +112,7 @@ class MediaObjectResourceTest extends KernelTestCase 'email' => 'peter@test.de', ] ); + $mediaObject = MediaObjectLogoFactory::createOne(); $token = $this->JWTManager->create($user->object()); $this->browser() ->delete('/api/media_objects/' . $mediaObject->getId(), [ diff --git a/tests/Functional/PartnerFollowResourceTest.php b/tests/Functional/PartnerFollowResourceTest.php index 6c1e28c..b689373 100644 --- a/tests/Functional/PartnerFollowResourceTest.php +++ b/tests/Functional/PartnerFollowResourceTest.php @@ -34,7 +34,6 @@ class PartnerFollowResourceTest extends KernelTestCase public function testPostPartnerFollow(): void { - MediaObjectUserFactory::createOne(); $user = UserFactory::createOne( [ 'firstName' => 'Peter', @@ -43,23 +42,10 @@ class PartnerFollowResourceTest extends KernelTestCase 'email' => 'peter@test.de', ] ); - MediaObjectLogoFactory::createOne(); $partner = PartnerFactory::createOne(); - PartnerFollowFactory::createOne(); $token = $this->JWTManager->create($user->object()); - $this->browser() - ->get('/api/partner_follows', [ - 'headers' => [ - 'Authorization' => 'Bearer ' . $token, - ], - ]) - ->assertSuccessful() - ->assertJsonMatches('"hydra:totalItems"', 1) - ; - - $this->browser() ->post('/api/partner_follows' , [ 'json' => [ @@ -79,7 +65,7 @@ class PartnerFollowResourceTest extends KernelTestCase ], ]) ->assertSuccessful() - ->assertJsonMatches('"hydra:totalItems"', 2) + ->assertJsonMatches('"hydra:totalItems"', 1) ; } } \ No newline at end of file diff --git a/tests/Functional/PartnerResourceTest.php b/tests/Functional/PartnerResourceTest.php index 52bd544..a293134 100644 --- a/tests/Functional/PartnerResourceTest.php +++ b/tests/Functional/PartnerResourceTest.php @@ -36,13 +36,13 @@ class PartnerResourceTest extends KernelTestCase public function testPostPartner(): void { - MediaObjectUserFactory::createOne(); $user = UserFactory::createOne( [ 'email' => 'peter@test.de', 'firstName' => 'Peter', 'lastName' => 'Test', 'password' => 'test', + 'roles' => ["ROLE_ADMIN"] ] ); diff --git a/tests/Functional/PostingResourceTest.php b/tests/Functional/PostingResourceTest.php index c04c1a5..b1a1cc3 100644 --- a/tests/Functional/PostingResourceTest.php +++ b/tests/Functional/PostingResourceTest.php @@ -38,7 +38,6 @@ class PostingResourceTest extends KernelTestCase public function testPostPosting(): void { - MediaObjectUserFactory::createOne(); $user = UserFactory::createOne( [ 'email' => 'peter@test.de', @@ -48,8 +47,6 @@ class PostingResourceTest extends KernelTestCase ] ); - MediaObjectContactFactory::createOne(); - MediaObjectLogoFactory::createOne(); $partner = PartnerFactory::createOne(); $contact = ContactFactory::createOne(); ProductFactory::createOne(); diff --git a/tests/Functional/ProductResourceTest.php b/tests/Functional/ProductResourceTest.php index dd0a994..6588f06 100644 --- a/tests/Functional/ProductResourceTest.php +++ b/tests/Functional/ProductResourceTest.php @@ -32,13 +32,13 @@ class ProductResourceTest extends KernelTestCase public function testPostProduct(): void { - MediaObjectUserFactory::createOne(); $user = UserFactory::createOne( [ 'email' => 'peter@test.de', 'firstName' => 'Peter', 'lastName' => 'Test', 'password' => 'test', + 'roles' => ["ROLE_ADMIN"] ] ); diff --git a/tests/Functional/TaskNoteResourceTest.php b/tests/Functional/TaskNoteResourceTest.php index 891a419..013720d 100644 --- a/tests/Functional/TaskNoteResourceTest.php +++ b/tests/Functional/TaskNoteResourceTest.php @@ -39,7 +39,6 @@ class TaskNoteResourceTest extends KernelTestCase public function testPostTaskNote(): void { - MediaObjectUserFactory::createOne(); $user = UserFactory::createOne( [ 'firstName' => 'Peter', diff --git a/tests/Functional/TaskResourceTest.php b/tests/Functional/TaskResourceTest.php index 9c9c38f..a111c49 100644 --- a/tests/Functional/TaskResourceTest.php +++ b/tests/Functional/TaskResourceTest.php @@ -38,7 +38,6 @@ class TaskResourceTest extends KernelTestCase public function testPostTask(): void { - MediaObjectUserFactory::createOne(); $user = UserFactory::createOne( [ 'firstName' => 'Peter', diff --git a/tests/Functional/UserResourceTest.php b/tests/Functional/UserResourceTest.php index 2f256e4..9194a25 100644 --- a/tests/Functional/UserResourceTest.php +++ b/tests/Functional/UserResourceTest.php @@ -32,7 +32,6 @@ class UserResourceTest extends KernelTestCase public function testPostUser(): void { - MediaObjectUserFactory::createOne(); UserFactory::createOne( [ 'email' => 'peter@test.de', @@ -90,7 +89,6 @@ class UserResourceTest extends KernelTestCase public function testPostUserNoAdmin(): void { - MediaObjectUserFactory::createOne(); $user = UserFactory::createOne( [ 'email' => 'peter@test.de', diff --git a/tests/fixtures/1176_upload.png b/tests/fixtures/1176_upload.png deleted file mode 100644 index 54a8ef6..0000000 Binary files a/tests/fixtures/1176_upload.png and /dev/null differ