h4cc / h4cc/AliceFixturesBundle
Function remove on fixture manager does not delete all the fixtures in a db
- Dominant language
- PHP
- Stars
- 74
- Forks
- 24
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I am trying to load and remove some dataFixtures ...
The fixtures are correctly loaded but are never removed (remove function called in tearDown or tearDownAfterClass function does not seem to work well).
the remove is OK at the end of the last test, but KO after the first one.
I made a little example as you can see the issue by yourself:
The result:
$ phpunit -c app/
PHPUnit 4.8.16 by Sebastian Bergmann and contributors.
```
Eadd new entries
string(25) "SET_UP : nb_chronos = 2
"
string(39) "TEST_1 : nb_chronos before delete = 2
"
string(38) "TEST_1 : nb_chronos after delete = 1
"
string(22) "====================
"
delete entries
.add new entries
string(25) "SET_UP : nb_chronos = 3
"
string(25) "TEST_2 : nb_chronos = 3
"
delete entries
string(28) "TEAR_DOWN : nb_chronos = 1
"
Time: 1.16 seconds, Memory: 14.00Mb
```
The config_test.yml:
imports:
- { resource: config_dev.yml }
```
framework:
test: ~
session:
storage_id: session.storage.mock_file
profiler:
collect: false
web_profiler:
toolbar: false
intercept_redirects: false
swiftmailer:
disable_delivery: true
doctrine:
dbal:
driver: pdo_sqlite
user: test
path: %kernel.cache_dir%/sqlite.db
#memory: true
charset: utf8
h4cc_alice_fixtures:
locale: fr_FR #usefull to generate french fixtures like a french phoneNumber
```
The Test class:
```
getContainer()->get('h4cc_alice_fixtures.manager');
static::$fixtures = static::$fixturesManager->loadFiles(
array(__DIR__ . '/../DataFixtures/chronos.yml')
);
static::$fixturesManager->persist(static::$fixtures);
$repo = $client
->getContainer()
->get('doctrine')
->getRepository('ChronosRestBundle:Chronos');
$chronos = $repo->findAll();
var_dump("SET_UP : nb_chronos = ".count($chronos).PHP_EOL);
}
/**
* Remove fixtures after every single test.
*/
public function tearDown()
{
echo "delete entries".PHP_EOL;
$client = static::createClient();
static::$fixturesManager = $client->getContainer()->get('h4cc_alice_fixtures.manager');
static::$fixturesManager->remove(static::$fixtures);
$repo = $client
->getContainer()
->get('doctrine')
->getRepository('ChronosRestBundle:Chronos');
$chronos = $repo->findAll();
var_dump("TEAR_DOWN : nb_chronos = ".count($chronos).PHP_EOL);
}
public function testAddAction()
{
$client = static::createClient();
//get a chronosController
$chronosController = $client->getContainer()->get('chronos.chronos_controller');
// $chronosController->addAction();
$repo = $client
->getContainer()
->get('doctrine')
->getRepository('ChronosRestBundle:Chronos');
$chronos = $repo->findAll();
var_dump("TEST_1 : nb_chronos before delete = ".count($chronos).PHP_EOL);
$em = $client
->getContainer()
->get('doctrine.orm.entity_manager');
$em->remove($chronos[0]);
$em->flush();
$chronos = $repo->findAll();
var_dump("TEST_1 : nb_chronos after delete = ".count($chronos).PHP_EOL);
var_dump("====================".PHP_EOL);
}
public function testEditAction() {
$client = static::createClient();
//get a chronosController
$chronosController = $client->getContainer()->get('chronos.chronos_controller');
// $chronosController->addAction();
$repo = $client
->getContainer()
->get('doctrine')
->getRepository('ChronosRestBundle:Chronos');
$chronos = $repo->findAll();
var_dump("TEST_2 : nb_chronos = ".count($chronos).PHP_EOL);
}
}
```
The fixtures:
```
Chronos\RestBundle\Entity\Chronos:
chronos_1:
id: 1
priority: 1
callDestination: 12548
channel: "welcome"
clientPhoneNumber: 0612348598
active: 1
inactiveCause: ""
additionalInformations: ""
recallDate:
createdAt:
updatedAt:
preTreatmentSmsDate: null
postTreatmentSmsDate: null
callDestinationType: "agent"
chronos_inactive:
id: 2
priority: 3
callDestination: 12549
channel: "nordnet.fr"
clientPhoneNumber: 0682348654
active: 0
inactiveCause: "nothing to say"
additionalInformations: ""
recallDate:
createdAt:
updatedAt:
preTreatmentSmsDate: nuu
postTreatmentSmsDate: ""
callDestinationType: "group"
```
The Entity:
id;
}
/**
* Set priority
*
* @param integer $priority
*
* @return Chronos
*/
public function setPriority($priority)
{
$this->priority = $priority;
return $this;
}
/**
* Get priority
*
* @return integer
*/
public function getPriority()
{
return $this->priority;
}
/**
* Set callDestination
*
* @param string $callDestination
*
* @return Chronos
*/
public function setCallDestination($callDestination)
{
$this->callDestination = $callDestination;
return $this;
}
/**
* Get callDestination
*
* @return string
*/
public function getCallDestination()
{
return $this->callDestination;
}
/**
* Set channel
*
* @param string $channel
*
* @return Chronos
*/
public function setChannel($channel)
{
$this->channel = $channel;
return $this;
}
/**
* Get channel
*
* @return string
*/
public function getChannel()
{
return $this->channel;
}
/**
* Set clientPhoneNumber
*
* @param integer $clientPhoneNumber
*
* @return Chronos
*/
public function setClientPhoneNumber($clientPhoneNumber)
{
$this->clientPhoneNumber = $clientPhoneNumber;
return $this;
}
/**
* Get clientPhoneNumber
*
* @return integer
*/
public function getClientPhoneNumber()
{
return $this->clientPhoneNumber;
}
/**
* Set active[D[D[D[D[D[DisActive
*
* @param boolean $active
*
* @return Chronos
*/
public function setActive($active)
{
$this->active = $active;
return $this;
}
/**
* Get active[D[D[D[D[D[DisActive
*
* @return boolean
*/
public function getActive()
{
return $this->active;
}
/**
* Set inactiveCause
*
* @param string $inactiveCause
*
* @return Chronos
*/
public function setInactiveCause($inactiveCause)
{
$this->inactiveCause = $inactiveCause;
return $this;
}
/**
* Get inactiveCause
*
* @return string
*/
public function getInactiveCause()
{
return $this->inactiveCause;
}
/**
* Set additionalInformations
*
* @param string $additionalInformations
*
* @return Chronos
*/
public function setAdditionalInformations($additionalInformations)
{
$this->additionalInformations = $additionalInformations;
return $this;
}
/**
* Get additionalInformations
*
* @return string
*/
public function getAdditionalInformations()
{
return $this->additionalInformations;
}
/**
* Set recallDate
*
* @param \DateTime $recallDate
*
* @return Chronos
*/
public function setRecallDate($recallDate)
{
$this->recallDate = $recallDate;
return $this;
}
/**
* Get recallDate
*
* @return \DateTime
*/
public function getRecallDate()
{
return $this->recallDate;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
*
* @return Chronos
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set updatedAt
*
* @param \DateTime $updatedAt
*
* @return Chronos
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get updatedAt
*
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set preTreatmentSmsDate
*
* @param \DateTime $preTreatmentSmsDate
*
* @return Chronos
*/
public function setPreTreatmentSmsDate($preTreatmentSmsDate)
{
$this->preTreatmentSmsDate = $preTreatmentSmsDate;
return $this;
}
/**
* Get preTreatmentSmsDate
*
* @return \DateTime
*/
public function getPreTreatmentSmsDate()
{
return $this->preTreatmentSmsDate;
}
/**
* Set postTreatmentSmsDate
*
* @param \DateTime $postTreatmentSmsDate
*
* @return Chronos
*/
public function setPostTreatmentSmsDate($postTreatmentSmsDate)
{
$this->postTreatmentSmsDate = $postTreatmentSmsDate;
return $this;
}
/**
* Get postTreatmentSmsDate
*
* @return \DateTime
*/
public function getPostTreatmentSmsDate()
{
return $this->postTreatmentSmsDate;
}
/**
* Set callDestinationType
*
* @param string $callDestinationType
*
* @return Chronos
*/
public function setCallDestinationType($callDestinationType)
{
$this->callDestinationType = $callDestinationType;
return $this;
}
/**
* Get callDestinationType
*
* @return string
*/
public function getCallDestinationType()
{
return $this->callDestinationType;
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.