1515
1616use Doctrine \Common \Collections \ArrayCollection ;
1717use Doctrine \Common \Collections \Collection ;
18+ use Doctrine \Common \Comparable ;
1819use PhpSpec \ObjectBehavior ;
1920use Sylius \Component \Core \Model \ImageInterface ;
2021use Sylius \Component \Core \Model \ImagesAwareInterface ;
22+ use Sylius \Component \Core \Model \Taxon ;
2123use Sylius \Component \Core \Model \TaxonInterface ;
2224
2325final class TaxonSpec extends ObjectBehavior
@@ -32,6 +34,11 @@ function it_implements_an_image_aware_interface(): void
3234 $ this ->shouldImplement (ImagesAwareInterface::class);
3335 }
3436
37+ function it_implements_doctrine_comparable (): void
38+ {
39+ $ this ->shouldImplement (Comparable::class);
40+ }
41+
3542 function it_initializes_an_image_collection_by_default (): void
3643 {
3744 $ this ->getImages ()->shouldHaveType (Collection::class);
@@ -60,4 +67,16 @@ function it_returns_images_by_type(ImageInterface $image): void
6067
6168 $ this ->getImagesByType ('thumbnail ' )->shouldBeLike (new ArrayCollection ([$ image ->getWrappedObject ()]));
6269 }
70+
71+ function it_is_comparable (): void
72+ {
73+ $ this ->setCode ('test ' );
74+
75+ $ otherTaxon = new Taxon ();
76+ $ otherTaxon ->setCode ('test ' );
77+ $ this ->compareTo ($ otherTaxon )->shouldReturn (0 );
78+
79+ $ otherTaxon ->setCode ('other ' );
80+ $ this ->compareTo ($ otherTaxon )->shouldReturn (1 );
81+ }
6382}
0 commit comments