`
sillycat
  • 浏览: 2539136 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

PHP Backend Application(4)Mysql Advanced and Eclipse with PHPUnit

 
阅读更多
PHP Backend Application(4)Mysql Advanced and Eclipse with PHPUnit

1 MySQL Advanced Operation
FIND_IN_SET is not using index, it is said.
    public function getStateIDsByZipCodes($zipCodes)
    {
        //set up base features
        $logger = $this->ioc->getService("logger");

        $query = "
        SELECT
            zipcode,
            statesid
        FROM
            zipcities
        WHERE
            find_in_set(zipcode, ?)
        ";

        //prepare params
        $zipParam = implode(",", $zipCodes);
        $logger->debug("getStateIDsByZipCodes params--------------");
        $logger->debug("zipParam = " . $zipParam);
        $logger->debug("------------------------------------------");

        $conn = $this->getStatsDBConn();
        $stmt = $conn->prepare($query);
        $stmt->bind_param("s", $zipParam);
        $stmt->execute();

        $result = $stmt->get_result();
        //fetch all the rows
        $data = $result->fetch_all(MYSQLI_ASSOC);

        $this->closeDBConn($conn);
        return $data;
    }

So I plan to change that to IN
        //prepare params
        $zipParam = "(".implode(",", $zipCodes).")";
        $logger->debug("getStateIDsByZipCodes params--------------");
        $logger->debug("zipParam = " . $zipParam);
        $logger->debug("------------------------------------------");

        $query = "
        SELECT
            zipcode,
            statesid
        FROM
            zipcities
        WHERE
            zipcode IN $zipParam
        ";

2 ECLIPSE and PHPUNIT
Go to “Eclipse Marketplace” and Search for “MakeGood”, accept and install that plugin.
http://kumamidori.github.io/php/2014/11/24/makegood_composer/
https://github.com/piece/makegood/releases

I create a class named tests/bootstrap_test.php
<?php

require __DIR__.'/../vendor/autoload.php';
?>

Change the phpunit.xml as follow
<phpunit bootstrap="tests/bootstrap_test.php">
  <testsuites>
    <testsuite name="unitsuite">
      <directory>tests</directory>
    </testsuite>
  </testsuites>

</phpunit>

Set the MakeGood Configuration as follow:
PHPUnit
Test Folders = /projectname/tests/namespace_directory
Preload Script: /projectname/tests/bootstrap_test.php
XML Configuration File: /projectname/phpunit.xml

That is all I have, I may put more initiation actions in bootstrap_test.php later, but till now, it is good.

Check PHPUNIT Version
> phpunit --version
PHPUnit 5.4.2 by Sebastian Bergmann and contributors.

In the composer.json, if I have the latest version of phpunit, I will get some exceptions as follow:
"require-dev": {
        "php": ">=5.3.0",
        "phpunit/phpunit": ">=5.4.2",
        "phpunit/dbunit": ">=1.2",
        "phpunit/php-invoker": "*"
}

Fatal error: Call to undefined method PHPUnit_Util_Configuration::getSeleniumBrowserConfiguration() in /Applications/Eclipse.app/Contents/Eclipse/plugins/com.piece_framework.makegood.stagehandtestrunner_3.1.1.v201409021510/resources/php/vendor/piece/stagehand-testrunner/src/Preparer/PHPUnitPreparer.php on line 128

I think it is related to the version of MakeGood=3.1.1 and PHPUNIT=5.4.4

So I change the configuration to downgrade the version
    "require-dev": {
        "php": ">=5.3.0",
        "phpunit/phpunit": "^4",
        "phpunit/dbunit": ">=1.2",
        "phpunit/php-invoker": "*"
    }

PHPUNIT=4.8.26, it throw new exceptions:
[PHPUnit_Framework_Exception]

  Argument #3 (No Value) of PHPUnit_TextUI_ResultPrinter::__construct() must be a value from "never", "auto" or "always"

Then I check the phpunit version list from this URL
https://packagist.org/packages/phpunit/phpunit

I tried the version as follow, it works perfectly.
    "require-dev": {
        "php": ">=5.3.0",
        "phpunit/phpunit": "~4.5.1",
        "phpunit/dbunit": ">=1.2",
        "phpunit/php-invoker": "*"
    }

By the way, I am using Eclipse latest version right now, it is

Eclipse for PHP Developers

Version: Neon Release Candidate 3 (4.6.0RC3)
Build id: 20160602-0837

References:
Exception Handler
http://blog.csdn.net/hguisu/article/details/7464977
http://php.net/manual/en/language.exceptions.php
分享到:
评论

相关推荐

    Mastering The Faster Web with PHP, MySQL, and JavaScript 1st pdf

    This book will get you started with the latest benchmarking, profiling and monitoring tools for PHP, MySQL and JavaScript using Docker-based technologies. From optimizing PHP 7 code to learning ...

    php form generator mysql db backend

    php mysql html form generator using this script you can generate html form for your website and it gives out php script and mysql db schema for you to use with out any coding knowledge

    pdns-backend-mysql-4.1.11-1.el7.x86_64.rpm

    官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装

    pdns-backend-mysql-4.0.6-2.el7.x86_64.rpm

    官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装

    Linux源码安装MySQL+MySQL主从+Nginx+Nginx负载均衡+redis+php+phpredis+tomcat

    在本教程中,我们将深入探讨如何在Linux环境中源码安装MySQL、MySQL主从复制、Nginx、Nginx负载均衡、Redis... ./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-config-file-scan-dir=/etc/...

    Full-Stack Vue.js 2 and Laravel 5 Bring the frontend and backend together epub

    Full-Stack Vue.js 2 and Laravel 5 Bring the frontend and backend together with Vue, Vuex, and Laravel 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网...

    PHP Reactive Programming

    The book will then focus on writing extendable RxPHP code by developing a code testing tool and also cover Using RxPHP on both the server and client side of the application. With a concluding chapter...

    Building Scalable Apps with Redis and Node.js(PACKT,2014)

    You start with developing a backend web application followed by a frontend interface, and later on deploy it to the cloud platform. This book takes a holistic approach to server-side programming ...

    Backend_Application

    在项目"Backend_Application-main"中,我们可以期待找到与上述知识点相关的源代码、配置文件和资源。通过阅读和分析这些内容,可以深入理解一个基于Java的后端应用是如何设计和实现的。开发者可能还使用了Maven或...

    Creating your MySQL Database.pdf

    Anyone working with applications that use a MySQL database backend will benefit greatly from the advice and techniques in this book. Although a working knowledge of both SQL and MySQL is assumed, the...

    Building Applications with Spring 5 and Kotlin

    along with Kotlin to build a robust backend in a microservice architecture with a REST based collaboration, and leverage Project Reactor in your application. You’ll then learn how to integrate Spring...

    Tkinter GUI Application Development HOTSHOT(PACKT,2013)

    building real-world, productive and fun applications like text editor, drum machine, game of chess, media player, drawing application and many more. Each subsequent project builds on the skills ...

    nginx+apache+mysql+php+memcached+squid搭建门户网站

    ### Nginx+Apache+MySQL+PHP+Memcached+Squid 搭建门户网站 #### 一、前言与架构概述 随着互联网技术的发展,如何构建一个高效、稳定且能够应对高并发访问的Web服务器成为了许多企业和开发者关注的重点。本文将...

    Hybrid Mobile Development with Ionic

    You will also implement various native plugins and integrate them with Ionic and Ionic Cloud services to use them optimally in your application. By this time, you will be able to create a full-...

    Serverless Web Applications with React and Firebase

    This book provides more practical insights rather than just theoretical concepts and includes basic to advanced examples – from hello world to a real-time seat booking app and Helpdesk application ...

    开源项目-1backend-1backend.zip

    3. **数据库服务**:作为一个 PaaS 平台,1backend 很可能提供了数据库服务,如 MySQL、PostgreSQL 或 NoSQL 数据库,以便用户可以轻松地存储和访问数据。 4. **身份验证与授权**:安全是任何服务的重要组成部分,1...

Global site tag (gtag.js) - Google Analytics