Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove duplicated test code.

  • Loading branch information...
commit f677bfea7da6c97ff8970cf6ec4d5d5dadb43cce 1 parent a4f0399
@markstory markstory authored
Showing with 7 additions and 170 deletions.
  1. +7 −170 lib/Cake/Test/Case/Utility/SetTest.php
View
177 lib/Cake/Test/Case/Utility/SetTest.php
@@ -80,67 +80,24 @@ public function testEnum() {
/**
* testFilter method
*
+ * @see Hash test cases, as Set::filter() is just a proxy.
* @return void
*/
public function testFilter() {
$result = Set::filter(array('0', false, true, 0, array('one thing', 'I can tell you', 'is you got to be', false)));
$expected = array('0', 2 => true, 3 => 0, 4 => array('one thing', 'I can tell you', 'is you got to be'));
$this->assertSame($expected, $result);
-
- $result = Set::filter(array(1, array(false)));
- $expected = array(1);
- $this->assertEquals($expected, $result);
-
- $result = Set::filter(array(1, array(false, false)));
- $expected = array(1);
- $this->assertEquals($expected, $result);
-
- $result = Set::filter(array(1, array('empty', false)));
- $expected = array(1, array('empty'));
- $this->assertEquals($expected, $result);
-
- $result = Set::filter(array(1, array('2', false, array(3, null))));
- $expected = array(1, array('2', 2 => array(3)));
- $this->assertEquals($expected, $result);
-
- $this->assertSame(array(), Set::filter(array()));
}
/**
* testNumericArrayCheck method
*
+ * @see Hash test cases, as Set::numeric() is just a proxy.
* @return void
*/
public function testNumericArrayCheck() {
$data = array('one');
$this->assertTrue(Set::numeric(array_keys($data)));
-
- $data = array(1 => 'one');
- $this->assertFalse(Set::numeric($data));
-
- $data = array('one');
- $this->assertFalse(Set::numeric($data));
-
- $data = array('one' => 'two');
- $this->assertFalse(Set::numeric($data));
-
- $data = array('one' => 1);
- $this->assertTrue(Set::numeric($data));
-
- $data = array(0);
- $this->assertTrue(Set::numeric($data));
-
- $data = array('one', 'two', 'three', 'four', 'five');
- $this->assertTrue(Set::numeric(array_keys($data)));
-
- $data = array(1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five');
- $this->assertTrue(Set::numeric(array_keys($data)));
-
- $data = array('1' => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five');
- $this->assertTrue(Set::numeric(array_keys($data)));
-
- $data = array('one', 2 => 'two', 3 => 'three', 4 => 'four', 'a' => 'five');
- $this->assertFalse(Set::numeric(array_keys($data)));
}
/**
@@ -1660,6 +1617,7 @@ public function testClassicExtract() {
/**
* testInsert method
*
+ * @see Hash tests, as Set::insert() is just a proxy.
* @return void
*/
public function testInsert() {
@@ -1669,55 +1627,8 @@ public function testInsert() {
$result = Set::insert($a, 'files', array('name' => 'files'));
$expected = array(
- 'pages' => array('name' => 'page'),
- 'files' => array('name' => 'files')
- );
- $this->assertEquals($expected, $result);
-
- $a = array(
- 'pages' => array('name' => 'page')
- );
- $result = Set::insert($a, 'pages.name', array());
- $expected = array(
- 'pages' => array('name' => array()),
- );
- $this->assertEquals($expected, $result);
-
- $a = array(
- 'pages' => array(
- 0 => array('name' => 'main'),
- 1 => array('name' => 'about')
- )
- );
-
- $result = Set::insert($a, 'pages.1.vars', array('title' => 'page title'));
- $expected = array(
- 'pages' => array(
- 0 => array('name' => 'main'),
- 1 => array('name' => 'about', 'vars' => array('title' => 'page title'))
- )
- );
- $this->assertEquals($expected, $result);
- }
-
-/**
- * Test that insert() can insert data over a string value.
- *
- * @return void
- */
- public function testInsertOverwriteStringValue() {
- $data = array(
- 'Some' => array(
- 'string' => 'value'
- )
- );
- $result = Set::insert($data, 'Some.string.value', array('values'));
- $expected = array(
- 'Some' => array(
- 'string' => array(
- 'value' => array( 'values')
- )
- )
+ 'pages' => array('name' => 'page'),
+ 'files' => array('name' => 'files')
);
$this->assertEquals($expected, $result);
}
@@ -1729,8 +1640,8 @@ public function testInsertOverwriteStringValue() {
*/
public function testRemove() {
$a = array(
- 'pages' => array('name' => 'page'),
- 'files' => array('name' => 'files')
+ 'pages' => array('name' => 'page'),
+ 'files' => array('name' => 'files')
);
$result = Set::remove($a, 'files');
@@ -1738,26 +1649,6 @@ public function testRemove() {
'pages' => array('name' => 'page')
);
$this->assertEquals($expected, $result);
-
- $a = array(
- 'pages' => array(
- 0 => array('name' => 'main'),
- 1 => array('name' => 'about', 'vars' => array('title' => 'page title'))
- )
- );
-
- $result = Set::remove($a, 'pages.1.vars');
- $expected = array(
- 'pages' => array(
- 0 => array('name' => 'main'),
- 1 => array('name' => 'about')
- )
- );
- $this->assertEquals($expected, $result);
-
- $result = Set::remove($a, 'pages.2.vars');
- $expected = $a;
- $this->assertEquals($expected, $result);
}
/**
@@ -3132,26 +3023,6 @@ public function testFlatten() {
$data[9] = 'Shemp';
$result = Set::flatten($data);
$this->assertEquals($data, $result);
-
- $data = array(
- array(
- 'Post' => array('id' => '1', 'author_id' => '1', 'title' => 'First Post'),
- 'Author' => array('id' => '1', 'user' => 'nate', 'password' => 'foo'),
- ),
- array(
- 'Post' => array('id' => '2', 'author_id' => '3', 'title' => 'Second Post', 'body' => 'Second Post Body'),
- 'Author' => array('id' => '3', 'user' => 'larry', 'password' => null),
- )
- );
-
- $result = Set::flatten($data);
- $expected = array(
- '0.Post.id' => '1', '0.Post.author_id' => '1', '0.Post.title' => 'First Post', '0.Author.id' => '1',
- '0.Author.user' => 'nate', '0.Author.password' => 'foo', '1.Post.id' => '2', '1.Post.author_id' => '3',
- '1.Post.title' => 'Second Post', '1.Post.body' => 'Second Post Body', '1.Author.id' => '3',
- '1.Author.user' => 'larry', '1.Author.password' => null
- );
- $this->assertEquals($expected, $result);
}
/**
@@ -3164,40 +3035,6 @@ public function testExpand() {
$flat = Set::flatten($data);
$result = Set::expand($flat);
$this->assertEqual($data, $result);
-
- $data = array(
- '0.Post.id' => '1', '0.Post.author_id' => '1', '0.Post.title' => 'First Post', '0.Author.id' => '1',
- '0.Author.user' => 'nate', '0.Author.password' => 'foo', '1.Post.id' => '2', '1.Post.author_id' => '3',
- '1.Post.title' => 'Second Post', '1.Post.body' => 'Second Post Body', '1.Author.id' => '3',
- '1.Author.user' => 'larry', '1.Author.password' => null
- );
- $result = Set::expand($data);
- $expected = array(
- array(
- 'Post' => array('id' => '1', 'author_id' => '1', 'title' => 'First Post'),
- 'Author' => array('id' => '1', 'user' => 'nate', 'password' => 'foo'),
- ),
- array(
- 'Post' => array('id' => '2', 'author_id' => '3', 'title' => 'Second Post', 'body' => 'Second Post Body'),
- 'Author' => array('id' => '3', 'user' => 'larry', 'password' => null),
- )
- );
- $this->assertEqual($result, $expected);
-
- $data = array(
- '0/Post/id' => 1,
- '0/Post/name' => 'test post'
- );
- $result = Set::expand($data, '/');
- $expected = array(
- array(
- 'Post' => array(
- 'id' => 1,
- 'name' => 'test post'
- )
- )
- );
- $this->assertEqual($result, $expected);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.