Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Conversation

@jmglsn
Copy link

@jmglsn jmglsn commented Jan 3, 2013

I needed to get the output of phpcpd direct on sdtout. I'm currently expanding my netbeans plugin to support phpcpd too.
So I added --xlm-out to pass through phpcpd-xml direct to cmd.

@sebastianbergmann
Copy link
Owner

Just log to php://stdout and use --quiet:

➜  phpcpd git:(master) phpcpd --log-pmd php://stdout --quiet /usr/local/src/phpunit
<?xml version="1.0" encoding="UTF-8"?>
<pmd-cpd>
  <duplication lines="57" tokens="76">
    <file path="/usr/local/src/phpunit/Tests/_files/BankAccountTest.php" line="58"/>
    <file path="/usr/local/src/phpunit/Tests/_files/BankAccountTest.test.php" line="58"/>
    <codefragment>class BankAccountTest extends PHPUnit_Framework_TestCase
{
    protected $ba;

    protected function setUp()
    {
        $this-&gt;ba = new BankAccount;
    }

    /**
     * @covers BankAccount::getBalance
     * @group balanceIsInitiallyZero
     * @group specification
     */
    public function testBalanceIsInitiallyZero()
    {
        $this-&gt;assertEquals(0, $this-&gt;ba-&gt;getBalance());
    }

    /**
     * @covers BankAccount::withdrawMoney
     * @group balanceCannotBecomeNegative
     * @group specification
     */
    public function testBalanceCannotBecomeNegative()
    {
        try {
            $this-&gt;ba-&gt;withdrawMoney(1);
        }

        catch (BankAccountException $e) {
            $this-&gt;assertEquals(0, $this-&gt;ba-&gt;getBalance());

            return;
        }

        $this-&gt;fail();
    }

    /**
     * @covers BankAccount::depositMoney
     * @group balanceCannotBecomeNegative
     * @group specification
     */
    public function testBalanceCannotBecomeNegative2()
    {
        try {
            $this-&gt;ba-&gt;depositMoney(-1);
        }

        catch (BankAccountException $e) {
            $this-&gt;assertEquals(0, $this-&gt;ba-&gt;getBalance());

            return;
        }

        $this-&gt;fail();
</codefragment>
  </duplication>
</pmd-cpd>

@jmglsn
Copy link
Author

jmglsn commented Jul 25, 2013

Thanks 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants