PartKeepr\PartBundle\Tests\StockTest::testRemoveStock PHP Method

testRemoveStock() public method

public testRemoveStock ( )
    public function testRemoveStock()
    {
        $client = static::makeClient(true);
        /**
         * @var Part
         */
        $part = $this->fixtures->getReference('part.1');
        $oldStockLevel = $this->getStockLevel($part);
        /**
         * @var IriConverter
         */
        $iriConverter = $this->getContainer()->get('api.iri_converter');
        $iri = $iriConverter->getIriFromItem($part);
        $iri .= '/removeStock';
        $request = ['quantity' => 7];
        $client->request('PUT', $iri, [], [], ['CONTENT_TYPE' => 'application/json'], json_encode($request));
        $result = json_decode($client->getResponse()->getContent());
        $newStockLevel = $this->getStockLevel($part);
        $this->assertEquals($oldStockLevel - 7, $newStockLevel);
        $this->assertObjectHasAttribute('stockLevel', $result);
        $this->assertEquals($newStockLevel, $result->stockLevel);
    }