| Conditions | 1 |
| Paths | 1 |
| Total Lines | 57 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 27 | public function fixtures_are_loaded_properly(): void |
||
| 28 | { |
||
| 29 | $kernel = static::bootKernel(); |
||
| 30 | $container = $kernel->getContainer()->get('test.service_container', ContainerInterface::NULL_ON_INVALID_REFERENCE) ?? $kernel->getContainer(); |
||
| 31 | |||
| 32 | $fixtureRegistry = $container->get(FixtureRegistryInterface::class); |
||
| 33 | $listenerRegistry = $container->get(ListenerRegistryInterface::class); |
||
| 34 | $suiteLoader = $container->get(SuiteLoaderInterface::class); |
||
| 35 | |||
| 36 | $suite = new Suite('test'); |
||
| 37 | $suite->addListener($listenerRegistry->getListener('orm_purger'), ['mode' => 'delete', 'exclude' => [], 'managers' => [null]]); |
||
| 38 | $suite->addFixture($fixtureRegistry->getFixture('locale'), ['locales' => [], 'load_default_locale' => true]); |
||
| 39 | $suite->addFixture($fixtureRegistry->getFixture('taxon'), ['custom' => ['books' => ['name' => 'Books', 'code' => 'BOOKS']]]); |
||
| 40 | $suite->addFixture($fixtureRegistry->getFixture('product_attribute'), ['custom' => [ |
||
| 41 | 'book_author' => ['name' => 'Author', 'code' => 'AUTHOR', 'type' => 'text'], |
||
| 42 | 'book_date' => ['name' => 'Date', 'code' => 'DATE', 'type' => 'date'], |
||
| 43 | 'book_adults_only' => ['name' => 'Adults only', 'code' => 'ADULT', 'type' => 'checkbox'], |
||
| 44 | 'book_pages' => ['name' => 'Pages', 'code' => 'PAGES', 'type' => 'integer'], |
||
| 45 | 'book_cover' => [ |
||
| 46 | 'name' => 'Cover', |
||
| 47 | 'code' => 'COVER', |
||
| 48 | 'type' => 'select', |
||
| 49 | 'configuration' => [ |
||
| 50 | 'choices' => [ |
||
| 51 | 'SOFT' => ['en_US' => 'Soft'], |
||
| 52 | 'HARD' => ['en_US' => 'Hard'], |
||
| 53 | ], |
||
| 54 | ], |
||
| 55 | ], |
||
| 56 | ]]); |
||
| 57 | $suite->addFixture($fixtureRegistry->getFixture('product'), ['custom' => [ |
||
| 58 | 'lotr_fellowship' => [ |
||
| 59 | 'name' => 'The Fellowship of the Ring', |
||
| 60 | 'code' => 'LOTR', |
||
| 61 | 'product_attributes' => [ |
||
| 62 | 'AUTHOR' => 'J.R.R Tolkien', |
||
| 63 | 'DATE' => '19-07-1954', |
||
| 64 | 'ADULT' => false, |
||
| 65 | 'PAGES' => 448, |
||
| 66 | 'COVER' => ['SOFT'], |
||
| 67 | ], |
||
| 68 | ], |
||
| 69 | ]]); |
||
| 70 | |||
| 71 | $suiteLoader->load($suite); |
||
| 72 | |||
| 73 | $productRepository = $container->get('sylius.repository.product'); |
||
| 74 | |||
| 75 | /** @var ProductInterface $product */ |
||
| 76 | $product = $productRepository->findOneByCode('LOTR'); |
||
| 77 | $this->assertNotNull($product); |
||
| 78 | |||
| 79 | $this->assertValueOfAttributeWithCode($product, 'DATE', new \DateTime('19-07-1954')); |
||
| 80 | $this->assertValueOfAttributeWithCode($product, 'ADULT', false); |
||
| 81 | $this->assertValueOfAttributeWithCode($product, 'PAGES', 448); |
||
| 82 | $this->assertValueOfAttributeWithCode($product, 'COVER', ['SOFT']); |
||
| 83 | } |
||
| 84 | |||
| 91 |