Fixing content type ordering when content_type is not defined.
[akelos.git] / test / unit / lib / AkActiveRecord / AkHasOne_specifications.php
blob03a78fce978eb7fbcbc5aac4e89f4746748909b7
1 <?php
3 defined('AK_TEST_DATABASE_ON') ? null : define('AK_TEST_DATABASE_ON', true);
4 require_once(dirname(__FILE__).'/../../../fixtures/config/config.php');
6 class test_HasOne_cascading_destroy extends AkUnitTest
8 #thumbnail belongsTo picture
9 /**
10 * hasOne main_thumbnail, dependent => true
11 * @var ActiveRecord
13 var $Picture;
14 function setUp()
16 $this->installAndIncludeModels(array('Picture','Thumbnail'));
17 $Picture =& $this->Picture->create(array('title'=>'This is not a picture'));
18 $Picture->main_thumbnail->create(array('caption'=>'It cant have a thumbnail'));
21 function test_ensure_we_have_the_setup_right()
23 $Picture =& $this->Picture->find('first',array('include'=>'main_thumbnail'));
24 $this->assertEqual(1,$Picture->main_thumbnail->photo_id);
26 $Thumb =& $this->Thumbnail->find('first');
27 $this->assertEqual(1,$Thumb->photo_id);
28 #var_dump($this->Picture->_db->select('SELECT * FROM thumbnails'));
31 function test_should_destroy_the_belonging_thumbnail()
33 $Picture =& $this->Picture->find('first',array('include'=>'main_thumbnail'));
34 $Picture->destroy();
36 $this->assertFalse($this->Thumbnail->find('first'));
39 function test_should_destroy_the_thumbnail_even_when_not_loaded()
41 $Picture =& $this->Picture->find('first');
42 $Picture->destroy();
44 $this->assertFalse($this->Thumbnail->find('first'),'Issue #125');
49 ak_test('test_HasOne_cascading_destroy',true);