ソースを参照

Add coverage.

euromark 11 年 前
コミット
0ca1532e20
5 ファイル変更53 行追加37 行削除
  1. 19 1
      .travis.yml
  2. 1 0
      README.md
  3. 8 10
      phpunit.xml.dist
  4. 0 1
      tests/TestCase/Utility/MimeTest.php
  5. 25 25
      tests/TestCase/Utility/UtilityTest.php

+ 19 - 1
.travis.yml

@@ -16,23 +16,41 @@ env:
 matrix:
   fast_finish: true
 
+  include:
+    - php: 5.4
+      env: PHPCS=1 DEFAULT=0
+
+    - php: 5.4
+      env: COVERALLS=1 DEFAULT=0
+
   allow_failures:
     - env: DB=sqlite db_class='Cake\Database\Driver\Sqlite' db_dsn='sqlite::memory:'
     - env: DB=pgsql db_class='Cake\Database\Driver\Postgres' db_dsn='pgsql:host=127.0.0.1;dbname=cakephp_test' db_database="cakephp_test" db_username='postgres' db_password=''
+    - php: 5.4
+      env: PHPCS=1 DEFAULT=0
 
 before_script:
   - composer self-update
-  - composer install --dev
+  - composer install --prefer-source --no-interaction --dev
 
   - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi"
   - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE DATABASE cakephp_test;' -U postgres; fi"
 
+  - sh -c "if [ '$PHPCS' = '1' ]; then pear channel-discover pear.cakephp.org; fi"
+  - sh -c "if [ '$PHPCS' = '1' ]; then pear install --alldeps cakephp/CakePHP_CodeSniffer; fi"
+
+  - sh -c "if [ '$COVERALLS' = '1' ]; then composer require --dev satooshi/php-coveralls:dev-master; fi"
+  - sh -c "if [ '$COVERALLS' = '1' ]; then mkdir -p build/logs; fi"
+
   - phpenv rehash
   - set +H
   - cp phpunit.xml.dist phpunit.xml
 
 script:
+  - sh -c "if [ '$COVERALLS' = '1' ]; then phpunit --coverage-clover build/logs/clover.xml; fi"
+  - sh -c "if [ '$COVERALLS' = '1' ]; then php vendor/bin/coveralls -c .coveralls.yml -v; fi"
   - sh -c "if [ '$DEFAULT' = '1' ]; then phpunit; fi"
+  - sh -c "if [ '$PHPCS' = '1' ]; then phpcs -p --extensions=php --standard=CakePHP --ignore=vendor --ignore=Test --ignore=docs . ; fi"
 
 notifications:
   email: false

+ 1 - 0
README.md

@@ -1,5 +1,6 @@
 # CakePHP Tools Plugin
 [![Build Status](https://api.travis-ci.org/dereuromark/cakephp-tools.png?branch=cake3)](https://travis-ci.org/dereuromark/cakephp-tools)
+[![Coverage Status](https://coveralls.io/repos/dereuromark/cakephp-tools/badge.png?branch=cake3)](https://coveralls.io/r/dereuromark/cakephp-tools)
 [![License](https://poser.pugx.org/dereuromark/cakephp-tools/license.png)](https://packagist.org/packages/dereuromark/cakephp-tools)
 [![Total Downloads](https://poser.pugx.org/dereuromark/tools-cakephp/d/total.png)](https://packagist.org/packages/dereuromark/cakephp-tools)
 

+ 8 - 10
phpunit.xml.dist

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <phpunit
+	backupGlobals="false"
 	colors="true"
 	backupStaticAttributes="false"
 	processIsolation="false"
@@ -23,15 +24,12 @@
 		</listener>
 	</listeners>
 	<filter>
-		<whitelist>
-			<directory suffix=".php">Plugin/Tools</directory>
-			<exclude>
-				<directory suffix=".php">Plugin/Tools/Vendor</directory>
-				<directory suffix=".php">Plugin/Tools/Config/Schema</directory>
-				<directory suffix=".php">Plugin/Tools/Test</directory>
-				<directory suffix=".php">Plugin/Tools/TestSuite</directory>
-				<directory suffix=".php">Plugin/Tools/Lib/Error</directory>
-			</exclude>
-		</whitelist>
+		<blacklist>
+			<directory suffix=".php">./vendor/</directory>
+			<directory suffix=".ctp">./vendor/</directory>
+
+			<directory suffix=".php">./tests/</directory>
+			<directory suffix=".ctp">./tests/</directory>
+		</blacklist>
 	</filter>
 </phpunit>

+ 0 - 1
tests/TestCase/Utility/MimeTest.php

@@ -82,7 +82,6 @@ class MimeTest extends TestCase {
 	/**
 	 * testgetMimeTypeByAlias()
 	 *
-	 * @cover detectMimeType
 	 * @return void
 	 */
 	public function testgetMimeTypeByAlias() {

+ 25 - 25
tests/TestCase/Utility/UtilityTest.php

@@ -6,14 +6,14 @@ use Cake\Core\Plugin;
 use Cake\Core\Configure;
 
 /**
- * @covers Utility
+ * @coversDefaultClass \Tools\Utility\Utility
  */
 class UtilityTest extends TestCase {
 
 	/**
 	 * UtilityTest::testInArray()
 	 *
-	 * @covers Utility::inArray
+	 * @covers ::inArray
 	 * @return void
 	 */
 	public function testInArray() {
@@ -56,7 +56,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testPregMatch()
 	 *
-	 * @covers Utility::pregMatch
+	 * @covers ::pregMatch
 	 * @return void
 	 */
 	public function testPregMatch() {
@@ -92,7 +92,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testPregMatchWithPatternEscape()
 	 *
-	 * @covers Utility::pregMatch
+	 * @covers ::pregMatch
 	 * @return void
 	 */
 	public function testPregMatchWithPatternEscape() {
@@ -114,7 +114,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testPregMatchAll()
 	 *
-	 * @covers Utility::pregMatchAll
+	 * @covers ::pregMatchAll
 	 * @return void
 	 */
 	public function testPregMatchAll() {
@@ -138,7 +138,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testStrSplit()
 	 *
-	 * @covers Utility::strSplit
+	 * @covers ::strSplit
 	 * @return void
 	 */
 	public function testStrSplit() {
@@ -153,7 +153,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testUrlEncode()
 	 *
-	 * @covers Utility::urlEncode
+	 * @covers ::urlEncode
 	 * @return void
 	 */
 	public function testUrlEncode() {
@@ -164,7 +164,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testUrlDecode()
 	 *
-	 * @covers Utility::urlDecode
+	 * @covers ::urlDecode
 	 * @return void
 	 */
 	public function testUrlDecode() {
@@ -175,7 +175,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testTypeCast()
 	 *
-	 * @covers Utility::typeCast
+	 * @covers ::typeCast
 	 * @return void
 	 */
 	public function testTypeCast() {
@@ -187,7 +187,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testGetClientIp()
 	 *
-	 * @covers Utility::getClientIp
+	 * @covers ::getClientIp
 	 * @return void
 	 */
 	public function testGetClientIp() {
@@ -198,7 +198,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testFileExists()
 	 *
-	 * @covers Utility::fileExists
+	 * @covers ::fileExists
 	 * @return void
 	 */
 	public function testFileExists() {
@@ -218,7 +218,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testUrlExists()
 	 *
-	 * @covers Utility::urlExists
+	 * @covers ::urlExists
 	 * @return void
 	 */
 	public function testUrlExists() {
@@ -232,7 +232,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testGetReferer()
 	 *
-	 * @covers Utility::getReferer
+	 * @covers ::getReferer
 	 * @return void
 	 */
 	public function testGetReferer() {
@@ -254,7 +254,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testGetHeaderFromUrl()
 	 *
-	 * @covers Utility::getHeaderFromUrl
+	 * @covers ::getHeaderFromUrl
 	 * @return void
 	 */
 	public function testGetHeaderFromUrl() {
@@ -266,7 +266,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testAutoPrefixUrl()
 	 *
-	 * @covers Utility::autoPrefixUrl
+	 * @covers ::autoPrefixUrl
 	 * @return void
 	 */
 	public function testAutoPrefixUrl() {
@@ -277,7 +277,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testCleanUrl()
 	 *
-	 * @covers Utility::cleanUrl
+	 * @covers ::cleanUrl
 	 * @return void
 	 */
 	public function testCleanUrl() {
@@ -301,7 +301,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testDeep()
 	 *
-	 * @covers Utility::trimDeep
+	 * @covers ::trimDeep
 	 * @return void
 	 */
 	public function testDeep() {
@@ -512,7 +512,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testArrayFlattenBasic()
 	 *
-	 * @covers Utility::arrayFlatten
+	 * @covers ::arrayFlatten
 	 * @return void
 	 */
 	public function testArrayFlattenBasic() {
@@ -537,7 +537,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * Test that deeper nested values overwrite higher ones.
 	 *
-	 * @covers Utility::arrayFlatten
+	 * @covers ::arrayFlatten
 	 * @return void
 	 */
 	public function testArrayFlatten() {
@@ -560,7 +560,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testArrayFlattenAndPreserveKeys()
 	 *
-	 * @covers Utility::arrayFlatten
+	 * @covers ::arrayFlatten
 	 * @return void
 	 */
 	public function testArrayFlattenAndPreserveKeys() {
@@ -582,7 +582,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testArrayShiftKeys()
 	 *
-	 * @covers Utility::arrayShiftKeys
+	 * @covers ::arrayShiftKeys
 	 * @return void
 	 */
 	public function testArrayShiftKeys() {
@@ -605,7 +605,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testTime()
 	 *
-	 * @covers Utility::returnElapsedTime
+	 * @covers ::returnElapsedTime
 	 * @return void
 	 */
 	public function testTime() {
@@ -626,7 +626,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testLogicalAnd()
 	 *
-	 * @covers Utility::logicalAnd
+	 * @covers ::logicalAnd
 	 * @return void
 	 */
 	public function testLogicalAnd() {
@@ -652,7 +652,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testLogicalOr()
 	 *
-	 * @covers Utility::logicalOr
+	 * @covers ::logicalOr
 	 * @return void
 	 */
 	public function testLogicalOr() {
@@ -687,7 +687,7 @@ class UtilityTest extends TestCase {
 	/**
 	 * UtilityTest::testIsValidSaveAll()
 	 *
-	 * @covers Utility::isValidSaveAll
+	 * @covers ::isValidSaveAll
 	 * @return void
 	 */
 	public function testIsValidSaveAll() {