we created a package to integrate CartoDB into Symfony2 projects. This package does not create any entity, because it "listens" for events, such as saving or a flash on your own entities, in order to synchronize information between your data and cartodb data. Here is the workflow:
Create an entity object β persist β listen event β add data to cartoDB via your API β get the identifier of the cartoDB object β update it in the created object
Here is an example for CartoDB Bundle anotations:
/** * @ORM\Entity * @ORM\Table(name="testDB", options={"collate"="utf8_general_ci"}) * @CartoDB\CartoDBLink(connection="private", table="testDB", cascade={"persist", "remove"}) */ class TestDB { /** * @ORM\Column(name="cartodb_index", type="integer", nullable=true) * @CartoDB\CartoDBColumn(column="testdb_id", index=true) */ protected $cartodbId;
We would like to create tests that cover any part of the code, so we decided to include Entity in the test folder to check synchronization with cartoDB data and add it to the test folder, we performed the following steps:
1- Add the doctrine kit to our composer.json kit.
2- Create an entity class in this route:
Company/Tests/CartoDB/Entity/TestDB.php
This object is as follows:
namespace Company\CartoDBBundle\Tests\CartoDB\Entity; use Doctrine\ORM\Mapping as ORM; class TestDB { protected $id; ..... ?>
3. Now it's his turn to test the script. We use the entity namespace:
use Company\CartoDBBundle\Tests\CartoDB\Entity\TestDB;
Next, we create an entity object:
$test = new TestDB(); $test->setText("HI");
It works fine, we call object methods, and everything goes right, and the last pass:
$em->persist($test); $em->flush();
Doctrine \ Common \ Persistence \ Mapping \ MappingException: class 'Company \ CartoDBBundle \ Tests \ CartoDB \ Entity \ TestDB' was not found in the chain name chain
Here is our doctrine configuration:
doctrine: dbal: driver: pdo_sqlite path: "%kernel.root_dir%/sqlite.db" charset: UTF8 orm: auto_generate_proxy_classes: %kernel.debug% auto_mapping: true
I donβt know what we are missing; can someone help us?
Thanks!