forked from mandango/MandangoBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
6 changed files
with
145 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/phpunit.xml | ||
/vendor/ | ||
/TestsProject/app/cache/ | ||
/TestsProject/app/log/ | ||
/TestsProject/src/Model/Base/ | ||
/TestsProject/src/Model/Mapping/ | ||
/TestsProject/src/Model/*/Base/ |
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 |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
use Symfony\Component\HttpKernel\Log\LoggerInterface; | ||
|
||
/** | ||
* MandangoDataCollector. | ||
* MandangoLogger. | ||
* | ||
* @author Pablo Díez <[email protected]> | ||
*/ | ||
|
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,46 @@ | ||
<?php | ||
|
||
namespace Mandango\MandangoBundle\Tests\Logger; | ||
|
||
use Mandango\MandangoBundle\Logger\MandangoLogger; | ||
|
||
class MandangoLoggerTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
private $logger; | ||
|
||
protected function setUp() | ||
{ | ||
$this->logger = new MandangoLogger(); | ||
} | ||
|
||
public function testLogQuery() | ||
{ | ||
$query = array('foo' => 'bar'); | ||
|
||
$kernelLogger = $this->getMock('Symfony\Component\HttpKernel\Log\LoggerInterface'); | ||
$kernelLogger | ||
->expects($this->once()) | ||
->method('info') | ||
->with('MongoDB Query: '.json_encode($query)); | ||
|
||
$logger = new MandangoLogger($kernelLogger); | ||
$logger->logQuery($query); | ||
} | ||
|
||
public function testGetQueries() | ||
{ | ||
$this->assertSame(array(), $this->logger->getQueries()); | ||
$this->logger->logQuery($query1 = array('foo' => 'bar')); | ||
$this->logger->logQuery($query2 = array('ups' => 'foo')); | ||
$this->assertSame(array($query1, $query2), $this->logger->getQueries()); | ||
} | ||
|
||
public function testCountQueries() | ||
{ | ||
$this->assertSame(0, $this->logger->getNbQueries()); | ||
$this->logger->logQuery(array()); | ||
$this->assertSame(1, $this->logger->getNbQueries()); | ||
$this->logger->logQuery(array()); | ||
$this->assertSame(2, $this->logger->getNbQueries()); | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
spl_autoload_register(function($class) { | ||
if (0 === strpos($class, 'Mandango\\MandangoBundle\\')) { | ||
$path = implode('/', array_slice(explode('\\', $class), 2)).'.php'; | ||
require_once __DIR__.'/../'.$path; | ||
return true; | ||
} | ||
}); | ||
|
||
$vendorDir = __DIR__.'/../vendor'; | ||
require_once $vendorDir.'/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php'; | ||
|
||
use Symfony\Component\ClassLoader\UniversalClassLoader; | ||
|
||
$loader = new UniversalClassLoader(); | ||
$loader->registerNamespaces(array( | ||
'Symfony' => $vendorDir.'/symfony/src', | ||
'Mandango' => $vendorDir.'/mandango/src' | ||
)); | ||
$loader->register(); |
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,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit bootstrap="./Tests/bootstrap.php" colors="true"> | ||
|
||
<testsuites> | ||
<testsuite name="MandangoBundle Test Suite"> | ||
<directory suffix="Test.php">./Tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory>./</directory> | ||
<exclude> | ||
<directory>./Resources</directory> | ||
<directory>./Tests</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
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,50 @@ | ||
<?php | ||
|
||
set_time_limit(0); | ||
|
||
if (!is_dir($vendorDir = __DIR__.'/vendor')) { | ||
mkdir($vendorDir, 0777, true); | ||
} | ||
|
||
if (isset($argv[1])) { | ||
$_SERVER['SYMFONY_VERSION'] = $argv[1]; | ||
} | ||
|
||
$deps = array( | ||
array('symfony', 'git://github.com/symfony/symfony', isset($_SERVER['SYMFONY_VERSION']) ? $_SERVER['SYMFONY_VERSION'] : 'origin/master'), | ||
array('mondator', 'git://github.com/mandango/mondator', 'origin/master'), | ||
array('mandango', 'git://github.com/mandango/mandango', 'origin/master'), | ||
); | ||
|
||
foreach ($deps as $dep) { | ||
if (3 === count($dep)) { | ||
list($name, $url, $rev) = $dep; | ||
$target = null; | ||
} else { | ||
list($name, $url, $rev, $target) = $dep; | ||
} | ||
|
||
if (null === $rev) { | ||
$rev = 'origin/master'; | ||
} | ||
|
||
if (null !== $target) { | ||
$installDir = $vendorDir.'/'.$target; | ||
} else { | ||
$installDir = $vendorDir.'/'.$name; | ||
} | ||
|
||
$install = false; | ||
if (!is_dir($installDir)) { | ||
$install = true; | ||
echo "> Installing $name\n"; | ||
|
||
system(sprintf('git clone -q %s %s', escapeshellarg($url), escapeshellarg($installDir))); | ||
} | ||
|
||
if (!$install) { | ||
echo "> Updating $name\n"; | ||
} | ||
|
||
system(sprintf('cd %s && git fetch origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($rev))); | ||
} |