Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
CS fixes and updating deprecated phpunit method calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Krämer committed Feb 28, 2014
1 parent 3177187 commit 8be0b63
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 83 deletions.
30 changes: 15 additions & 15 deletions Test/Case/Controller/TagsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ public function testIndex() {
public function testView() {
$this->Tags->view('cakephp');
$this->assertTrue(!empty($this->Tags->viewVars['tag']));
$this->assertEqual($this->Tags->viewVars['tag']['Tag']['keyname'], 'cakephp');
$this->assertEquals($this->Tags->viewVars['tag']['Tag']['keyname'], 'cakephp');

$this->Tags->view('invalid-key-name!');
$this->assertEqual($this->Tags->redirectUrl, '/');
$this->assertEquals($this->Tags->redirectUrl, '/');
}

/**
Expand All @@ -143,10 +143,10 @@ public function testView() {
public function testAdminView() {
$this->Tags->admin_view('cakephp');
$this->assertTrue(!empty($this->Tags->viewVars['tag']));
$this->assertEqual($this->Tags->viewVars['tag']['Tag']['keyname'], 'cakephp');
$this->assertEquals($this->Tags->viewVars['tag']['Tag']['keyname'], 'cakephp');

$this->Tags->admin_view('invalid-key-name!');
$this->assertEqual($this->Tags->redirectUrl, '/');
$this->assertEquals($this->Tags->redirectUrl, '/');
}

/**
Expand Down Expand Up @@ -177,10 +177,10 @@ public function testAdminDelete() {


$this->Tags->admin_delete('WRONG-ID!!!');
$this->assertEqual($this->Tags->redirectUrl, array('action' => 'index'));
$this->assertEquals($this->Tags->redirectUrl, array('action' => 'index'));

$this->Tags->admin_delete('tag-1');
$this->assertEqual($this->Tags->redirectUrl, array('action' => 'index'));
$this->assertEquals($this->Tags->redirectUrl, array('action' => 'index'));
}

/**
Expand All @@ -193,7 +193,7 @@ public function testAdminAdd() {
'Tag' => array(
'tags' => 'tag1, tag2, tag3'));
$this->Tags->admin_add();
$this->assertEqual($this->Tags->redirectUrl, array('action' => 'index'));
$this->assertEquals($this->Tags->redirectUrl, array('action' => 'index'));
}

/**
Expand All @@ -205,23 +205,23 @@ public function testAdminEdit() {
$this->Tags->admin_edit('tag-1');
$tag = array(
'Tag' => array(
'id' => 'tag-1',
'identifier' => null,
'name' => 'CakePHP',
'keyname' => 'cakephp',
'id' => 'tag-1',
'identifier' => null,
'name' => 'CakePHP',
'keyname' => 'cakephp',
'occurrence' => 1,
'article_occurrence' => 1,
'created' => '2008-06-02 18:18:11',
'modified' => '2008-06-02 18:18:37'));
'created' => '2008-06-02 18:18:11',
'modified' => '2008-06-02 18:18:37'));

$this->assertEqual($this->Tags->data, $tag);
$this->assertEquals($this->Tags->data, $tag);

$this->Tags->data = array(
'Tag' => array(
'id' => 'tag-1',
'name' => 'CAKEPHP'));
$this->Tags->admin_edit('tag-1');

$this->assertEqual($this->Tags->redirectUrl, array('action' => 'index'));
$this->assertEquals($this->Tags->redirectUrl, array('action' => 'index'));
}
}
18 changes: 9 additions & 9 deletions Test/Case/Model/Behavior/TaggableBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function testOccurrenceCache() {
'conditions' => array(
'Tag.keyname' => 'cakephp')));

$this->assertEqual($resultAfter['Tag']['occurrence'] - $resultBefore['Tag']['occurrence'], 1);
$this->assertEquals($resultAfter['Tag']['occurrence'] - $resultBefore['Tag']['occurrence'], 1);

// updating the record to not have the cakephp tag anymore, decreases the occurrence
$data = array('id' => $this->Article->id, 'title' => 'Test Article', 'tags' => 'php, something, else');
Expand All @@ -146,7 +146,7 @@ public function testOccurrenceCache() {
'contain' => array(),
'conditions' => array(
'Tag.keyname' => 'cakephp')));
$this->assertEqual($resultAfter['Tag']['occurrence'], 1);
$this->assertEquals($resultAfter['Tag']['occurrence'], 1);
}

/**
Expand All @@ -171,7 +171,7 @@ public function testTagSaving() {
'id' => 'article-1')));

$this->assertTrue(!empty($result['Article']['tags']));
$this->assertEqual(3, count($result['Tag']));
$this->assertEquals(3, count($result['Tag']));


$data['tags'] = 'cakephp:foo, developer, cakephp:developer, cakephp:php';
Expand All @@ -183,7 +183,7 @@ public function testTagSaving() {
'Tag.identifier' => 'cakephp')));

$result = Set::extract($result, '{n}.Tag.keyname');
$this->assertEqual($result, array(
$this->assertEquals($result, array(
'developer', 'foo', 'php'));

$this->assertFalse($this->Article->saveTags('foo, bar', null));
Expand All @@ -206,13 +206,13 @@ public function testSaveTimesTagged() {
'contain' => array('Tag'),
));
$fooCount = Set::extract('/Tag[keyname=foo]/../Tagged/times_tagged', $result);
$this->assertEqual($fooCount, array(2));
$this->assertEquals($fooCount, array(2));

$barCount = Set::extract('/Tag[keyname=bar]/../Tagged/times_tagged', $result);
$this->assertEqual($barCount, array(2));
$this->assertEquals($barCount, array(2));

$testCount = Set::extract('/Tag[keyname=test]/../Tagged/times_tagged', $result);
$this->assertEqual($testCount, array(2));
$this->assertEquals($testCount, array(2));
}

/**
Expand Down Expand Up @@ -243,10 +243,10 @@ public function testTagArrayToString() {
*/
public function testMultibyteKey() {
$result = $this->Article->multibyteKey('this is _ a Nice ! - _ key!');
$this->assertEqual('thisisanicekey', $result);
$this->assertEquals('thisisanicekey', $result);

$result = $this->Article->multibyteKey('Äü-Ü_ß');
$this->assertEqual('äüüß', $result);
$this->assertEquals('äüüß', $result);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions Test/Case/Model/TagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testTagFind() {
'article_occurrence' => 1,
'created' => '2008-06-02 18:18:11',
'modified' => '2008-06-02 18:18:37'));
$this->assertEqual($results, $expected);
$this->assertEquals($results, $expected);
}

/**
Expand All @@ -95,7 +95,7 @@ public function testTagFind() {
public function testView() {
$result = $this->Tag->view('cakephp');
$this->assertTrue(is_array($result));
$this->assertEqual($result['Tag']['keyname'], 'cakephp');
$this->assertEquals($result['Tag']['keyname'], 'cakephp');

$this->expectException('CakeException');
$this->Tag->view('invalid-key!!!');
Expand Down Expand Up @@ -128,7 +128,7 @@ public function testAdd() {
*/
public function testEdit() {
$this->assertNull($this->Tag->edit('tag-1'));
$this->assertEqual($this->Tag->data['Tag']['id'], 'tag-1');
$this->assertEquals($this->Tag->data['Tag']['id'], 'tag-1');

$data = array(
'Tag' => array(
Expand All @@ -147,7 +147,7 @@ public function testEdit() {
'id' => 'tag-1',
'name' => 'CAKEPHP',
'keyname' => ''));
$this->assertEqual($this->Tag->edit('tag-1', $data), $data);
$this->assertEquals($this->Tag->edit('tag-1', $data), $data);

$this->expectException('CakeException');
$this->assertTrue($this->Tag->edit('invalid-id', array()));
Expand Down
40 changes: 24 additions & 16 deletions Test/Case/Model/TaggedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@
* TagggedArticle Test Model
*/
class TaggedArticle extends Model {

public $useTable = 'articles';

public $actsAs = array(
'Tags.Taggable');
'Tags.Taggable'
);

public $belongsTo = array(
'User'
);

}

/**
Expand All @@ -45,7 +53,8 @@ class TaggedTest extends CakeTestCase {
'plugin.tags.tagged',
'plugin.tags.tag',
'plugin.tags.article',
'plugin.tags.user');
'plugin.tags.user'
);

/**
* setUp
Expand Down Expand Up @@ -98,7 +107,7 @@ public function testTaggedFind() {
'created' => '2008-12-02 12:32:31',
'modified' => '2008-12-02 12:32:31'));

$this->assertEqual($result, $expected);
$this->assertEquals($result, $expected);
}

/**
Expand All @@ -110,16 +119,16 @@ public function testFindCloud() {
$result = $this->Tagged->find('cloud', array(
'model' => 'Article'));

$this->assertEqual(count($result), 3);
$this->assertEquals(count($result), 3);
$this->assertTrue(isset($result[0][0]['occurrence']));
$this->assertEqual($result[0][0]['occurrence'], 1);
$this->assertEquals($result[0][0]['occurrence'], 1);

$result = $this->Tagged->find('cloud');
$this->assertTrue(is_array($result) && !empty($result));

$result = $this->Tagged->find('cloud', array(
'limit' => 1));
$this->assertEqual(count($result), 1);
$this->assertEquals(count($result), 1);
}

/**
Expand All @@ -132,18 +141,17 @@ public function testFindTagged() {
$result = $this->Tagged->find('tagged', array(
'by' => 'cakephp',
'model' => 'Article'));
$this->assertEqual(count($result), 1);
$this->assertEqual($result[0]['Article']['id'], 'article-1');
$this->assertEquals(count($result), 1);
$this->assertEquals($result[0]['Article']['id'], 'article-1');

$result = $this->Tagged->find('tagged', array(
'model' => 'Article'));
$this->assertEqual(count($result), 2);

$this->assertEquals(count($result), 2);
// Test call to paginateCount by Controller::pagination()
$result = $this->Tagged->paginateCount(array(), 1, array(
'model' => 'Article',
'type' => 'tagged'));
$this->assertEqual($result, 2);
$this->assertEquals($result, 2);
}

/**
Expand All @@ -157,14 +165,14 @@ public function testFindTaggedWithConditions() {
'by' => 'cakephp',
'model' => 'Article',
'conditions' => array('Article.title LIKE' => 'Second %')));
$this->assertEqual(count($result), 0);
$this->assertEquals(count($result), 0);

$result = $this->Tagged->find('tagged', array(
'by' => 'cakephp',
'model' => 'Article',
'conditions' => array('Article.title LIKE' => 'First %')));
$this->assertEqual(count($result), 1);
$this->assertEqual($result[0]['Article']['id'], 'article-1');
$this->assertEquals(count($result), 1);
$this->assertEquals($result[0]['Article']['id'], 'article-1');
}

/**
Expand All @@ -189,7 +197,7 @@ public function testDeepAssociationsHasOne() {
'Article' => array(
'User'))));

$this->assertEqual($result[0]['Article']['User']['name'], 'CakePHP');
$this->assertEquals($result[0]['Article']['User']['name'], 'CakePHP');
}

/**
Expand All @@ -214,7 +222,7 @@ public function testDeepAssociationsBelongsTo() {
'Article' => array(
'User'))));

$this->assertEqual($result[0]['Article']['User']['name'], 'CakePHP');
$this->assertEquals($result[0]['Article']['User']['name'], 'CakePHP');
}

}
10 changes: 5 additions & 5 deletions Test/Case/View/Helper/TagCloudHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function setUp() {
* @return void
*/
public function testDisplay() {
$this->assertEqual($this->TagCloud->display(), '');
$this->assertEquals($this->TagCloud->display(), '');

// Test tags shuffling
$options = array(
Expand All @@ -89,7 +89,7 @@ public function testDisplay() {
$options = array(
'shuffle' => false);
$result = $this->TagCloud->display($this->sampleTags, $options);
$this->assertEqual($result, $expected);
$this->assertEquals($result, $expected);

// Test options
$options = array_merge($options, array(
Expand All @@ -103,14 +103,14 @@ public function testDisplay() {
$result = $this->TagCloud->display($this->sampleTags, $options);
$expected = '<span size="1"><a href="/search/index/from:twitter/query:cakephp" id="tag-1">CakePHP</a> </span><!-- size: 1 -->'.
'<span size="1"><a href="/search/index/from:twitter/query:cakedc" id="tag-2">CakeDC</a> </span><!-- size: 1 -->';
$this->assertEqual($result, $expected);
$this->assertEquals($result, $expected);

$tags = $this->sampleTags;
$tags[1]['Tag']['weight'] = 1;
$result = $this->TagCloud->display($tags, $options);
$expected = '<span size="100"><a href="/search/index/from:twitter/query:cakephp" id="tag-1">CakePHP</a> </span><!-- size: 100 -->'.
'<span size="1"><a href="/search/index/from:twitter/query:cakedc" id="tag-2">CakeDC</a> </span><!-- size: 1 -->';
$this->assertEqual($result, $expected);
$this->assertEquals($result, $expected);
}

public function testDisplayShouldDefineCorrectSizeWhenCustomWeightField() {
Expand All @@ -127,7 +127,7 @@ public function testDisplayShouldDefineCorrectSizeWhenCustomWeightField() {
$result = $this->TagCloud->display($tags, $options);
$expected = '<!-- size: 160 --><a href="/search/index/by:cakephp" id="tag-1">CakePHP</a> '.
'<!-- size: 80 --><a href="/search/index/by:cakedc" id="tag-2">CakeDC</a> ';
$this->assertEqual($result, $expected);
$this->assertEquals($result, $expected);
}

/**
Expand Down
9 changes: 6 additions & 3 deletions Test/Fixture/ArticleFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ class ArticleFixture extends CakeTestFixture {
* @var array
*/
public $fields = array(
'id' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 36),
'id' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 36),
'title' => array('type' => 'string', 'null' => false),
'user_id' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 36));
'user_id' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 36)
);

/**
* records property
Expand All @@ -44,5 +45,7 @@ class ArticleFixture extends CakeTestFixture {
array(
'id' => 'article-3',
'title' => 'Third Article',
'user_id' => 'user-3'));
'user_id' => 'user-3'
)
);
}
Loading

0 comments on commit 8be0b63

Please sign in to comment.