Sonata\Tests\ProductBundle\Entity\BaseProductTest::testGetImageAndGetGallery PHP Method

testGetImageAndGetGallery() public method

    public function testGetImageAndGetGallery()
    {
        $product = new Product();
        $this->assertNull($product->getImage());
        // Test gallery
        $gallery = $this->getMock('Sonata\\MediaBundle\\Model\\GalleryInterface');
        $product->setGallery($gallery);
        $this->assertNull($product->getImage());
        $this->assertInstanceOf('Sonata\\MediaBundle\\Model\\GalleryInterface', $product->getGallery());
        // Test getImage
        $image = $this->getMock('Sonata\\MediaBundle\\Model\\MediaInterface');
        $image->expects($this->any())->method('getName')->will($this->returnValue('correctMedia'));
        $product->setImage($image);
        $this->assertInstanceOf('Sonata\\MediaBundle\\Model\\MediaInterface', $product->getImage());
        $this->assertEquals('correctMedia', $product->getImage()->getName());
    }