Skip to content

Commit

Permalink
add tests and change phpunit options to avoid cakedc/tags deprication…
Browse files Browse the repository at this point in the history
… issue
  • Loading branch information
ryuzee committed Sep 2, 2015
1 parent 994a684 commit 8337ee0
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 2 deletions.
68 changes: 67 additions & 1 deletion app/Test/Case/Controller/SlidesControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public function testEdit()
}

/**
* testEdit method
* testEditOtherUserSlide method
*
* @return void
*/
Expand All @@ -411,6 +411,53 @@ public function testEditOtherUserSlide()
$this->assertContains('/slides/view/3', $this->headers['Location']);
}

/**
* testEditWithPost method
*
* @return void
*/
public function testEditWithPost()
{
$this->goIntoLoginStatus('Slides');
$this->mockSlide();

$data = array(
'Slide' => array(
'id' => 1,
'name' => 'Updated1',
'description' => 'UpdatedDescription1',
'downloadable' => 1,
'category_id' => 3,
'key' => '4ea2abecba74eda5521fff924d9e5062',
'convert_status' => 100,
'tags' => 'toro,uni,ika',
),
);
//@TODO:This configure setting must be removed after cakedc/tags fixes the issue
Configure::write('debug', 0);
$this->testAction('/slides/edit/1', array(
'data' => $data,
'method' => 'POST',
'return' => 'contents'
));
Configure::write('debug', 2);
// Slide ID:3 was owned by user ID:2
$this->assertContains('/slides/view/1', $this->headers['Location']);

App::uses('Slide', 'Model');
$s = new Slide();
$s->useDbConfig = 'test';
$s->recursive = -1;
$s->id = 1;
$rec = $s->read(null, 1);
$this->assertEqual($rec['Slide']['name'], $data['Slide']['name']);
$this->assertEqual($rec['Slide']['description'], $data['Slide']['description']);
$this->assertEqual($rec['Slide']['downloadable'], $data['Slide']['downloadable']);
$this->assertEqual($rec['Slide']['category_id'], $data['Slide']['category_id']);

}


/**
* testDelete method
*
Expand All @@ -429,4 +476,23 @@ public function testDelete()
);
$this->assertContains('/users', $this->headers['Location']);
}

/**
* testDeleteOthersSlide
*
*/
public function testDeleteOthersSlide()
{
$this->goIntoLoginStatus('Slides');
$this->mockSlide();
$result = $this->testAction(
'/comments/delete/3',
array(
'method' => 'POST',
'return' => 'contents'
)
);
$this->assertContains('/slides/view/3', $this->headers['Location']);
}

}
4 changes: 3 additions & 1 deletion oss_phpunit.xml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<phpunit>
<phpunit convertErrorsToExceptions="false"
convertNoticesToExceptions="false"
convertWarningsToExceptions="false">

<logging>
<log type="coverage-html" target="./app/reports/coverage_html/" title="My Project" charset="UTF-8" yui="true" highlight="true" lowUpperBound="35" highLowerBound="70"></log>
Expand Down
4 changes: 4 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<phpunit convertErrorsToExceptions="false"
convertNoticesToExceptions="false"
convertWarningsToExceptions="false">
</phpunit>

0 comments on commit 8337ee0

Please sign in to comment.