-
-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f2dbed
commit 88de789
Showing
12 changed files
with
233 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
version: "3" | ||
services: | ||
db: | ||
image: mysql | ||
environment: | ||
MYSQL_RANDOM_ROOT_PASSWORD: "yes" | ||
MYSQL_DATABASE: "incubator" | ||
MYSQL_USER: "incubator" | ||
MYSQL_PASSWORD: "secret" | ||
ports: | ||
- "3306:3306" | ||
|
||
aerospike: | ||
image: aerospike | ||
ports: | ||
- "3000:3000" | ||
|
||
redis: | ||
image: redis | ||
ports: | ||
- "6379:6379" | ||
|
||
beanstalk: | ||
image: schickling/beanstalkd | ||
ports: | ||
- "11300:11300" | ||
memcached: | ||
image: memcached | ||
ports: | ||
- "11211:11211" | ||
|
||
mongodb: | ||
image: mongo | ||
environment: | ||
MONGO_INITDB_DATABASE: incubator | ||
ports: | ||
- "27017:27017" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
/* | ||
+------------------------------------------------------------------------+ | ||
| Phalcon Framework | | ||
+------------------------------------------------------------------------+ | ||
| Copyright (c) 2011-2016 Phalcon Team (https://www.phalconphp.com) | | ||
+------------------------------------------------------------------------+ | ||
| This source file is subject to the New BSD License that is bundled | | ||
| with this package in the file LICENSE.txt. | | ||
| | | ||
| If you did not receive a copy of the license and are unable to | | ||
| obtain it through the world-wide-web, please send an email | | ||
| to [email protected] so we can send you a copy immediately. | | ||
+------------------------------------------------------------------------+ | ||
| Authors: Phoenix Osiris <[email protected]> | | ||
+------------------------------------------------------------------------+ | ||
*/ | ||
|
||
namespace Phalcon\Test\Test\Traits; | ||
|
||
use Phalcon\Config; | ||
use Phalcon\Db\Adapter\Pdo\Mysql; | ||
use Phalcon\Di\FactoryDefault; | ||
use Phalcon\Test\Codeception\ModelTestCase as ModelTest; | ||
use Phalcon\Test\Traits\ModelTestCase; | ||
|
||
class ModelTestCaseTest extends ModelTest | ||
{ | ||
/** @var ModelTestCase */ | ||
protected $testSubject = null; | ||
|
||
public function _before() | ||
{ | ||
$this->testSubject = $this->di->get(ModelTest::class); | ||
} | ||
|
||
public function testDbWithDb() | ||
{ | ||
$mockDb = $this->getMockBuilder(Mysql::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->di = $this->getMockBuilder(FactoryDefault::class) | ||
->disableOriginalConstructor() | ||
->setMethods(['has', 'get']) | ||
->getMock(); | ||
|
||
$this->di->expects($this->once()) | ||
->method('has') | ||
->with('db') | ||
->willReturn(true); | ||
|
||
$this->di->expects($this->once()) | ||
->method('get') | ||
->willReturn($mockDb); | ||
|
||
$this->testSubject->setDI($this->di); | ||
|
||
$reflectionMethod = new \ReflectionMethod(ModelTest::class, 'setDb'); | ||
$reflectionMethod->setAccessible(true); | ||
|
||
$this->assertSame($mockDb, $reflectionMethod->invoke($this->testSubject)); | ||
} | ||
|
||
public function testDbWithoutConfig() | ||
{ | ||
$this->testSubject = $this->getMockBuilder(ModelTest::class) | ||
->setMethods(['getConfig']) | ||
->getMock(); | ||
|
||
$this->testSubject->config = $this->getMockBuilder(Config::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->testSubject->expects($this->never()) | ||
->method('getConfig'); | ||
|
||
$this->di = $this->getMockBuilder(FactoryDefault::class) | ||
->disableOriginalConstructor() | ||
->setMethods(['has', 'set']) | ||
->getMock(); | ||
|
||
$this->di->expects($this->once()) | ||
->method('has') | ||
->with('db') | ||
->willReturn(false); | ||
|
||
$this->di->expects($this->once()) | ||
->method('set') | ||
->with('db', $this->isInstanceOf(\Closure::class)); | ||
|
||
$this->testSubject->setDI($this->di); | ||
|
||
$reflectionMethod = new \ReflectionMethod(ModelTest::class, 'setDb'); | ||
$reflectionMethod->setAccessible(true); | ||
|
||
$reflectionMethod->invoke($this->testSubject); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/* | ||
+------------------------------------------------------------------------+ | ||
| Phalcon Framework | | ||
+------------------------------------------------------------------------+ | ||
| Copyright (c) 2011-2016 Phalcon Team (https://www.phalconphp.com) | | ||
+------------------------------------------------------------------------+ | ||
| This source file is subject to the New BSD License that is bundled | | ||
| with this package in the file LICENSE.txt. | | ||
| | | ||
| If you did not receive a copy of the license and are unable to | | ||
| obtain it through the world-wide-web, please send an email | | ||
| to [email protected] so we can send you a copy immediately. | | ||
+------------------------------------------------------------------------+ | ||
| Authors: Phoenix Osiris <[email protected]> | | ||
+------------------------------------------------------------------------+ | ||
*/ | ||
|
||
namespace Phalcon\Test\Test\Traits; | ||
|
||
use Phalcon\Test\Codeception\UnitTestCase as Unit; | ||
use Phalcon\Config; | ||
use Phalcon\Test\Traits\UnitTestCase; | ||
use PHPUnit_Framework_MockObject_MockObject; | ||
|
||
class UnitTestCaseTest extends Unit | ||
{ | ||
/** @var UnitTestCase|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $testSubject = null; | ||
|
||
public function _before() | ||
{ | ||
$this->testSubject = $this->getMockBuilder( | ||
UnitTestCase::class | ||
)->getMockForTrait(); | ||
} | ||
|
||
public function testConfig() | ||
{ | ||
$this->tester->amGoingTo('Confirm Testing Fallback Works'); | ||
|
||
/** @var Config|PHPUnit_Framework_MockObject_MockObject $mockConfig */ | ||
$mockConfig = $this->getMockBuilder(Config::class)->getMock(); | ||
|
||
$this->assertNull($this->testSubject->getConfig()); | ||
|
||
$this->di->set('config', $mockConfig); | ||
|
||
$this->assertSame($this->testSubject, $this->testSubject->setConfig($mockConfig)); | ||
$this->assertSame($mockConfig, $this->testSubject->getConfig()); | ||
} | ||
} |
File renamed without changes.