From 3834201966092a5ca5bd86bc116db0518134bfc3 Mon Sep 17 00:00:00 2001 From: Kleduy Date: Thu, 12 May 2022 15:42:17 +0200 Subject: [PATCH 1/2] BaseMapperTest --- test/Unit/BaseMapperTest.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/Unit/BaseMapperTest.php diff --git a/test/Unit/BaseMapperTest.php b/test/Unit/BaseMapperTest.php new file mode 100644 index 0000000..daa705e --- /dev/null +++ b/test/Unit/BaseMapperTest.php @@ -0,0 +1,35 @@ +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(); + $test->expects($this->once()) + ->method('setFactory') + ->willReturn(TRUE); + $this->assertTrue($this->base->setFactory($test)); + } + + +} From 7257a729ec2d27ff6cb8eda5ceed49744197b0ad Mon Sep 17 00:00:00 2001 From: Kleduy Date: Fri, 3 Jun 2022 16:59:34 +0200 Subject: [PATCH 2/2] FactoryTest --- test/Unit/FactoryTest.php | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 test/Unit/FactoryTest.php diff --git a/test/Unit/FactoryTest.php b/test/Unit/FactoryTest.php new file mode 100644 index 0000000..a6d2443 --- /dev/null +++ b/test/Unit/FactoryTest.php @@ -0,0 +1,63 @@ +createMock(Horde_Db_Adapter::class); + + $q=new Factory($adapter); + $c=$q->__construct($adapter); + + $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(){ + $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(){ + $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); + } + +} \ No newline at end of file