-
Notifications
You must be signed in to change notification settings - Fork 4
BaseMapperTest #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: FRAMEWORK_6_0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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(){ | ||
| $this->base=$this->createMock(BaseMapper::class); | ||
|
|
||
| $test=$this->getMockBuilder('Factory')->getMock(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)); | ||
| } | ||
|
|
||
|
|
||
| } | ||
| 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(){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
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