From ecfd64c082321de94822184ea07b7944fadbf2a8 Mon Sep 17 00:00:00 2001 From: euromark Date: Mon, 6 Jan 2014 21:07:00 +0100 Subject: [PATCH] adding test --- .../Case/TestSuite/CakeTestFixtureTest.php | 57 ++++++++++++++++++- .../TestSuite/Fixture/CakeTestFixture.php | 2 +- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php index 4c791a5d5..3488d6a92 100644 --- a/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php +++ b/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php @@ -65,7 +65,7 @@ class CakeTestFixtureTestFixture extends CakeTestFixture { } /** - * StringFieldsTestFixture class + * StringTestFixture class * * @package Cake.Test.Case.TestSuite */ @@ -109,6 +109,50 @@ class StringsTestFixture extends CakeTestFixture { ); } +/** + * InvalidTestFixture class + * + * @package Cake.Test.Case.TestSuite + */ +class InvalidTestFixture extends CakeTestFixture { + +/** + * Name property + * + * @var string + */ + public $name = 'Invalid'; + +/** + * Table property + * + * @var string + */ + public $table = 'invalid'; + +/** + * Fields array - missing "email" row + * + * @var array + */ + public $fields = array( + 'id' => array('type' => 'integer', 'key' => 'primary'), + 'name' => array('type' => 'string', 'length' => '255'), + 'age' => array('type' => 'integer', 'default' => 10) + ); + +/** + * Records property + * + * @var array + */ + public $records = array( + array('name' => 'Mark Doe', 'email' => 'mark.doe@email.com'), + array('name' => 'John Doe', 'email' => 'john.doe@email.com', 'age' => 20), + array('email' => 'jane.doe@email.com', 'name' => 'Jane Doe', 'age' => 30) + ); +} + /** * CakeTestFixtureImportFixture class * @@ -482,6 +526,17 @@ class CakeTestFixtureTest extends CakeTestCase { $this->assertEquals($expected, $this->insertMulti['fields_values']); } +/** + * test the insert method with invalid fixture + * + * @expectedException CakeException + * @return void + */ + public function testInsertInvalid() { + $Fixture = new InvalidTestFixture(); + $return = $Fixture->insert($this->criticDb); + } + /** * Test the drop method * diff --git a/lib/Cake/TestSuite/Fixture/CakeTestFixture.php b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php index 04aaa4484..4fd045143 100644 --- a/lib/Cake/TestSuite/Fixture/CakeTestFixture.php +++ b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php @@ -280,7 +280,7 @@ class CakeTestFixture { foreach ($this->records as $record) { $merge = array_values(array_merge($default, $record)); if (count($fields) !== count($merge)) { - throw new CakeException('Fixure invalid: Count of fields does not match count of values'); + throw new CakeException('Fixture invalid: Count of fields does not match count of values'); } $values[] = $merge; }