-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[make:factory] Problems with --test
flag
#786
Comments
Hi @tomasnorre Yeah this sounds like a bug! |
I'm haven't really looked into the code base. But I can see if I can come up with a PR, unless you know exactly where to dig in and solve it fast ;) |
yes, PR welcome, thanks! I think there are two problems:
|
--test
flag
Thanks for your pointers. I have fork the repository, but getting quite a number of errors when running the tests. I'll look into that first, I don't want to start of with failing tests. |
The tests are passing on branch have a look into the readme for some insights in order to contribute. Using docker for the database helps a lot :) For the tests about maker, you can use |
usually, I have this MONGO_URL="" # disable mongo related tests
PHPUNIT_VERSION="11" # enable phpunit 11
USE_DAMA_DOCTRINE_TEST_BUNDLE="1" # enable dama |
I have following: ╰─❯ php -v
PHP 8.3.15 (cli) (built: Dec 24 2024 06:10:28) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.15, Copyright (c) Zend Technologies
with Zend OPcache v8.3.15, Copyright (c), by Zend Technologies
with Xdebug v3.4.0, Copyright (c) 2002-2024, by Derick Rethans Example when running tests, with the $ docker compose up -d
$ ./phpunit
vendor/bin/phpunit -c phpunit-10.xml.dist --extension Zenstruck\Foundry\Tests\Fixture\DoctrineCascadeRelationship\PhpUnitTestExtension --extension DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension
PHPUnit 11.5.3 by Sebastian Bergmann and contributors.
Runtime: PHP 8.3.15
Configuration: /home/tomas/Projects/opensource/zenstruck-foundry/phpunit-10.xml.dist
..SSSSFF.FFF.F.....SS.SFFFFFFFFFFF....................I...... 61 / 1144 ( 5%)
............................................................. 122 / 1144 ( 10%)
............................................................. 183 / 1144 ( 15%)
............................................................. 244 / 1144 ( 21%)
............................................................. 305 / 1144 ( 26%)
............................................................. 366 / 1144 ( 31%)
............................................................. 427 / 1144 ( 37%)
............................................................. 488 / 1144 ( 42%)
............................................................. 549 / 1144 ( 47%)
............................................................. 610 / 1144 ( 53%)
............................................................. 671 / 1144 ( 58%)
............................................................. 732 / 1144 ( 63%)
............................................................. 793 / 1144 ( 69%)
............................................................. 854 / 1144 ( 74%)
............................................................. 915 / 1144 ( 79%)
............................................................. 976 / 1144 ( 85%)
............................................................. 1037 / 1144 ( 90%)
.......I.....
Time: 00:19.476, Memory: 58.50 MB
There were 17 failures:
1) Zenstruck\Foundry\Tests\Integration\Maker\MakeFactoryTest::can_create_factory
File "/home/tomas/Projects/opensource/zenstruck-foundry/tests/Integration/Maker/../../Fixture/Maker/tmp/src/Factory/CategoryFactory.php" is different from expected file "/home/tomas/Projects/opensource/zenstruck-foundry/tests/Fixture/Maker/expected/can_create_factory.php".
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
'<?php\n
\n
-/*\n
- * This file is part of the zenstruck/foundry package.\n
- *\n
- * (c) Kevin Bond <kevinbond@gmail.com>\n
- *\n
- * For the full copyright and license information, please view the LICENSE\n
- * file that was distributed with this source code.\n
- */\n
-\n
namespace App\Factory;\n
\n
+use Doctrine\ORM\EntityRepository;\n
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;\n
+use Zenstruck\Foundry\Persistence\Proxy;\n
+use Zenstruck\Foundry\Persistence\ProxyRepositoryDecorator;\n
use Zenstruck\Foundry\Tests\Fixture\Entity\Category;\n
\n
/**\n
* @extends PersistentProxyObjectFactory<Category>\n
*/\n
-final class CategoryFactory extends PersistentProxyObjectFactory\n
-{\n
+final class CategoryFactory extends PersistentProxyObjectFactory{\n
/**\n
* @see htt...'
/home/tomas/Projects/opensource/zenstruck-foundry/tests/Integration/Maker/MakerTestCase.php:59
/home/tomas/Projects/opensource/zenstruck-foundry/tests/Integration/Maker/MakeFactoryTest.php:75 |
When running.
And I'm on 2.x branch. Up to date with the main repository. I have tried with PHP 8.2, 8.3 and 8.4, all same result. |
yeah it seems that the problem comes from the last symfony/maker version released yesterday, some changes around php-cs-fixer seem to have been made... |
Thanks a lot. That solved it for me. I'll see if I can come up with a fix, or as minimum a test that proves the problem. |
Possibly related? symfony/maker-bundle#1651 |
The maker-bundle stuff should be fixed, just run |
The updated maker-bundle works for me in the tests now. |
I'm honestly know sure, if I'm misunderstanding something, doing it wrong or it a bug.
Lets say I have the entity setup from documentation. https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#same-entities-used-in-these-docs
A post and a comment.
If I create factories with the
bin/console make:factory --test Post
flag it complains that theCommentFactory
is not present and as if it should create it for me. If I said yes, it creates it's in thesrc/Factory
directory even if I use the--test
flag.If it's already is created in
tests/Facoty
is still complains that it's not present as it looks for it insrc/Factory/CommentFactory.php
but when I answer yes to create if fails, as it's already created.Is this something that I misunderstand from concept or is this a bug?
Thanks for your help.
The text was updated successfully, but these errors were encountered: