/** * @expectedException \eZ\Publish\Core\IO\Exception\BinaryFileNotFoundException */ public function testDeleteNotFound() { $statement = $this->createDbalStatementMock(); $statement->expects($this->once())->method('rowCount')->will($this->returnValue(0)); $this->dbalMock->expects($this->once())->method('prepare')->with($this->anything())->will($this->returnValue($statement)); $this->handler->delete('prefix/my/file.png'); }
public function testDeleteWithException() { $exceptionMessage = 'Some Message'; $this->bookmarkResourceMock->expects($this->once())->method('delete')->with($this->bookmarkMock)->willThrowException(new \Exception($exceptionMessage)); $this->setExpectedException('Magento\\Framework\\Exception\\CouldNotDeleteException', __($exceptionMessage)); $this->assertTrue($this->bookmarkRepository->delete($this->bookmarkMock)); }
public function testDelete() { // ARRANGE $expectedSql = "DELETE FROM `countries` WHERE `countries`.`id` = '123'"; // ACT $this->tableGateway->delete('123'); // ASSERT $this->assertTableGatewayLastSqlDelete($expectedSql); }
/** * @expectedException \Exception * @expectedExceptionMessage test exception */ public function testBeforeDelete() { $this->objectMock->expects($this->once())->method('getEntityTypeId')->willReturn(665); $this->eavConfigMock->expects($this->once())->method('getEntityType')->with(665)->willReturn($this->typeMock); $this->typeMock->expects($this->once())->method('getDefaultAttributeSetId')->willReturn(4); $this->objectMock->expects($this->once())->method('getAttributeSetId')->willReturn(5); $this->model->expects($this->once())->method('_getWriteAdapter')->willThrowException(new \Exception('test exception')); $this->model->delete($this->objectMock); }
/** * @expectedException \Magento\Framework\Exception\StateException */ public function testDeleteStateException() { $id = 3; $this->category->expects($this->once())->method('getId')->will($this->returnValue($id)); $this->category->expects($this->once())->method('delete')->will($this->returnCallback(function () { throw new \Exception(); })); $this->model->delete($id); }
/** * @covers ::delete */ public function testDelete() { $this->entity->id = $this->randomMachineName(); $storage = $this->getMock('\\Drupal\\Core\\Entity\\EntityStorageInterface'); // Testing the argument of the delete() method consumes too much memory. $storage->expects($this->once())->method('delete'); $this->entityManager->expects($this->once())->method('getStorage')->with($this->entityTypeId)->will($this->returnValue($storage)); $this->entity->delete(); }
/** * @expectedException \Exception * @expectedExceptionMessage test exception * @return void */ public function testBeforeDelete() { $this->resourceMock->expects($this->once())->method('getConnection')->willReturn($this->getMock('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface')); $this->transactionManagerMock->expects($this->once())->method('start')->with($this->getMock('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface'))->willReturn($this->getMock('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface')); $this->objectMock->expects($this->once())->method('getEntityTypeId')->willReturn(665); $this->eavConfigMock->expects($this->once())->method('getEntityType')->with(665)->willReturn($this->typeMock); $this->typeMock->expects($this->once())->method('getDefaultAttributeSetId')->willReturn(4); $this->objectMock->expects($this->once())->method('getAttributeSetId')->willReturn(5); $this->relationProcessor->expects($this->once())->method('delete')->willThrowException(new \Exception('test exception')); $this->model->delete($this->objectMock); }
/** * @depends testAdd */ public function testDelete($returnedLink) { $this->fileManagerMock->expects($this->once())->method('deleteFile')->with('myGreatLink')->willReturn(true); $instance = new \core_kernel_classes_Resource($returnedLink); $this->assertInstanceOf('\\core_kernel_classes_Resource', $instance, 'This class should exists'); $success = $this->mediaManagerManagement->delete($returnedLink); // should return true $this->assertTrue($success, 'The file is not deleted'); // should remove the instance $removedInstance = new \core_kernel_classes_Class($instance->getUri()); $this->assertFalse($instance->exists(), 'The instance still exists'); $this->assertFalse($removedInstance->exists(), 'The instance still exists'); }
public function te1stAnnouncement() { $subject = 'subject' . "\n<html>"; $message = 'message' . "\n<html>"; $author = 'author'; $time = time() - 10; $announcement = $this->manager->announce($subject, $message, $author, $time); $this->assertInternalType('int', $announcement['id']); $this->assertGreaterThan(0, $announcement['id']); $this->assertSame('subject <html>', $announcement['subject']); $this->assertSame('message<br /><html>', $announcement['message']); $this->assertSame('author', $announcement['author']); $this->assertSame($time, $announcement['time']); $this->assertEquals($announcement, $this->manager->getAnnouncement($announcement['id'])); $this->assertEquals($announcement, $this->manager->getAnnouncement($announcement['id'])); $this->assertEquals([$announcement], $this->manager->getAnnouncements(1)); $this->manager->delete($announcement['id']); try { $this->manager->getAnnouncement($announcement['id']); $this->fail('Failed to delete the announcement'); } catch (\InvalidArgumentException $e) { $this->assertInstanceOf('InvalidArgumentException', $e); } }
/** * @expectedException \eZ\Publish\Core\IO\Exception\BinaryFileNotFoundException */ public function testDeleteNotFound() { $this->filesystem->expects($this->once())->method('delete')->with('prefix/my/file.png')->will($this->throwException(new FileNotFoundException('prefix/my/file.png'))); $this->handler->delete('prefix/my/file.png'); }
public function testDelete() { $this->filesystem->expects($this->never())->method('delete'); $this->handler->delete('prefix/my/file.png'); }
public function testDelete() { $this->handler->delete('prefix/my/file.png'); }
/** * @test * @dataProvider deleteQueriesDataProvider * @param array $args * @param string $expectedQuery * @param array $expectedValues * @param array $expectedTypes */ public function deleteQueries(array $args, string $expectedQuery, array $expectedValues, array $expectedTypes) { $this->connection->expects($this->once())->method('executeUpdate')->with($expectedQuery, $expectedValues, $expectedTypes)->will($this->returnValue(1)); $this->connection->delete(...$args); }