Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions test/Unit/BaseMapperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Horde\Rdo\Unit\Test;
use \Horde_Db_Adapter;
use Horde\Test\TestCase;

use Horde\Rdo\BaseMapper;

class AbstractClassBaseMapperTest extends TestCase
{
public function testtest(){
$this->i = 'test';
$this->j = 'test';
$this->assertSame($this->i,$this->j);
}

public function test__construct(){
$this->base=$this->createMock(BaseMapper::class);
$this->a = $this->createMock(Horde_Db_Adapter::class);
$this->assertNull($this->base->__construct($this->a));

}

public function testsetFactory(){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be testSetFactory, not testsetFactory

$this->base=$this->createMock(BaseMapper::class);

$test=$this->getMockBuilder('Factory')->getMock();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing $test = $this

$test->expects($this->once())
->method('setFactory')
->willReturn(TRUE);
$this->assertTrue($this->base->setFactory($test));
}


}
63 changes: 63 additions & 0 deletions test/Unit/FactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace Horde\Rdo\Unit\Test;
use \Horde_Db_Adapter;

use Horde\Test\TestCase;

use Horde\Rdo\Factory;
use Horde\Rdo\Mapper;
use Horde\Rdo\RdoException;
use Horde_Db;

class FactoryTest extends TestCase{

//@return Factory The Factory

public function test__construct(){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to testConstructor, if needed at all

$adapter=$this->createMock(Horde_Db_Adapter::class);

$q=new Factory($adapter);
$c=$q->__construct($adapter);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong. You don't call the constructor on an existing object.


$this->assertInstanceOf(Factory::class,$q);

}


public function testcount(){

//count returns number of cached mappers as Integer
$adapter=$this->createMock(Horde_Db_Adapter::class);

$q=new Factory($adapter);
$c=$q->count();
$this->assertIsInt($c);

}

/* public function testcreateClassExist(){

}
*/
public function testcreateClassDoesNotExist(){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testCreate...

$adapter=$this->createMock(Horde_Db_Adapter::class);
$q=new Factory($adapter);
$class='anything';
$this->expectException(RdoException::class);
$this->expectExceptionMessage((sprintf('Class %s not found', $class)));
$q->create($class,$adapter);

}

public function testcreateClassWithoutAdapter(){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testCreate...

$adapter=$this->createMock(Horde_Db_Adapter::class);

$q=new Factory($adapter);
$class=$this->createMock(Mapper::class);

$q->create($class,$adapter);
$this->assertInstanceOf(Mapper::class,$class);
}

}