Hello StackOverflow community, I just joined the community and this is my first question :)
I'm using Symfony2. When I access a page manually using my browser (firefox):
http://localhost:8000/vendor/add-product
The page renders fine and I see a form which will allow a user to add a product to his store.
But when I use Behat for my tests, I get this error:
[Semantical Error] The annotation "@Symfony\Component\Validator\Constraints\GreaterThanOrEqual" in property AppBundle\Entity\Product::$productPrice does not exist, or could not be auto-loaded.
This is (a part of) the source code in question:
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity
* @ORM\Table(name="app_products")
*/
class Product
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $productId;
/**
* @ORM\Column(type="integer")
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Store")
*/
private $storeId;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank(message="This is important, Product Name should not be blank!")
* @Assert\Length(max = "255", maxMessage="Your description must not exceed 255 characters.")
*/
private $productName;
/**
* @ORM\Column(type="integer", length=255)
* @Assert\GreaterThanOrEqual(value=0)
* @Assert\NotBlank(message="Product Price should not be blank!")
*/
private $productPrice;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank(message="Please enter a product description.")
* @Assert\Length(max = "255", maxMessage="Your description must not exceed 255 characters.")
*/
private $productDescription;
/**
* @ORM\Column(type="integer")
* @Assert\GreaterThanOrEqual(value=0)
* @Assert\NotBlank(message="Product Quantity should not be blank!")
*/
private $productQuantity;
/**
* @ORM\Column(type="string", length=255)
* @Assert\File(mimeTypes={ "image/jpeg" })
* @Assert\File(maxSize="6000000")
*/
private $productImage;
...
And this is my feature:
Feature: Buying products
As a customer,
I want to view and select products before buying,
So that I could have more value for my money
Background:
Given I am on the homepage
When I fill in "username" with "24thsaint"
And I fill in "password" with "123123"
And I press "login-button"
Scenario: Vendor wants to add a new product
Given I am on the homepage
When I follow "My Store" ###### The test stops here as I get the Semantical Error
And I follow "add-new-product"
Please help, I really think everything is in place. It's just that the error occurs during testing with Behat. What could have gone wrong?
Edit:
I did the suggestions of sir Evgeniy Kuzmin by clearing the cache. I ran,
php bin/console cache:clear --env=test
The tests that pass before fail now with this error:
[Semantical Error] The annotation "@Doctrine\ORM\Mapping\Entity" in
class AppBundle\Entity\User does not exist, or could not be auto-loaded.
Please help me.