public function testDelete() { /** * Log models delete test */ \DatabaseManager::generateFakeRecords(); $admin = $this->personRepository->findOne(array('login' => 'admin')); $admin->delete(); $map = $this->getRepositoryMap($this->personRepository); $this->assertCount(0, $map); $rows = $this->dbal->fetchAll("select * from person where login = '******'"); $this->assertCount(1, $rows); $adminRow = $rows[0]; $this->assertLessThanOrEqual(time(), strtotime($adminRow['v_end'])); /** * Delete test for model without log behaviour */ $newModule = $this->moduleRepository->create(array('name' => 'Name')); $newModule->save(); $map = $this->getRepositoryMap($this->moduleRepository); $this->assertCount(1, $map); $newModule->delete(); $map = $this->getRepositoryMap($this->moduleRepository); $this->assertCount(0, $map); $rows = $this->dbal->fetchAll("select * from module"); $this->assertCount(1, $rows); // there is 1 backend module \DatabaseManager::clearTables(); }
public function testManyToManyDelete() { \DatabaseManager::generateFakeRecords(); $admin = $this->personRepository->findOne(array('login' => 'admin')); $backend = $this->moduleRepository->findOne(array('name' => 'Backend')); $admin->addModuleDeveloperLink($backend); $links = $admin->getModuleDeveloperLinks(); $this->assertCount(1, $links); $link = $links[0]; $link->delete(); $links = $admin->getModuleDeveloperLinks(); $this->assertCount(0, $links); $rows = $this->dbal->fetchAll("select * from module_developer_link"); $this->assertCount(1, $rows); $now = $this->dbal->fetchNow(); $this->assertLessThanOrEqual(strtotime($now), $rows[0]['v_end']); \DatabaseManager::clearTables(); }