PartKeepr\CategoryBundle\Tests\AbstractMoveCategoryTest::testMoveCategory PHP Method

testMoveCategory() public method

public testMoveCategory ( )
    public function testMoveCategory()
    {
        $client = static::makeClient(true);
        /**
         * @var AbstractCategory
         * @var $rootCategory    AbstractCategory
         */
        $secondCategory = $this->fixtures->getReference($this->getReferencePrefix() . '.second');
        $rootCategory = $this->fixtures->getReference($this->getReferencePrefix() . '.root');
        /**
         * @var IriConverter
         */
        $iriConverter = $this->getContainer()->get('api.iri_converter');
        $iri = $iriConverter->getIriFromItem($secondCategory);
        $iri .= '/move';
        $targetIri = $iriConverter->getIriFromItem($rootCategory);
        $request = ['parent' => $targetIri];
        $client->request('PUT', $iri, [], [], ['CONTENT_TYPE' => 'application/json'], json_encode($request));
        $this->assertEquals($rootCategory->getId(), $secondCategory->getParent()->getId());
        $this->assertEquals('Root Node ➤ Second Category', $secondCategory->getCategoryPath());
    }