mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Simplified failing test in model.test.php
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4736 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
a702d4d41a
commit
2f5fa26e29
3 changed files with 101 additions and 27 deletions
|
@ -88,11 +88,36 @@
|
|||
'body' => VALID_NOT_EMPTY
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.model
|
||||
*/
|
||||
class ArticleFeatured extends CakeTestModel {
|
||||
var $name = 'ArticleFeatured';
|
||||
var $belongsTo = array('User', 'Category');
|
||||
var $hasOne = array('Featured');
|
||||
var $hasMany = array(
|
||||
'Comment' => array('className'=>'Comment', 'dependent' => true)
|
||||
);
|
||||
var $hasAndBelongsToMany = array('Tag');
|
||||
var $validate = array(
|
||||
'user_id' => VALID_NUMBER,
|
||||
'title' => VALID_NOT_EMPTY,
|
||||
'body' => VALID_NOT_EMPTY
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.model
|
||||
*/
|
||||
class Featured extends CakeTestModel {
|
||||
var $name = 'Featured';
|
||||
var $belongsTo = array(
|
||||
'Article'=> array('className' => 'Article'),
|
||||
'ArticleFeatured'=> array('className' => 'ArticleFeatured'),
|
||||
'Category'=> array('className' => 'Category')
|
||||
);
|
||||
}
|
||||
|
@ -159,7 +184,7 @@
|
|||
* @subpackage cake.tests.cases.libs.model
|
||||
*/
|
||||
class ModelTest extends CakeTestCase {
|
||||
var $fixtures = array( 'core.category', 'core.category_thread', 'core.user', 'core.article', 'core.featured', 'core.tag', 'core.articles_tag', 'core.comment', 'core.attachment' );
|
||||
var $fixtures = array( 'core.category', 'core.category_thread', 'core.user', 'core.article', 'core.featured', 'core.article_featured', 'core.tag', 'core.articles_tag', 'core.comment', 'core.attachment' );
|
||||
|
||||
function start() {
|
||||
parent::start();
|
||||
|
@ -658,38 +683,35 @@ class ModelTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
/*
|
||||
$this->Article = new Article();
|
||||
$this->ArticleFeatured = new ArticleFeatured();
|
||||
|
||||
$this->Article->bindModel(array('hasOne' => array('Featured'=> array('className' => 'Featured'))));
|
||||
$this->Article->bindModel(array('belongsTo' => array('Category')));
|
||||
|
||||
$this->Article->Featured->recursive = 2;
|
||||
$orderBy = 'Article.published DESC';
|
||||
$this->Article->Featured->bindModel(array('belongsTo' =>
|
||||
array('Article' => array('conditions' => 'Article.published = \'Y\'',
|
||||
$this->ArticleFeatured->Featured->recursive = 2;
|
||||
$orderBy = 'ArticleFeatured.id ASC';
|
||||
$this->ArticleFeatured->Featured->bindModel(array('belongsTo' =>
|
||||
array('ArticleFeatured' => array('conditions' => 'ArticleFeatured.published = \'Y\'',
|
||||
'fields' => 'id, title, user_id, published'))));
|
||||
|
||||
$this->Article->unbindModel(array('hasMany' => array('Attachment', 'Leaf', 'Rating', 'Comment'), 'hasAndBelongsToMany'=>array('Tag')));
|
||||
$this->ArticleFeatured->Featured->ArticleFeatured->bindModel(array('hasOne' => array('Featured'=> array('className' => 'Featured'))));
|
||||
$this->ArticleFeatured->Featured->ArticleFeatured->unbindModel(array('hasMany' => array('Attachment', 'Comment'), 'hasAndBelongsToMany'=>array('Tag')));
|
||||
|
||||
// UNCOMMENT THE FOLLOWING LINE TO MAKE TEST SUCCEED:
|
||||
//
|
||||
// $this->Article->unbindModel(array('belongsTo'=>array('Category')));
|
||||
// $this->ArticleFeatured->unbindModel(array('belongsTo'=>array('Category')));
|
||||
|
||||
$result = $this->Article->Featured->findAll(null, null, $orderBy, 3);
|
||||
$result = $this->ArticleFeatured->Featured->findAll(null, null, $orderBy, 3);
|
||||
|
||||
$expected = array (
|
||||
0 => array (
|
||||
array (
|
||||
'Featured' => array (
|
||||
'id' => '1',
|
||||
'article_id' => '1',
|
||||
'article_featured_id' => '1',
|
||||
'category_id' => '1',
|
||||
'published_date' => '2007-03-31 10:39:23',
|
||||
'end_date' => '2007-05-15 10:39:23',
|
||||
'created' => '2007-03-18 10:39:23',
|
||||
'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'Article' => array (
|
||||
'ArticleFeatured' => array (
|
||||
'id' => '1',
|
||||
'title' => 'First Article',
|
||||
'user_id' => '1',
|
||||
|
@ -703,7 +725,7 @@ class ModelTest extends CakeTestCase {
|
|||
),
|
||||
'Featured' => array (
|
||||
'id' => '1',
|
||||
'article_id' => '1',
|
||||
'article_featured_id' => '1',
|
||||
'category_id' => '1',
|
||||
'published_date' => '2007-03-31 10:39:23',
|
||||
'end_date' => '2007-05-15 10:39:23',
|
||||
|
@ -719,17 +741,17 @@ class ModelTest extends CakeTestCase {
|
|||
'updated' => '2007-03-18 15:32:31'
|
||||
)
|
||||
),
|
||||
1 => array (
|
||||
array (
|
||||
'Featured' => array (
|
||||
'id' => '2',
|
||||
'article_id' => '2',
|
||||
'article_featured_id' => '2',
|
||||
'category_id' => '1',
|
||||
'published_date' => '2007-03-31 10:39:23',
|
||||
'end_date' => '2007-05-15 10:39:23',
|
||||
'created' => '2007-03-18 10:39:23',
|
||||
'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'Article' => array (
|
||||
'ArticleFeatured' => array (
|
||||
'id' => '2',
|
||||
'title' => 'Second Article',
|
||||
'user_id' => '3',
|
||||
|
@ -743,7 +765,7 @@ class ModelTest extends CakeTestCase {
|
|||
),
|
||||
'Featured' => array (
|
||||
'id' => '2',
|
||||
'article_id' => '2',
|
||||
'article_featured_id' => '2',
|
||||
'category_id' => '1',
|
||||
'published_date' => '2007-03-31 10:39:23',
|
||||
'end_date' => '2007-05-15 10:39:23',
|
||||
|
@ -762,7 +784,6 @@ class ModelTest extends CakeTestCase {
|
|||
);
|
||||
|
||||
$this->assertEqual($result, $expected);
|
||||
*/
|
||||
}
|
||||
|
||||
function testSaveField() {
|
||||
|
|
53
cake/tests/fixtures/article_featured_fixture.php
vendored
Normal file
53
cake/tests/fixtures/article_featured_fixture.php
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id: article_featured_fixture.php 4668 2007-03-23 22:11:06Z phpnut $ */
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.fixtures
|
||||
* @since CakePHP(tm) v 1.2.0.4667
|
||||
* @version $Revision: 4668 $
|
||||
* @modifiedby $LastChangedBy: phpnut $
|
||||
* @lastmodified $Date: 2007-03-23 19:11:06 -0300 (Vie, 23 Mar 2007) $
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.fixtures
|
||||
*/
|
||||
class ArticleFeaturedFixture extends CakeTestFixture {
|
||||
var $name = 'ArticleFeatured';
|
||||
var $fields = array(
|
||||
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||
'user_id' => array('type' => 'integer', 'null' => false),
|
||||
'title' => array('type' => 'string', 'null' => false),
|
||||
'body' => 'text',
|
||||
'published' => array('type' => 'string', 'length' => 1, 'default' => 'N'),
|
||||
'created' => 'datetime',
|
||||
'updated' => 'datetime'
|
||||
);
|
||||
var $records = array(
|
||||
array ('id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'),
|
||||
array ('id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'),
|
||||
array ('id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31')
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
6
cake/tests/fixtures/featured_fixture.php
vendored
6
cake/tests/fixtures/featured_fixture.php
vendored
|
@ -36,7 +36,7 @@ class FeaturedFixture extends CakeTestFixture {
|
|||
var $name = 'Featured';
|
||||
var $fields = array(
|
||||
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||
'article_id' => array('type' => 'integer', 'null' => false),
|
||||
'article_featured_id' => array('type' => 'integer', 'null' => false),
|
||||
'category_id' => array('type' => 'integer', 'null' => false),
|
||||
'published_date' => 'datetime',
|
||||
'end_date' => 'datetime',
|
||||
|
@ -44,8 +44,8 @@ class FeaturedFixture extends CakeTestFixture {
|
|||
'updated' => 'datetime'
|
||||
);
|
||||
var $records = array(
|
||||
array ('id' => 1, 'article_id' => 1, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'),
|
||||
array ('id' => 2, 'article_id' => 2, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'),
|
||||
array ('id' => 1, 'article_featured_id' => 1, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'),
|
||||
array ('id' => 2, 'article_featured_id' => 2, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue