Skip to content
Browse files

Made it run on CakePHP 2.2-dev.

  • Loading branch information...
1 parent a65c16c commit 8be789cf2f58ea95f3ee432da43fa2e2410f3bd9 @Phally committed Mar 17, 2012
View
0 models/behaviors/dimension.php → Model/Behavior/DimensionBehavior.php 100755 → 100644
File renamed without changes.
View
0 models/behaviors/facts.php → Model/Behavior/FactsBehavior.php 100755 → 100644
File renamed without changes.
View
46 ...cases/models/behaviors/dimension.test.php → .../Model/Behavior/DimensionBehaviorTest.php 100755 → 100644
@@ -1,54 +1,50 @@
<?php
-class Ip extends Model {
+class Ip extends CakeTestModel {
public $actsAs = array('Olap.Dimension');
- public $hasMany = array(
- 'Request'
- );
+ public $hasMany = array('Request');
}
-class Moment extends Model {
+class Moment extends CakeTestModel {
public $actsAs = array('Olap.Dimension' => array('unique' => array('day', 'month', 'year')));
- public $hasMany = array(
- 'Request'
- );
+ public $hasMany = array('Request');
}
-class Request extends Model {
+class Request extends CakeTestModel {
public $actsAs = array('Olap.Facts');
- public $belongsTo = array(
- 'Ip',
- 'Location',
- 'Moment'
- );
+ public $belongsTo = array('Ip', 'Location', 'Moment');
}
-class DimensionBehaviorTestCase extends CakeTestCase {
+class DimensionBehaviorTest extends CakeTestCase {
public $fixtures = array(
'plugin.olap.moment',
'plugin.olap.ip',
'plugin.olap.request',
'plugin.olap.location'
);
-
+
private $Moment = null;
private $Ip = null;
-
- public function startTest() {
+
+ public function setUp() {
+ parent::setUp();
+
$this->Moment = ClassRegistry::init('Moment');
$this->Ip = ClassRegistry::init('Ip');
}
public function testGetUniqueFields() {
$expected = array('day', 'month', 'year');
- $result = $this->Moment->getUniqueFields();
- $this->assertIdentical($result, $expected);
-
+ $result = $this->Moment->getUniqueFields();
+ $this->assertSame($result, $expected);
+
$expected = array('address');
- $result = $this->Ip->getUniqueFields();
- $this->assertIdentical($result, $expected);
+ $result = $this->Ip->getUniqueFields();
+ $this->assertSame($result, $expected);
}
-
- public function endTest() {
+
+ public function tearDown() {
+ parent::tearDown();
+
ClassRegistry::flush();
unset($this->Moment);
unset($this->Ip);
View
124 tests/cases/models/behaviors/facts.test.php → ...Case/Model/Behavior/FactsBehaviorTest.php 100755 → 100644
@@ -1,32 +1,22 @@
<?php
-class Ip extends Model {
+class Ip extends CakeTestModel {
public $actsAs = array('Olap.Dimension');
- public $hasMany = array(
- 'Request'
- );
+ public $hasMany = array('Request');
}
-class Location extends Model {
+class Location extends CakeTestModel {
public $actsAs = array('Olap.Dimension');
- public $hasMany = array(
- 'Request'
- );
+ public $hasMany = array('Request');
}
-class Moment extends Model {
+class Moment extends CakeTestModel {
public $actsAs = array('Olap.Dimension' => array('unique' => array('hour', 'day', 'month', 'year')));
- public $hasMany = array(
- 'Request'
- );
+ public $hasMany = array('Request');
}
-class Request extends Model {
+class Request extends CakeTestModel {
public $actsAs = array('Olap.Facts');
- public $belongsTo = array(
- 'Ip',
- 'Location',
- 'Moment'
- );
+ public $belongsTo = array('Ip', 'Location', 'Moment');
}
class FactsBehaviorTestCase extends CakeTestCase {
@@ -36,13 +26,15 @@ class FactsBehaviorTestCase extends CakeTestCase {
'plugin.olap.location',
'plugin.olap.request',
);
-
+
private $Request = null;
-
- public function startTest() {
+
+ public function setUp() {
+ parent::setUp();
+
$this->Request = ClassRegistry::init('Request');
}
-
+
public function testSaveFactWithOneDimensionRecordCreated() {
$this->Request->saveFact(array(
'Location' => array(
@@ -59,22 +51,22 @@ public function testSaveFactWithOneDimensionRecordCreated() {
),
'number_of_visits' => 18
));
-
+
$result = $this->Request->find('first', array(
'conditions' => array(
'Location.path' => 'app/articles/show',
'Ip.address' => '192.168.1.100',
- 'Moment.hour' => 19,
- 'Moment.day' => 22,
- 'Moment.month' => 9,
- 'Moment.year' => 2010,
+ 'Moment.hour' => 19,
+ 'Moment.day' => 22,
+ 'Moment.month' => 9,
+ 'Moment.year' => 2010,
)
));
$expected = array(
'Request' => array(
'ip_id' => '1',
- 'location_id' => '1',
+ 'location_id' => '1',
'moment_id' => '5',
'number_of_visits' => '18'
),
@@ -94,9 +86,9 @@ public function testSaveFactWithOneDimensionRecordCreated() {
'year' => '2010'
)
);
-
- $this->assertIdentical($result, $expected, 'New record made for Moment and the rest associated. Fact has been saved. %s');
-
+
+ $this->assertSame($result, $expected);
+
$expected = array(
'Request' => array(
'Location' => array(
@@ -110,10 +102,10 @@ public function testSaveFactWithOneDimensionRecordCreated() {
)
)
);
-
- $this->assertIdentical($this->Request->Behaviors->Facts->dimensionIds, $expected, 'Dimension records properly cached. %s');
+
+ $this->assertSame($this->Request->Behaviors->Facts->dimensionIds, $expected);
}
-
+
public function testSaveFactWithAllDimensionRecordsCreated() {
$this->Request->saveFact(array(
'Location' => array(
@@ -130,22 +122,22 @@ public function testSaveFactWithAllDimensionRecordsCreated() {
),
'number_of_visits' => 1232
));
-
+
$result = $this->Request->find('first', array(
'conditions' => array(
'Location.path' => 'app/pictures/edit',
'Ip.address' => '123.123.123.123',
- 'Moment.hour' => 21,
- 'Moment.day' => 14,
- 'Moment.month' => 2,
- 'Moment.year' => 2009,
+ 'Moment.hour' => 21,
+ 'Moment.day' => 14,
+ 'Moment.month' => 2,
+ 'Moment.year' => 2009,
)
));
$expected = array(
'Request' => array(
'ip_id' => '5',
- 'location_id' => '5',
+ 'location_id' => '5',
'moment_id' => '5',
'number_of_visits' => '1232'
),
@@ -165,9 +157,9 @@ public function testSaveFactWithAllDimensionRecordsCreated() {
'year' => '2009'
)
);
-
- $this->assertIdentical($result, $expected, 'New records are made in the dimensions. Fact has been saved. %s');
-
+
+ $this->assertSame($result, $expected);
+
$expected = array(
'Request' => array(
'Location' => array(
@@ -181,8 +173,8 @@ public function testSaveFactWithAllDimensionRecordsCreated() {
)
)
);
-
- $this->assertIdentical($this->Request->Behaviors->Facts->dimensionIds, $expected, 'Dimension records properly cached. %s');
+
+ $this->assertSame($this->Request->Behaviors->Facts->dimensionIds, $expected);
}
public function testSaveFactWithNoDimensionRecordsCreated() {
@@ -194,30 +186,30 @@ public function testSaveFactWithNoDimensionRecordsCreated() {
'address' => '127.0.0.1'
),
'Moment' => array(
- 'hour' => 8,
- 'day' => 14,
- 'month' => 9,
+ 'hour' => 8,
+ 'day' => 14,
+ 'month' => 9,
'year' => 2010
),
'number_of_visits' => 12345
));
-
+
$result = $this->Request->find('first', array(
'conditions' => array(
'Location.path' => 'content_management/pages/display',
'Ip.address' => '127.0.0.1',
- 'Moment.hour' => 8,
- 'Moment.day' => 14,
- 'Moment.month' => 9,
- 'Moment.year' => 2010,
+ 'Moment.hour' => 8,
+ 'Moment.day' => 14,
+ 'Moment.month' => 9,
+ 'Moment.year' => 2010,
'Request.number_of_visits' => 12345
)
));
$expected = array(
'Request' => array(
'ip_id' => '4',
- 'location_id' => '3',
+ 'location_id' => '3',
'moment_id' => '3',
'number_of_visits' => '12345'
),
@@ -237,9 +229,9 @@ public function testSaveFactWithNoDimensionRecordsCreated() {
'year' => '2010'
)
);
-
- $this->assertIdentical($result, $expected, 'All dimension records are found and associated. Fact has been saved. %s');
-
+
+ $this->assertSame($result, $expected);
+
$expected = array(
'Request' => array(
'Location' => array(
@@ -253,12 +245,12 @@ public function testSaveFactWithNoDimensionRecordsCreated() {
)
)
);
-
- $this->assertIdentical($this->Request->Behaviors->Facts->dimensionIds, $expected, 'Dimension records properly cached. %s');
+
+ $this->assertSame($this->Request->Behaviors->Facts->dimensionIds, $expected);
}
public function testFind() {
-
+
$expected = array(
0 => array(
'Ip' => array(
@@ -270,7 +262,7 @@ public function testFind() {
)
)
);
-
+
$this->Request->virtualFields = array('count' => 'SUM(Request.number_of_visits)');
$result = $this->Request->find('all', array(
'fields' => array('Ip.id', 'Ip.address', 'count'),
@@ -281,11 +273,13 @@ public function testFind() {
),
'group' => array('Ip.id', 'Ip.address'),
));
-
- $this->assertIdentical($result, $expected);
+
+ $this->assertSame($result, $expected);
}
-
- public function endTest() {
+
+ public function tearDown() {
+ parent::tearDown();
+
ClassRegistry::flush();
unset($this->Request);
}
View
0 tests/fixtures/ip_fixture.php → Test/Fixture/IpFixture.php 100755 → 100644
File renamed without changes.
View
0 tests/fixtures/location_fixture.php → Test/Fixture/LocationFixture.php 100755 → 100644
File renamed without changes.
View
6 tests/fixtures/moment_fixture.php → Test/Fixture/MomentFixture.php 100755 → 100644
@@ -1,7 +1,7 @@
-<?php
+<?php
class MomentFixture extends CakeTestFixture {
public $name = 'Moment';
-
+
public $fields = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 11, 'key' => 'primary'),
'hour' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 2),
@@ -10,7 +10,7 @@ class MomentFixture extends CakeTestFixture {
'year' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 4),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
);
-
+
public $records = array(
array('id' => 1, 'hour' => 11, 'day' => 14, 'month' => 4, 'year' => 2010),
array('id' => 2, 'hour' => 8, 'day' => 14, 'month' => 4, 'year' => 2010),
View
0 tests/fixtures/request_fixture.php → Test/Fixture/RequestFixture.php 100755 → 100644
File renamed without changes.

0 comments on commit 8be789c

Please sign in to comment.
Something went wrong with that request. Please try again.