Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Commit

Permalink
Bugfixed Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chfsx committed Jul 3, 2014
1 parent 922a86b commit a6263c4
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 6 deletions.
13 changes: 13 additions & 0 deletions Connector/class.arConnectorPdoDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,20 @@ protected function returnDB() {
}


/**
* @return mixed
*/
public static function getConnector() {
return self::$pbo_connect;
}


/**
* @param ActiveRecord $ar
*
* @return null|void
*/
public function updateIndices(ActiveRecord $ar) {
return NULL;
}
}
2 changes: 1 addition & 1 deletion Factory/class.arFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class arFactory {
* @return ActiveRecord
* @throws arException
*/
public static function getInstance($class_name, $primary_key, $additional_arguments = array()) {
public static function getInstance($class_name, $primary_key = 0, $additional_arguments = array()) {
/**
* @var $obj ActiveRecord
*/
Expand Down
1 change: 0 additions & 1 deletion Tests/Records/class.arUnitTestRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public function __construct($primary = 0) {
* @db_is_notnull true
* @db_fieldtype integer
* @db_length 4
* @con_sequence true
*/
protected $id = 0;
/**
Expand Down
38 changes: 37 additions & 1 deletion Tests/StackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function setUp() {


public function testTableExistant() {
$this->assertTrue($this->pdo->tableExists(arUnitTestRecord::returnDbTableName()));
$this->assertTrue($this->pdo->tableExists($this->table_name));
}


Expand Down Expand Up @@ -143,6 +143,42 @@ public function testLimitAndOrder() {

//TODO mehr active records und list funktionen.

public function testMoreListFuntionality() {
$entry = arUnitTestRecord::where(array( "title" => "Title" ), '!=')->limit(0,100)->orderBy('title', 'DESC')->where('id != 1')->count();
$this->assertEquals($entry, 2);

$arUnitTestRecord8 = arUnitTestRecord::findOrGetInstance(8);
$this->assertTrue($arUnitTestRecord8 instanceof arUnitTestRecord);

$arUnitTestRecord8_fromCache = arUnitTestRecord::find(8);
$this->assertEquals($arUnitTestRecord8_fromCache, NULL);

$arUnitTestRecordInstance = arFactory::getInstance('arUnitTestRecord');
$this->assertEquals($arUnitTestRecordInstance->getId(), 0);

$arUnitTestRecord1_from_arObjectCache = arObjectCache::get('arUnitTestRecord', 2);
$this->assertEquals($arUnitTestRecord1_from_arObjectCache->getId(), 2);

$arUnitTestRecord8_fromCache = arUnitTestRecord::find(2);
$this->assertEquals($arUnitTestRecord8_fromCache->getId(), 2);
$this->assertTrue(arObjectCache::isCached('arUnitTestRecord', 2));
arObjectCache::purge($arUnitTestRecord1_from_arObjectCache);
$this->assertFalse(arObjectCache::isCached('arUnitTestRecord', 2));
$arUnitTestRecord8_fromCache = arUnitTestRecord::find(2);
$this->assertEquals($arUnitTestRecord8_fromCache->getId(), 2);


$arUnitTestRecord6 = new arUnitTestRecord();
$arUnitTestRecord6->setId(16);
$arUnitTestRecord6->setTitle('Title 16');
$arUnitTestRecord6->create();

$this->assertTrue(arObjectCache::isCached('arUnitTestRecord', 16));
$arUnitTestRecord6->delete();
$this->assertFalse(arObjectCache::isCached('arUnitTestRecord', 16));
$this->assertEquals(arUnitTestRecord::find(16), NULL);
}

public function testMoreActiveRecordFunctionality() {
$entry = arUnitTestRecord::find(1);
$csv = $entry->__asCsv(";", true);
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require-dev": {
"phpunit/phpunit": "3.7.*"
}
"require-dev": {
"phpunit/phpunit": "3.7.*"
}
}

0 comments on commit a6263c4

Please sign in to comment.