1515
1616use Doctrine \Common \Collections \ArrayCollection ;
1717use Doctrine \Common \Collections \Collection ;
18+ use Doctrine \Common \Comparable ;
1819use PhpSpec \ObjectBehavior ;
1920use Sylius \Component \Core \Model \ChannelInterface ;
2021use Sylius \Component \Core \Model \ChannelPricingInterface ;
2122use Sylius \Component \Core \Model \Product ;
2223use Sylius \Component \Core \Model \ProductImageInterface ;
2324use Sylius \Component \Core \Model \ProductImagesAwareInterface ;
25+ use Sylius \Component \Core \Model \ProductVariant ;
2426use Sylius \Component \Core \Model \ProductVariantInterface ;
2527use Sylius \Component \Product \Model \ProductVariant as BaseProductVariant ;
2628use Sylius \Component \Resource \Model \VersionedInterface ;
@@ -41,6 +43,11 @@ function it_implements_a_taxable_interface(): void
4143 $ this ->shouldImplement (TaxableInterface::class);
4244 }
4345
46+ function it_implements_doctrine_comparable (): void
47+ {
48+ $ this ->shouldImplement (Comparable::class);
49+ }
50+
4451 function it_extends_a_product_variant_model (): void
4552 {
4653 $ this ->shouldHaveType (BaseProductVariant::class);
@@ -273,4 +280,16 @@ function it_returns_images_by_type(ProductImageInterface $image, Product $produc
273280 $ this ->addImage ($ image );
274281 $ this ->getImagesByType ('thumbnail ' )->shouldBeLike (new ArrayCollection ([$ image ->getWrappedObject ()]));
275282 }
283+
284+ function it_is_comparable (): void
285+ {
286+ $ this ->setCode ('test ' );
287+
288+ $ otherTaxon = new ProductVariant ();
289+ $ otherTaxon ->setCode ('test ' );
290+ $ this ->compareTo ($ otherTaxon )->shouldReturn (0 );
291+
292+ $ otherTaxon ->setCode ('other ' );
293+ $ this ->compareTo ($ otherTaxon )->shouldReturn (1 );
294+ }
276295}
0 commit comments