Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
b86f5a14
Commit
b86f5a14
authored
May 06, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#2435 Tests for integrity exception
parent
d773ce66
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
IntegrityException.php
framework/db/IntegrityException.php
+25
-0
CommandTest.php
tests/unit/framework/db/CommandTest.php
+12
-0
No files found.
framework/db/IntegrityException.php
0 → 100644
View file @
b86f5a14
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\db
;
/**
* Exception represents an exception that is caused by violation of DB constraints.
*
* @author Alexander Makarov <sam@rmcreative.ru>
* @since 2.0
*/
class
IntegrityException
extends
Exception
{
/**
* @return string the user-friendly name of this exception
*/
public
function
getName
()
{
return
'Integrity constraint violation'
;
}
}
tests/unit/framework/db/CommandTest.php
View file @
b86f5a14
...
...
@@ -287,4 +287,16 @@ class CommandTest extends DatabaseTestCase
public
function
testDropIndex
()
{
}
public
function
testIntegrityViolation
()
{
$this
->
setExpectedException
(
'\yii\db\IntegrityException'
);
$db
=
$this
->
getConnection
();
$sql
=
'INSERT INTO profile(id, description) VALUES (123, \'duplicate\')'
;
$command
=
$db
->
createCommand
(
$sql
);
$command
->
execute
();
$command
->
execute
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment