diff --git a/.gitignore b/.gitignore
index dd62680..124117d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ sftp-config.json
composer.lock
.subsplit
.php_cs.cache
+.idea/
diff --git a/.idea/design_pattern.iml b/.idea/design_pattern.iml
deleted file mode 100644
index caab06b..0000000
--- a/.idea/design_pattern.iml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 28a804d..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index e203503..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/php.xml b/.idea/php.xml
deleted file mode 100644
index 0564203..0000000
--- a/.idea/php.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index 6e44200..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,407 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- $PROJECT_DIR$/composer.json
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
- DEFINITION_ORDER
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1541518168509
-
-
- 1541518168509
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..f3e95e5
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,15 @@
+language: php # 我们代码所需要运行的环境平台
+
+php: # 需要测试的版本
+ - 7.0
+ - 7.1
+ - 7.2
+
+dist: trusty # 系统版本
+sudo: false # 使用使用 sudo 模式
+
+# 执行前需要运行的命令
+install: travis_retry composer install --no-interaction --prefer-source
+
+# 主要构建命令
+script: vendor/bin/phpunit --verbose
diff --git a/README.md b/README.md
index 7c117c7..41ff2ee 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,21 @@
design_pattern
- .
+[](https://www.travis-ci.org/sockstack/design_pattern) [](https://github.styleci.io/repos/156411862)
## Installing
```shell
-$ composer require sockstack/design_pattern -vvv
+$ git clone https://github.com/sockstack/design_pattern.git
```
## Usage
-TODO
+```shell
+$ cd design_pattern/
+$ composer install -vvv
+$ vendor/bin/phpunit
+```
## Contributing
diff --git a/composer.json b/composer.json
index a961ea4..65f6a76 100644
--- a/composer.json
+++ b/composer.json
@@ -9,7 +9,8 @@
}
],
"require": {
- "phpunit/phpunit": "~5"
+ "phpunit/phpunit": "~5.7.0",
+ "mockery/mockery": "^1.2"
},
"autoload": {
"psr-4": {
diff --git a/src/FactoryMethod/Sample/Implemention/SUV.php b/src/FactoryMethod/Sample/Implemention/SUV.php
new file mode 100644
index 0000000..acde5bd
--- /dev/null
+++ b/src/FactoryMethod/Sample/Implemention/SUV.php
@@ -0,0 +1,20 @@
+assertTrue($suv instanceof SUV);
+
+ $taxi = TaxiFactory::create();
+ $this->assertTrue($taxi instanceof Taxi);
+ }
+}
diff --git a/tests/SimpleFactoryTest.php b/tests/SimpleFactoryTest.php
new file mode 100644
index 0000000..5ffda00
--- /dev/null
+++ b/tests/SimpleFactoryTest.php
@@ -0,0 +1,30 @@
+fail('创建实例对象失败');
+ }
+
+ $mysqli = SimpleFactory::createMysqli();
+ if (!$mysqli instanceof MysqliDriver) {
+ $this->fail('创建实例对象失败');
+ }
+ }
+}
diff --git a/tests/SingletonTest.php b/tests/SingletonTest.php
index f324788..4f33fc9 100644
--- a/tests/SingletonTest.php
+++ b/tests/SingletonTest.php
@@ -51,6 +51,6 @@ public function testSingleton()
$object1 = Singleton::getInstance();
$object2 = Singleton::getInstance();
- $this->assertEquals($object1, $object2);
+ $this->assertTrue($object1 === $object2, '两个对象不是同一个对象');
}
}